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