Merge "generateId -> mw.user.generateRandomSessionId"
[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 /**
29 * HTML template for Special:Userlogin form
30 * @ingroup Templates
31 */
32 class UserloginTemplate extends QuickTemplate {
33 function execute() {
34 if( $this->data['message'] ) {
35 ?>
36 <div class="<?php $this->text('messagetype') ?>box">
37 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
38 <strong><?php $this->msg( 'loginerror' )?></strong><br />
39 <?php } ?>
40 <?php $this->html('message') ?>
41 </div>
42 <div class="visualClear"></div>
43 <?php } ?>
44
45 <div id="loginstart"><?php $this->msgWiki( 'loginstart' ); ?></div>
46 <div id="userloginForm">
47 <form name="userlogin" method="post" action="<?php $this->text('action') ?>">
48 <h2><?php $this->msg('login') ?></h2>
49 <p id="userloginlink"><?php $this->html('link') ?></p>
50 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
51 <div id="userloginprompt"><?php $this->msgWiki('loginprompt') ?></div>
52 <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
53 <table>
54 <tr>
55 <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
56 <td class="mw-input">
57 <?php
58 echo Html::input( 'wpName', $this->data['name'], 'text', array(
59 'class' => 'loginText',
60 'id' => 'wpName1',
61 'tabindex' => '1',
62 'size' => '20',
63 'required'
64 # Can't do + array( 'autofocus' ) because + for arrays in PHP
65 # only works right for associative arrays! Thanks, PHP.
66 ) + ( $this->data['name'] ? array() : array( 'autofocus' => '' ) ) ); ?>
67
68 </td>
69 </tr>
70 <tr>
71 <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
72 <td class="mw-input">
73 <?php
74 echo Html::input( 'wpPassword', null, 'password', array(
75 'class' => 'loginPassword',
76 'id' => 'wpPassword1',
77 'tabindex' => '2',
78 'size' => '20'
79 ) + ( $this->data['name'] ? array( 'autofocus' ) : array() ) ); ?>
80
81 </td>
82 </tr>
83 <?php if( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
84 $doms = "";
85 foreach( $this->data['domainnames'] as $dom ) {
86 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
87 }
88 ?>
89 <tr id="mw-user-domain-section">
90 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
91 <td class="mw-input">
92 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
93 tabindex="3">
94 <?php echo $doms ?>
95 </select>
96 </td>
97 </tr>
98 <?php }
99
100 if( $this->haveData( 'extrafields' ) ) {
101 echo $this->data['extrafields'];
102 }
103
104 if( $this->data['canremember'] ) { ?>
105 <tr>
106 <td></td>
107 <td class="mw-input">
108 <?php
109 global $wgCookieExpiration;
110 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
111 echo Xml::checkLabel(
112 wfMessage( 'remembermypassword' )->numParams( $expirationDays )->text(),
113 'wpRemember',
114 'wpRemember',
115 $this->data['remember'],
116 array( 'tabindex' => '8' )
117 )
118 ?>
119 </td>
120 </tr>
121 <?php } ?>
122 <?php if( $this->data['cansecurelogin'] ) { ?>
123 <tr>
124 <td></td>
125 <td class="mw-input">
126 <?php
127 echo Xml::checkLabel(
128 wfMessage( 'securelogin-stick-https' )->text(),
129 'wpStickHTTPS',
130 'wpStickHTTPS',
131 $this->data['stickHTTPS'],
132 array( 'tabindex' => '9' )
133 );
134 ?>
135 </td>
136 </tr>
137 <?php } ?>
138 <tr>
139 <td></td>
140 <td class="mw-submit">
141 <?php
142 echo Html::input( 'wpLoginAttempt', wfMessage( 'login' )->text(), 'submit', array(
143 'id' => 'wpLoginAttempt',
144 'tabindex' => '9'
145 ) );
146 if ( $this->data['useemail'] && $this->data['canreset'] ) {
147 if( $this->data['resetlink'] === true ) {
148 echo '&#160;';
149 echo Linker::link(
150 SpecialPage::getTitleFor( 'PasswordReset' ),
151 wfMessage( 'userlogin-resetlink' )
152 );
153 } elseif( $this->data['resetlink'] === null ) {
154 echo '&#160;';
155 echo Html::input(
156 'wpMailmypassword',
157 wfMessage( 'mailmypassword' )->text(),
158 'submit', array(
159 'id' => 'wpMailmypassword',
160 'tabindex' => '10'
161 )
162 );
163 }
164 } ?>
165
166 </td>
167 </tr>
168 </table>
169 <?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
170 <?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
171 </form>
172 </div>
173 <div id="loginend"><?php $this->html( 'loginend' ); ?></div>
174 <?php
175
176 }
177 }