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( $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' ) ?>"
86 if( $this->data
['canremember'] ) { ?
>
91 global $wgCookieExpiration, $wgLang;
93 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
96 $this->data
['remember'],
97 array( 'tabindex' => '4' )
105 <td
class="mw-submit">
107 echo Html
::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
108 'id' => 'wpLoginAttempt',
111 if ( $this->data
['useemail'] && $this->data
['canreset'] ) {
113 echo Html
::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
114 'id' => 'wpMailmypassword',
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
} ?
>
126 <div id
="loginend"><?php
$this->msgWiki( 'loginend' ); ?
></div
>
135 class UsercreateTemplate
extends QuickTemplate
{
136 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
137 $this->data
['extraInput'][] = array(
142 'helptext' => $helptext,
147 if( $this->data
['message'] ) {
149 <div
class="<?php $this->text('messagetype') ?>box">
150 <?php
if ( $this->data
['messagetype'] == 'error' ) { ?
>
151 <strong
><?php
$this->msg( 'loginerror' )?
></strong
><br
/>
153 <?php
$this->html('message') ?
>
155 <div
class="visualClear"></div
>
158 <div id
="signupstart"><?php
$this->msgWiki( 'signupstart' ); ?
></div
>
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
} ?
>
168 <td
class="mw-label"><label
for='wpName2'><?php
$this->msg('yourname') ?
></label
></td
>
169 <td
class="mw-input">
171 echo Html
::input( 'wpName', $this->data
['name'], 'text', array(
172 'class' => 'loginText',
183 <td
class="mw-label"><label
for='wpPassword2'><?php
$this->msg('yourpassword') ?
></label
></td
>
184 <td
class="mw-input">
186 echo Html
::input( 'wpPassword', null, 'password', array(
187 'class' => 'loginPassword',
188 'id' => 'wpPassword2',
191 ) + User
::passwordChangeInputAttribs() ); ?
>
193 <td
><div id
="password-strength"></div
></td
>
195 <?php
if( $this->data
['usedomain'] ) {
197 foreach( $this->data
['domainnames'] as $dom ) {
198 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
202 <td
class="mw-label"><?php
$this->msg( 'yourdomainname' ) ?
></td
>
203 <td
class="mw-input">
204 <select name
="wpDomain" value
="<?php $this->text( 'domain' ) ?>"
213 <td
class="mw-label"><label
for='wpRetype'><?php
$this->msg('yourpasswordagain') ?
></label
></td
>
214 <td
class="mw-input">
216 echo Html
::input( 'wpRetype', null, 'password', array(
217 'class' => 'loginPassword',
221 ) + User
::passwordChangeInputAttribs() ); ?
>
223 <td
><div id
="password-retype"></div
></td
>
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">
230 echo Html
::input( 'wpEmail', $this->data
['email'], 'email', array(
231 'class' => 'loginText',
236 <div
class="prefsectiontip">
237 <?php
if( $this->data
['emailrequired'] ) {
238 $this->msgWiki('prefs-help-email-required');
240 $this->msgWiki('prefs-help-email');
246 <?php
if( $this->data
['userealname'] ) { ?
>
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"
253 value
="<?php $this->text('realname') ?>" size
='20' />
254 <div
class="prefsectiontip">
255 <?php
$this->msgWiki('prefs-help-realname'); ?
>
260 <?php
if( $this->data
['usereason'] ) { ?
>
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"
267 value
="<?php $this->text('reason') ?>" size
='20' />
271 <?php
if( $this->data
['canremember'] ) { ?
>
274 <td
class="mw-input" colspan
="2">
276 global $wgCookieExpiration, $wgLang;
277 echo Xml
::checkLabel(
278 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
281 $this->data
['remember'],
282 array( 'tabindex' => '8' )
290 if ( isset( $this->data
['extraInput'] ) && is_array( $this->data
['extraInput'] ) ) {
291 foreach ( $this->data
['extraInput'] as $inputItem ) { ?
>
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
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++; ?>"
307 if ( $inputItem['type'] != 'checkbox' ) {
308 echo htmlspecialchars( $inputItem['value'] );
312 ?>" id
="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
314 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
315 echo 'checked="checked"';
317 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
319 <label
for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
320 $this->msgHtml( $inputItem['msg'] ) ?
></label
><?php
322 if( $inputItem['helptext'] !== false ) {
324 <div
class="prefsectiontip">
325 <?php
$this->msgWiki( $inputItem['helptext'] ); ?
>
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') ?>" />
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
} ?
>
353 <div id
="signupend"><?php
$this->msgWiki( 'signupend' ); ?
></div
>