3 * Html forms for user login and account creation
10 * @defgroup Templates Templates
13 if( !defined( 'MEDIAWIKI' ) ) die( -1 );
16 * HTML template for Special:Userlogin form
19 class UserloginTemplate
extends QuickTemplate
{
21 if( $this->data
['message'] ) {
23 <div
class="<?php $this->text('messagetype') ?>box">
24 <?php
if ( $this->data
['messagetype'] == 'error' ) { ?
>
25 <strong
><?php
$this->msg( 'loginerror' )?
></strong
><br
/>
27 <?php
$this->html('message') ?
>
29 <div
class="visualClear"></div
>
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
} ?
>
42 <td
class="mw-label"><label
for='wpName1'><?php
$this->msg('yourname') ?
></label
></td
>
45 echo Html
::input( 'wpName', $this->data
['name'], 'text', array(
46 'class' => 'loginText',
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' => '' ) ) ); ?
>
58 <td
class="mw-label"><label
for='wpPassword1'><?php
$this->msg('yourpassword') ?
></label
></td
>
61 echo Html
::input( 'wpPassword', null, 'password', array(
62 'class' => 'loginPassword',
63 'id' => 'wpPassword1',
66 ) +
( $this->data
['name'] ?
array( 'autofocus' ) : array() ) ); ?
>
70 <?php
if( isset( $this->data
['usedomain'] ) && $this->data
['usedomain'] ) {
72 foreach( $this->data
['domainnames'] as $dom ) {
73 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
76 <tr id
="mw-user-domain-section">
77 <td
class="mw-label"><?php
$this->msg( 'yourdomainname' ) ?
></td
>
79 <select name
="wpDomain" value
="<?php $this->text( 'domain' ) ?>"
87 if( $this->haveData( 'extrafields' ) ) {
88 echo $this->data
['extrafields'];
91 if( $this->data
['canremember'] ) { ?
>
96 global $wgCookieExpiration, $wgLang;
98 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
101 $this->data
['remember'],
102 array( 'tabindex' => '8' )
108 <?php
if( $this->data
['cansecurelogin'] ) { ?
>
111 <td
class="mw-input">
113 echo Xml
::checkLabel(
114 wfMsg( 'securelogin-stick-https' ),
117 $this->data
['stickHTTPS'],
118 array( 'tabindex' => '9' )
126 <td
class="mw-submit">
128 echo Html
::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
129 'id' => 'wpLoginAttempt',
132 if ( $this->data
['useemail'] && $this->data
['canreset'] ) {
133 if( $this->data
['resetlink'] === true ){
136 SpecialPage
::getTitleFor( 'PasswordReset' ),
137 wfMessage( 'userlogin-resetlink' )
139 } elseif( $this->data
['resetlink'] === null ) {
141 echo Html
::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
142 'id' => 'wpMailmypassword',
151 <?php
if( @$this->haveData( 'uselang' ) ) { ?
><input type
="hidden" name
="uselang" value
="<?php $this->text( 'uselang' ); ?>" /><?php
} ?
>
152 <?php
if( @$this->haveData( 'token' ) ) { ?
><input type
="hidden" name
="wpLoginToken" value
="<?php $this->text( 'token' ); ?>" /><?php
} ?
>
155 <div id
="loginend"><?php
$this->msgWiki( 'loginend' ); ?
></div
>
164 class UsercreateTemplate
extends QuickTemplate
{
165 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
166 $this->data
['extraInput'][] = array(
171 'helptext' => $helptext,
176 if( $this->data
['message'] ) {
178 <div
class="<?php $this->text('messagetype') ?>box">
179 <?php
if ( $this->data
['messagetype'] == 'error' ) { ?
>
180 <strong
><?php
$this->msg( 'loginerror' )?
></strong
><br
/>
182 <?php
$this->html('message') ?
>
184 <div
class="visualClear"></div
>
187 <div id
="signupstart"><?php
$this->msgWiki( 'signupstart' ); ?
></div
>
190 <form name
="userlogin2" id
="userlogin2" method
="post" action
="<?php $this->text('action') ?>">
191 <h2
><?php
$this->msg('createaccount') ?
></h2
>
192 <p id
="userloginlink"><?php
$this->html('link') ?
></p
>
193 <?php
$this->html('header'); /* pre-table point for form plugins... */ ?
>
194 <?php
if( @$this->haveData( 'languages' ) ) { ?
><div id
="languagelinks"><p
><?php
$this->html( 'languages' ); ?
></p
></div
><?php
} ?
>
197 <td
class="mw-label"><label
for='wpName2'><?php
$this->msg('yourname') ?
></label
></td
>
198 <td
class="mw-input">
200 echo Html
::input( 'wpName', $this->data
['name'], 'text', array(
201 'class' => 'loginText',
211 <td
class="mw-label"><label
for='wpPassword2'><?php
$this->msg('yourpassword') ?
></label
></td
>
212 <td
class="mw-input">
214 echo Html
::input( 'wpPassword', null, 'password', array(
215 'class' => 'loginPassword',
216 'id' => 'wpPassword2',
219 ) + User
::passwordChangeInputAttribs() ); ?
>
222 <?php
if( $this->data
['usedomain'] ) {
224 foreach( $this->data
['domainnames'] as $dom ) {
225 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
229 <td
class="mw-label"><?php
$this->msg( 'yourdomainname' ) ?
></td
>
230 <td
class="mw-input">
231 <select name
="wpDomain" value
="<?php $this->text( 'domain' ) ?>"
239 <td
class="mw-label"><label
for='wpRetype'><?php
$this->msg('yourpasswordagain') ?
></label
></td
>
240 <td
class="mw-input">
242 echo Html
::input( 'wpRetype', null, 'password', array(
243 'class' => 'loginPassword',
247 ) + User
::passwordChangeInputAttribs() ); ?
>
251 <?php
if( $this->data
['useemail'] ) { ?
>
252 <td
class="mw-label"><label
for='wpEmail'><?php
$this->msg('youremail') ?
></label
></td
>
253 <td
class="mw-input">
255 echo Html
::input( 'wpEmail', $this->data
['email'], 'email', array(
256 'class' => 'loginText',
261 <div
class="prefsectiontip">
262 <?php
// duplicated in Preferences.php profilePreferences()
263 if( $this->data
['emailrequired'] ) {
264 $this->msgWiki('prefs-help-email-required');
266 $this->msgWiki('prefs-help-email');
268 if( $this->data
['emailothers'] ) {
269 $this->msgWiki('prefs-help-email-others');
274 <?php
if( $this->data
['userealname'] ) { ?
>
277 <td
class="mw-label"><label
for='wpRealName'><?php
$this->msg('yourrealname') ?
></label
></td
>
278 <td
class="mw-input">
279 <input type
='text' class='loginText' name
="wpRealName" id
="wpRealName"
281 value
="<?php $this->text('realname') ?>" size
='20' />
282 <div
class="prefsectiontip">
283 <?php
$this->msgWiki('prefs-help-realname'); ?
>
287 <?php
if( $this->data
['usereason'] ) { ?
>
290 <td
class="mw-label"><label
for='wpReason'><?php
$this->msg('createaccountreason') ?
></label
></td
>
291 <td
class="mw-input">
292 <input type
='text' class='loginText' name
="wpReason" id
="wpReason"
294 value
="<?php $this->text('reason') ?>" size
='20' />
298 <?php
if( $this->data
['canremember'] ) { ?
>
301 <td
class="mw-input">
303 global $wgCookieExpiration, $wgLang;
304 echo Xml
::checkLabel(
305 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
308 $this->data
['remember'],
309 array( 'tabindex' => '8' )
317 if ( isset( $this->data
['extraInput'] ) && is_array( $this->data
['extraInput'] ) ) {
318 foreach ( $this->data
['extraInput'] as $inputItem ) { ?
>
321 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
322 ?
><td
class="mw-label"><label
for="<?php
323 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
324 $this->msgWiki( $inputItem['msg'] ) ?
></label
><?php
329 <td
class="mw-input">
330 <input type
="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name
="<?php
331 echo htmlspecialchars( $inputItem['name'] ); ?>"
332 tabindex
="<?php echo $tabIndex++; ?>"
334 if ( $inputItem['type'] != 'checkbox' ) {
335 echo htmlspecialchars( $inputItem['value'] );
339 ?>" id
="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
341 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
342 echo 'checked="checked"';
344 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
346 <label
for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
347 $this->msgHtml( $inputItem['msg'] ) ?
></label
><?php
349 if( $inputItem['helptext'] !== false ) {
351 <div
class="prefsectiontip">
352 <?php
$this->msgWiki( $inputItem['helptext'] ); ?
>
364 <td
class="mw-submit">
365 <input type
='submit' name
="wpCreateaccount" id
="wpCreateaccount"
366 tabindex
="<?php echo $tabIndex++; ?>"
367 value
="<?php $this->msg('createaccount') ?>" />
368 <?php
if( $this->data
['createemail'] ) { ?
>
369 <input type
='submit' name
="wpCreateaccountMail" id
="wpCreateaccountMail"
370 tabindex
="<?php echo $tabIndex++; ?>"
371 value
="<?php $this->msg('createaccountmail') ?>" />
376 <?php
if( @$this->haveData( 'uselang' ) ) { ?
><input type
="hidden" name
="uselang" value
="<?php $this->text( 'uselang' ); ?>" /><?php
} ?
>
377 <?php
if( @$this->haveData( 'token' ) ) { ?
><input type
="hidden" name
="wpCreateaccountToken" value
="<?php $this->text( 'token' ); ?>" /><?php
} ?
>
380 <div id
="signupend"><?php
$this->msgWiki( 'signupend' ); ?
></div
>