Merge "Optimized SqlBagOStuff::getBatch() a bit."
[lhc/web/wiklou.git] / includes / templates / Userlogin.php
1 <?php
2 /**
3 * Html form for user login.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Templates
22 */
23
24 /**
25 * @defgroup Templates Templates
26 */
27
28 if( !defined( 'MEDIAWIKI' ) ) die( -1 );
29
30 /**
31 * HTML template for Special:Userlogin form
32 * @ingroup Templates
33 */
34 class UserloginTemplate extends QuickTemplate {
35 function execute() {
36 if( $this->data['message'] ) {
37 ?>
38 <div class="<?php $this->text('messagetype') ?>box">
39 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
40 <strong><?php $this->msg( 'loginerror' )?></strong><br />
41 <?php } ?>
42 <?php $this->html('message') ?>
43 </div>
44 <div class="visualClear"></div>
45 <?php } ?>
46
47 <div id="loginstart"><?php $this->msgWiki( 'loginstart' ); ?></div>
48 <div id="userloginForm">
49 <form name="userlogin" method="post" action="<?php $this->text('action') ?>">
50 <h2><?php $this->msg('login') ?></h2>
51 <p id="userloginlink"><?php $this->html('link') ?></p>
52 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
53 <div id="userloginprompt"><?php $this->msgWiki('loginprompt') ?></div>
54 <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
55 <table>
56 <tr>
57 <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
58 <td class="mw-input">
59 <?php
60 echo Html::input( 'wpName', $this->data['name'], 'text', array(
61 'class' => 'loginText',
62 'id' => 'wpName1',
63 'tabindex' => '1',
64 'size' => '20',
65 'required'
66 # Can't do + array( 'autofocus' ) because + for arrays in PHP
67 # only works right for associative arrays! Thanks, PHP.
68 ) + ( $this->data['name'] ? array() : array( 'autofocus' => '' ) ) ); ?>
69
70 </td>
71 </tr>
72 <tr>
73 <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
74 <td class="mw-input">
75 <?php
76 echo Html::input( 'wpPassword', null, 'password', array(
77 'class' => 'loginPassword',
78 'id' => 'wpPassword1',
79 'tabindex' => '2',
80 'size' => '20'
81 ) + ( $this->data['name'] ? array( 'autofocus' ) : array() ) ); ?>
82
83 </td>
84 </tr>
85 <?php if( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
86 $doms = "";
87 foreach( $this->data['domainnames'] as $dom ) {
88 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
89 }
90 ?>
91 <tr id="mw-user-domain-section">
92 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
93 <td class="mw-input">
94 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
95 tabindex="3">
96 <?php echo $doms ?>
97 </select>
98 </td>
99 </tr>
100 <?php }
101
102 if( $this->haveData( 'extrafields' ) ) {
103 echo $this->data['extrafields'];
104 }
105
106 if( $this->data['canremember'] ) { ?>
107 <tr>
108 <td></td>
109 <td class="mw-input">
110 <?php
111 global $wgCookieExpiration, $wgLang;
112 echo Xml::checkLabel(
113 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
114 'wpRemember',
115 'wpRemember',
116 $this->data['remember'],
117 array( 'tabindex' => '8' )
118 )
119 ?>
120 </td>
121 </tr>
122 <?php } ?>
123 <?php if( $this->data['cansecurelogin'] ) { ?>
124 <tr>
125 <td></td>
126 <td class="mw-input">
127 <?php
128 echo Xml::checkLabel(
129 wfMsg( 'securelogin-stick-https' ),
130 'wpStickHTTPS',
131 'wpStickHTTPS',
132 $this->data['stickHTTPS'],
133 array( 'tabindex' => '9' )
134 );
135 ?>
136 </td>
137 </tr>
138 <?php } ?>
139 <tr>
140 <td></td>
141 <td class="mw-submit">
142 <?php
143 echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
144 'id' => 'wpLoginAttempt',
145 'tabindex' => '9'
146 ) );
147 if ( $this->data['useemail'] && $this->data['canreset'] ) {
148 if( $this->data['resetlink'] === true ){
149 echo '&#160;';
150 echo Linker::link(
151 SpecialPage::getTitleFor( 'PasswordReset' ),
152 wfMessage( 'userlogin-resetlink' )
153 );
154 } elseif( $this->data['resetlink'] === null ) {
155 echo '&#160;';
156 echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
157 'id' => 'wpMailmypassword',
158 'tabindex' => '10'
159 ) );
160 }
161 } ?>
162
163 </td>
164 </tr>
165 </table>
166 <?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
167 <?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
168 </form>
169 </div>
170 <div id="loginend"><?php $this->html( 'loginend' ); ?></div>
171 <?php
172
173 }
174 }