Merge "Support rate-limiting thumbnail generation"
[lhc/web/wiklou.git] / includes / templates / Userlogin.php
1 <?php
2 /**
3 * Html form for user login (since 1.22 with VForm appearance).
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Templates
22 */
23
24 class UserloginTemplate extends BaseTemplate {
25
26 function execute() {
27 global $wgCookieExpiration;
28 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
29 ?>
30 <div class="mw-ui-container">
31 <?php if ( $this->haveData( 'languages' ) ) { ?>
32 <div id="languagelinks">
33 <p><?php $this->html( 'languages' ); ?></p>
34 </div>
35 <?php } ?>
36 <div id="userloginForm">
37 <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
38 <?php if ( $this->data['loggedin'] ) { ?>
39 <div class="warningbox">
40 <?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
41 </div>
42 <?php } ?>
43 <section class="mw-form-header">
44 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
45 </section>
46
47 <?php if ( $this->data['message'] ) { ?>
48 <div class="<?php $this->text( 'messagetype' ); ?>box">
49 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
50 <strong><?php $this->msg( 'loginerror' ); ?></strong>
51 <br />
52 <?php } ?>
53 <?php $this->html( 'message' ); ?>
54 </div>
55 <?php } ?>
56
57 <div>
58 <label for='wpName1'>
59 <?php
60 $this->msg( 'userlogin-yourname' );
61
62 if ( $this->data['secureLoginUrl'] ) {
63 echo Html::element( 'a', array(
64 'href' => $this->data['secureLoginUrl'],
65 'class' => 'mw-ui-flush-right mw-secure',
66 ), $this->getMsg( 'userlogin-signwithsecure' )->text() );
67 }
68 ?>
69 </label>
70 <?php
71 $extraAttrs = array();
72 // Set focus to this field if it's blank.
73 if ( !$this->data['name'] ) {
74 $extraAttrs['autofocus'] = '';
75 }
76 echo Html::input( 'wpName', $this->data['name'], 'text', array(
77 'class' => 'loginText',
78 'id' => 'wpName1',
79 'tabindex' => '1',
80 'size' => '20',
81 // 'required' is blacklisted for now in Html.php due to browser issues.
82 // Keeping here in case that changes.
83 'required',
84 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text()
85 ) + $extraAttrs );
86 ?>
87 </div>
88
89 <div>
90 <label for='wpPassword1'>
91 <?php
92 $this->msg( 'userlogin-yourpassword' );
93
94 if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
95 echo ' ' . Linker::link(
96 SpecialPage::getTitleFor( 'PasswordReset' ),
97 $this->getMsg( 'userlogin-resetpassword-link' )->parse(),
98 array( 'class' => 'mw-ui-flush-right' )
99 );
100 }
101 ?>
102 </label>
103 <?php
104 $extraAttrs = array();
105 // Set focus to this field if username is filled in.
106 if ( $this->data['name'] ) {
107 $extraAttrs['autofocus'] = '';
108 }
109 echo Html::input( 'wpPassword', null, 'password', array(
110 'class' => 'loginPassword',
111 'id' => 'wpPassword1',
112 'tabindex' => '2',
113 'size' => '20',
114 'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
115 ) + $extraAttrs );
116 ?>
117 </div>
118
119 <?php
120 if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
121 $doms = "";
122 foreach ( $this->data['domainnames'] as $dom ) {
123 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
124 }
125 ?>
126 <div id="mw-user-domain-section">
127 <label for='wpDomain'><?php $this->msg( 'yourdomainname' ); ?></label>
128 <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>" tabindex="3">
129 <?php echo $doms; ?>
130 </select>
131 </div>
132 <?php } ?>
133
134 <?php
135 if ( $this->haveData( 'extrafields' ) ) {
136 echo $this->data['extrafields'];
137 }
138 ?>
139
140 <div>
141 <?php if ( $this->data['canremember'] ) { ?>
142 <label class="mw-ui-checkbox-label">
143 <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
144 <?php if ( $this->data['remember'] ) {
145 echo 'checked="checked"';
146 } ?>
147 >
148 <?php echo $this->getMsg( 'userlogin-remembermypassword' )->numParams( $expirationDays )->escaped(); ?>
149 </label>
150 <?php } ?>
151 </div>
152
153 <div>
154 <?php
155 echo Html::input( 'wpLoginAttempt', $this->getMsg( 'login' )->text(), 'submit', array(
156 'id' => 'wpLoginAttempt',
157 'tabindex' => '6',
158 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-primary'
159 ) );
160 ?>
161 </div>
162
163 <div id="mw-userlogin-help">
164 <?php echo $this->getMsg( 'userlogin-helplink' )->parse(); ?>
165 </div>
166 <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
167 <?php if ( $this->data['loggedin'] ) { ?>
168 <div id="mw-createaccount-another">
169 <h3 id="mw-userloginlink"><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7" class="mw-ui-button"><?php $this->msg( 'userlogin-createanother' ); ?></a></h3>
170 </div>
171 <?php } else { ?>
172 <div id="mw-createaccount-cta">
173 <h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7" class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ); ?></a></h3>
174 </div>
175 <?php } ?>
176 <?php } ?>
177 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
178 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
179 <?php if ( $this->data['cansecurelogin'] ) {?><input type="hidden" name="wpForceHttps" value="<?php $this->text( 'stickhttps' ); ?>" /><?php } ?>
180 </form>
181 </div>
182 </div>
183 <?php
184
185 }
186 }