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'] ) {
134 echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
135 'id' => 'wpMailmypassword',
143 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
144 <?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
147 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
156 class UsercreateTemplate extends QuickTemplate {
157 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
158 $this->data['extraInput'][] = array(
163 'helptext' => $helptext,
168 if( $this->data['message'] ) {
170 <div class="<?php $this->text('messagetype') ?>box">
171 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
172 <strong><?php $this->msg( 'loginerror' )?></strong><br />
174 <?php $this->html('message') ?>
176 <div class="visualClear"></div>
179 <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
182 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
183 <h2><?php $this->msg('createaccount') ?></h2>
184 <p id="userloginlink"><?php $this->html('link') ?></p>
185 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
186 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
189 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
190 <td class="mw-input">
192 echo Html::input( 'wpName', $this->data['name'], 'text', array(
193 'class' => 'loginText',
203 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
204 <td class="mw-input">
206 echo Html::input( 'wpPassword', null, 'password', array(
207 'class' => 'loginPassword',
208 'id' => 'wpPassword2',
211 ) + User::passwordChangeInputAttribs() ); ?>
214 <?php if( $this->data['usedomain'] ) {
216 foreach( $this->data['domainnames'] as $dom ) {
217 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
221 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
222 <td class="mw-input">
223 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
231 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
232 <td class="mw-input">
234 echo Html::input( 'wpRetype', null, 'password', array(
235 'class' => 'loginPassword',
239 ) + User::passwordChangeInputAttribs() ); ?>
243 <?php if( $this->data['useemail'] ) { ?>
244 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
245 <td class="mw-input">
247 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
248 'class' => 'loginText',
253 <div class="prefsectiontip">
254 <?php if( $this->data['emailrequired'] ) {
255 $this->msgWiki('prefs-help-email-required');
257 $this->msgWiki('prefs-help-email');
262 <?php if( $this->data['userealname'] ) { ?>
265 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
266 <td class="mw-input">
267 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
269 value="<?php $this->text('realname') ?>" size='20' />
270 <div class="prefsectiontip">
271 <?php $this->msgWiki('prefs-help-realname'); ?>
275 <?php if( $this->data['usereason'] ) { ?>
278 <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
279 <td class="mw-input">
280 <input type='text' class='loginText' name="wpReason" id="wpReason"
282 value="<?php $this->text('reason') ?>" size='20' />
286 <?php if( $this->data['canremember'] ) { ?>
289 <td class="mw-input">
291 global $wgCookieExpiration, $wgLang;
292 echo Xml::checkLabel(
293 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
296 $this->data['remember'],
297 array( 'tabindex' => '8' )
305 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
306 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
309 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
310 ?><td class="mw-label"><label for="<?php
311 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
312 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
317 <td class="mw-input">
318 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
319 echo htmlspecialchars( $inputItem['name'] ); ?>"
320 tabindex="<?php echo $tabIndex++; ?>"
322 if ( $inputItem['type'] != 'checkbox' ) {
323 echo htmlspecialchars( $inputItem['value'] );
327 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
329 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
330 echo 'checked="checked"';
332 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
334 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
335 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
337 if( $inputItem['helptext'] !== false ) {
339 <div class="prefsectiontip">
340 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
352 <td class="mw-submit">
353 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
354 tabindex="<?php echo $tabIndex++; ?>"
355 value="<?php $this->msg('createaccount') ?>" />
356 <?php if( $this->data['createemail'] ) { ?>
357 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
358 tabindex="<?php echo $tabIndex++; ?>"
359 value="<?php $this->msg('createaccountmail') ?>" />
364 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
365 <?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
368 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>