Merge r81445 from 1.17: revert r70520 (js password complexity checker)
[lhc/web/wiklou.git] / includes / templates / Userlogin.php
1 <?php
2 /**
3 * Html forms for user login and account creation
4 *
5 * @file
6 * @ingroup Templates
7 */
8
9 /**
10 * @defgroup Templates Templates
11 */
12
13 if( !defined( 'MEDIAWIKI' ) ) die( -1 );
14
15 /**
16 * HTML template for Special:Userlogin form
17 * @ingroup Templates
18 */
19 class UserloginTemplate extends QuickTemplate {
20 function execute() {
21 if( $this->data['message'] ) {
22 ?>
23 <div class="<?php $this->text('messagetype') ?>box">
24 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
25 <strong><?php $this->msg( 'loginerror' )?></strong><br />
26 <?php } ?>
27 <?php $this->html('message') ?>
28 </div>
29 <div class="visualClear"></div>
30 <?php } ?>
31
32 <div id="loginstart"><?php $this->msgWiki( 'loginstart' ); ?></div>
33 <div id="userloginForm">
34 <form name="userlogin" method="post" action="<?php $this->text('action') ?>">
35 <h2><?php $this->msg('login') ?></h2>
36 <p id="userloginlink"><?php $this->html('link') ?></p>
37 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
38 <div id="userloginprompt"><?php $this->msgWiki('loginprompt') ?></div>
39 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
40 <table>
41 <tr>
42 <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
43 <td class="mw-input">
44 <?php
45 echo Html::input( 'wpName', $this->data['name'], 'text', array(
46 'class' => 'loginText',
47 'id' => 'wpName1',
48 'tabindex' => '1',
49 'size' => '20',
50 'required'
51 # Can't do + array( 'autofocus' ) because + for arrays in PHP
52 # only works right for associative arrays! Thanks, PHP.
53 ) + ( $this->data['name'] ? array() : array( 'autofocus' => '' ) ) ); ?>
54
55 </td>
56 </tr>
57 <tr>
58 <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
59 <td class="mw-input">
60 <?php
61 echo Html::input( 'wpPassword', null, 'password', array(
62 'class' => 'loginPassword',
63 'id' => 'wpPassword1',
64 'tabindex' => '2',
65 'size' => '20'
66 ) + ( $this->data['name'] ? array( 'autofocus' ) : array() ) ); ?>
67
68 </td>
69 </tr>
70 <?php if( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
71 $doms = "";
72 foreach( $this->data['domainnames'] as $dom ) {
73 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
74 }
75 ?>
76 <tr id="mw-user-domain-section">
77 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
78 <td class="mw-input">
79 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
80 tabindex="3">
81 <?php echo $doms ?>
82 </select>
83 </td>
84 </tr>
85 <?php }
86
87 if( $this->haveData( 'extrafields' ) ) {
88 echo $this->data['extrafields'];
89 }
90
91 if( $this->data['canremember'] ) { ?>
92 <tr>
93 <td></td>
94 <td class="mw-input">
95 <?php
96 global $wgCookieExpiration, $wgLang;
97 echo Xml::checkLabel(
98 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
99 'wpRemember',
100 'wpRemember',
101 $this->data['remember'],
102 array( 'tabindex' => '8' )
103 )
104 ?>
105 </td>
106 </tr>
107 <?php } ?>
108 <?php if( $this->data['cansecurelogin'] ) { ?>
109 <tr>
110 <td></td>
111 <td class="mw-input">
112 <?php
113 echo Xml::checkLabel(
114 wfMsg( 'securelogin-stick-https' ),
115 'wpStickHTTPS',
116 'wpStickHTTPS',
117 $this->data['stickHTTPS'],
118 array( 'tabindex' => '9' )
119 );
120 ?>
121 </td>
122 </tr>
123 <?php } ?>
124 <tr>
125 <td></td>
126 <td class="mw-submit">
127 <?php
128 echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
129 'id' => 'wpLoginAttempt',
130 'tabindex' => '9'
131 ) );
132 if ( $this->data['useemail'] && $this->data['canreset'] ) {
133 echo '&#160;';
134 echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
135 'id' => 'wpMailmypassword',
136 'tabindex' => '10'
137 ) );
138 } ?>
139
140 </td>
141 </tr>
142 </table>
143 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
144 <?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
145 </form>
146 </div>
147 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
148 <?php
149
150 }
151 }
152
153 /**
154 * @ingroup Templates
155 */
156 class UsercreateTemplate extends QuickTemplate {
157 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
158 $this->data['extraInput'][] = array(
159 'name' => $name,
160 'value' => $value,
161 'type' => $type,
162 'msg' => $msg,
163 'helptext' => $helptext,
164 );
165 }
166
167 function execute() {
168 if( $this->data['message'] ) {
169 ?>
170 <div class="<?php $this->text('messagetype') ?>box">
171 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
172 <strong><?php $this->msg( 'loginerror' )?></strong><br />
173 <?php } ?>
174 <?php $this->html('message') ?>
175 </div>
176 <div class="visualClear"></div>
177 <?php } ?>
178
179 <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
180 <div id="userlogin">
181
182 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
183 <h2><?php $this->msg('createaccount') ?></h2>
184 <p id="userloginlink"><?php $this->html('link') ?></p>
185 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
186 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
187 <table>
188 <tr>
189 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
190 <td class="mw-input">
191 <?php
192 echo Html::input( 'wpName', $this->data['name'], 'text', array(
193 'class' => 'loginText',
194 'id' => 'wpName2',
195 'tabindex' => '1',
196 'size' => '20',
197 'required',
198 'autofocus'
199 ) ); ?>
200 </td>
201 </tr>
202 <tr>
203 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
204 <td class="mw-input">
205 <?php
206 echo Html::input( 'wpPassword', null, 'password', array(
207 'class' => 'loginPassword',
208 'id' => 'wpPassword2',
209 'tabindex' => '2',
210 'size' => '20'
211 ) + User::passwordChangeInputAttribs() ); ?>
212 </td>
213 </tr>
214 <?php if( $this->data['usedomain'] ) {
215 $doms = "";
216 foreach( $this->data['domainnames'] as $dom ) {
217 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
218 }
219 ?>
220 <tr>
221 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
222 <td class="mw-input">
223 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
224 tabindex="3">
225 <?php echo $doms ?>
226 </select>
227 </td>
228 </tr>
229 <?php } ?>
230 <tr>
231 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
232 <td class="mw-input">
233 <?php
234 echo Html::input( 'wpRetype', null, 'password', array(
235 'class' => 'loginPassword',
236 'id' => 'wpRetype',
237 'tabindex' => '4',
238 'size' => '20'
239 ) + User::passwordChangeInputAttribs() ); ?>
240 </td>
241 </tr>
242 <tr>
243 <?php if( $this->data['useemail'] ) { ?>
244 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
245 <td class="mw-input">
246 <?php
247 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
248 'class' => 'loginText',
249 'id' => 'wpEmail',
250 'tabindex' => '5',
251 'size' => '20'
252 ) ); ?>
253 <div class="prefsectiontip">
254 <?php // duplicated in Preferences.php profilePreferences()
255 if( $this->data['emailrequired'] ) {
256 $this->msgWiki('prefs-help-email-required');
257 } else {
258 $this->msgWiki('prefs-help-email');
259 }
260 if( $this->data['emailothers'] ) {
261 $this->msgWiki('prefs-help-email-others');
262 } ?>
263 </div>
264 </td>
265 <?php } ?>
266 <?php if( $this->data['userealname'] ) { ?>
267 </tr>
268 <tr>
269 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
270 <td class="mw-input">
271 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
272 tabindex="6"
273 value="<?php $this->text('realname') ?>" size='20' />
274 <div class="prefsectiontip">
275 <?php $this->msgWiki('prefs-help-realname'); ?>
276 </div>
277 </td>
278 <?php } ?>
279 <?php if( $this->data['usereason'] ) { ?>
280 </tr>
281 <tr>
282 <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
283 <td class="mw-input">
284 <input type='text' class='loginText' name="wpReason" id="wpReason"
285 tabindex="7"
286 value="<?php $this->text('reason') ?>" size='20' />
287 </td>
288 <?php } ?>
289 </tr>
290 <?php if( $this->data['canremember'] ) { ?>
291 <tr>
292 <td></td>
293 <td class="mw-input">
294 <?php
295 global $wgCookieExpiration, $wgLang;
296 echo Xml::checkLabel(
297 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
298 'wpRemember',
299 'wpRemember',
300 $this->data['remember'],
301 array( 'tabindex' => '8' )
302 )
303 ?>
304 </td>
305 </tr>
306 <?php }
307
308 $tabIndex = 9;
309 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
310 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
311 <tr>
312 <?php
313 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
314 ?><td class="mw-label"><label for="<?php
315 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
316 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
317 } else {
318 ?><td><?php
319 }
320 ?></td>
321 <td class="mw-input">
322 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
323 echo htmlspecialchars( $inputItem['name'] ); ?>"
324 tabindex="<?php echo $tabIndex++; ?>"
325 value="<?php
326 if ( $inputItem['type'] != 'checkbox' ) {
327 echo htmlspecialchars( $inputItem['value'] );
328 } else {
329 echo '1';
330 }
331 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
332 <?php
333 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
334 echo 'checked="checked"';
335 ?> /> <?php
336 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
337 ?>
338 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
339 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
340 }
341 if( $inputItem['helptext'] !== false ) {
342 ?>
343 <div class="prefsectiontip">
344 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
345 </div>
346 <?php } ?>
347 </td>
348 </tr>
349 <?php
350
351 }
352 }
353 ?>
354 <tr>
355 <td></td>
356 <td class="mw-submit">
357 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
358 tabindex="<?php echo $tabIndex++; ?>"
359 value="<?php $this->msg('createaccount') ?>" />
360 <?php if( $this->data['createemail'] ) { ?>
361 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
362 tabindex="<?php echo $tabIndex++; ?>"
363 value="<?php $this->msg('createaccountmail') ?>" />
364 <?php } ?>
365 </td>
366 </tr>
367 </table>
368 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
369 <?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
370 </form>
371 </div>
372 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
373 <?php
374
375 }
376 }