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