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