Enforce $wgMinimalPasswordLength client-side
[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 <h2><?php $this->msg('loginerror') ?></h2>
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 echo Html::input( 'wpRemember', '1', 'checkbox', array(
86 'tabindex' => '4',
87 'id' => 'wpRemember'
88 ) + ( $this->data['remember'] ? array( 'checked' ) : array() ) ); ?>
89
90 <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
91 </td>
92 </tr>
93 <?php } ?>
94 <tr>
95 <td></td>
96 <td class="mw-submit">
97 <?php
98 echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
99 'id' => 'wpLoginAttempt',
100 'tabindex' => '5'
101 ) );
102 if ( $this->data['useemail'] && $this->data['canreset'] ) {
103 echo '&nbsp;';
104 echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
105 'id' => 'wpMailmypassword',
106 'tabindex' => '6'
107 ) );
108 } ?>
109
110 </td>
111 </tr>
112 </table>
113 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
114 </form>
115 </div>
116 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
117 <?php
118
119 }
120 }
121
122 /**
123 * @ingroup Templates
124 */
125 class UsercreateTemplate extends QuickTemplate {
126 function addInputItem( $name, $value, $type, $msg ) {
127 $this->data['extraInput'][] = array(
128 'name' => $name,
129 'value' => $value,
130 'type' => $type,
131 'msg' => $msg,
132 );
133 }
134
135 function execute() {
136 if( $this->data['message'] ) {
137 ?>
138 <div class="<?php $this->text('messagetype') ?>box">
139 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
140 <h2><?php $this->msg('loginerror') ?></h2>
141 <?php } ?>
142 <?php $this->html('message') ?>
143 </div>
144 <div class="visualClear"></div>
145 <?php } ?>
146 <div id="userlogin">
147
148 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
149 <h2><?php $this->msg('createaccount') ?></h2>
150 <p id="userloginlink"><?php $this->html('link') ?></p>
151 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
152 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
153 <table>
154 <tr>
155 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
156 <td class="mw-input">
157 <?php
158 echo Html::input( 'wpName', null, 'text', array(
159 'class' => 'loginText',
160 'id' => 'wpName2',
161 'tabindex' => '1',
162 'size' => '20',
163 'required',
164 'autofocus'
165 ) ); ?>
166 </td>
167 </tr>
168 <tr>
169 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
170 <td class="mw-input">
171 <?php
172 echo Html::input( 'wpPassword', null, 'password', array(
173 'class' => 'loginPassword',
174 'id' => 'wpPassword2',
175 'tabindex' => '2',
176 'size' => '20'
177 ) + User::passwordChangeInputAttribs() ); ?>
178 </td>
179 </tr>
180 <?php if( $this->data['usedomain'] ) {
181 $doms = "";
182 foreach( $this->data['domainnames'] as $dom ) {
183 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
184 }
185 ?>
186 <tr>
187 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
188 <td class="mw-input">
189 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
190 tabindex="3">
191 <?php echo $doms ?>
192 </select>
193 </td>
194 </tr>
195 <?php } ?>
196 <tr>
197 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
198 <td class="mw-input">
199 <?php
200 echo Html::input( 'wpRetype', null, 'password', array(
201 'class' => 'loginPassword',
202 'id' => 'wpRetype',
203 'tabindex' => '4',
204 'size' => '20'
205 ) + User::passwordChangeInputAttribs() ); ?>
206 </td>
207 </tr>
208 <tr>
209 <?php if( $this->data['useemail'] ) { ?>
210 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
211 <td class="mw-input">
212 <?php
213 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
214 'class' => 'loginText',
215 'id' => 'wpEmail',
216 'tabindex' => '5',
217 'size' => '20'
218 ) ); ?>
219 <div class="prefsectiontip">
220 <?php if( $this->data['emailrequired'] ) {
221 $this->msgWiki('prefs-help-email-required');
222 } else {
223 $this->msgWiki('prefs-help-email');
224 } ?>
225 </div>
226 </td>
227 <?php } ?>
228 <?php if( $this->data['userealname'] ) { ?>
229 </tr>
230 <tr>
231 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
232 <td class="mw-input">
233 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
234 tabindex="6"
235 value="<?php $this->text('realname') ?>" size='20' />
236 <div class="prefsectiontip">
237 <?php $this->msgWiki('prefs-help-realname'); ?>
238 </div>
239 </td>
240 <?php } ?>
241 </tr>
242 <?php if( $this->data['canremember'] ) { ?>
243 <tr>
244 <td></td>
245 <td class="mw-input">
246 <input type='checkbox' name="wpRemember"
247 tabindex="7"
248 value="1" id="wpRemember"
249 <?php if( $this->data['remember'] ) { ?>checked="checked"<?php } ?>
250 /> <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
251 </td>
252 </tr>
253 <?php }
254
255 $tabIndex = 8;
256 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
257 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
258 <tr>
259 <?php
260 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
261 ?><td class="mw-label"><label for="<?php
262 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
263 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
264 } else {
265 ?><td><?php
266 }
267 ?></td>
268 <td class="mw-input">
269 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
270 echo htmlspecialchars( $inputItem['name'] ); ?>"
271 tabindex="<?php echo $tabIndex++; ?>"
272 value="<?php
273 if ( $inputItem['type'] != 'checkbox' ) {
274 echo htmlspecialchars( $inputItem['value'] );
275 } else {
276 echo '1';
277 }
278 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
279 <?php
280 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
281 echo 'checked="checked"';
282 ?> /> <?php
283 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
284 ?>
285 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
286 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
287 }
288 ?>
289 </td>
290 </tr>
291 <?php
292
293 }
294 }
295 ?>
296 <tr>
297 <td></td>
298 <td class="mw-submit">
299 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
300 tabindex="<?php echo $tabIndex++; ?>"
301 value="<?php $this->msg('createaccount') ?>" />
302 <?php if( $this->data['createemail'] ) { ?>
303 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
304 tabindex="<?php echo $tabIndex++; ?>"
305 value="<?php $this->msg('createaccountmail') ?>" />
306 <?php } ?>
307 </td>
308 </tr>
309 </table>
310 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
311 </form>
312 </div>
313 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
314 <?php
315
316 }
317 }