Use Html::input() for login form
[lhc/web/wiklou.git] / includes / templates / Userlogin.php
1 <?php
2 /**
3 * @defgroup Templates Templates
4 * @file
5 * @ingroup Templates
6 */
7 if( !defined( 'MEDIAWIKI' ) ) die( -1 );
8
9 /**
10 * HTML template for Special:Userlogin form
11 * @ingroup Templates
12 */
13 class UserloginTemplate extends QuickTemplate {
14 function execute() {
15 if( $this->data['message'] ) {
16 ?>
17 <div class="<?php $this->text('messagetype') ?>box">
18 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
19 <h2><?php $this->msg('loginerror') ?></h2>
20 <?php } ?>
21 <?php $this->html('message') ?>
22 </div>
23 <div class="visualClear"></div>
24 <?php } ?>
25
26 <div id="loginstart"><?php $this->msgWiki( 'loginstart' ); ?></div>
27 <div id="userloginForm">
28 <form name="userlogin" method="post" action="<?php $this->text('action') ?>">
29 <h2><?php $this->msg('login') ?></h2>
30 <p id="userloginlink"><?php $this->html('link') ?></p>
31 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
32 <div id="userloginprompt"><?php $this->msgWiki('loginprompt') ?></div>
33 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
34 <table>
35 <tr>
36 <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
37 <td class="mw-input">
38 <?php
39 echo Html::input( 'wpName', $this->data['name'], 'text', array(
40 'class' => 'loginText',
41 'id' => 'wpName1',
42 'tabindex' => '1',
43 'size' => '20',
44 'required',
45 'autofocus'
46 ) ); ?>
47
48 </td>
49 </tr>
50 <tr>
51 <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
52 <td class="mw-input">
53 <?php
54 echo Html::input( 'wpPassword', null, 'password', array(
55 'class' => 'loginPassword',
56 'id' => 'wpPassword1',
57 'tabindex' => '2',
58 'size' => '20'
59 ) ); ?>
60
61 </td>
62 </tr>
63 <?php if( $this->data['usedomain'] ) {
64 $doms = "";
65 foreach( $this->data['domainnames'] as $dom ) {
66 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
67 }
68 ?>
69 <tr id="mw-user-domain-section">
70 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
71 <td class="mw-input">
72 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
73 tabindex="3">
74 <?php echo $doms ?>
75 </select>
76 </td>
77 </tr>
78 <?php }
79 if( $this->data['canremember'] ) { ?>
80 <tr>
81 <td></td>
82 <td class="mw-input">
83 <?php
84 echo Html::input( 'wpRemember', '1', 'checkbox', array(
85 'tabindex' => '4',
86 'id' => 'wpRemember'
87 ) + ( $this->data['remember'] ? array( 'checked' ) : array() ) ); ?>
88
89 <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
90 </td>
91 </tr>
92 <?php } ?>
93 <tr>
94 <td></td>
95 <td class="mw-submit">
96 <?php
97 echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
98 'id' => 'wpLoginAttempt',
99 'tabindex' => '5'
100 ) );
101 if ( $this->data['useemail'] && $this->data['canreset'] ) {
102 echo '&nbsp;';
103 echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
104 'id' => 'wpMailmypassword',
105 'tabindex' => '6'
106 ) );
107 } ?>
108
109 </td>
110 </tr>
111 </table>
112 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
113 </form>
114 </div>
115 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
116 <?php
117
118 }
119 }
120
121 /**
122 * @ingroup Templates
123 */
124 class UsercreateTemplate extends QuickTemplate {
125 function addInputItem( $name, $value, $type, $msg ) {
126 $this->data['extraInput'][] = array(
127 'name' => $name,
128 'value' => $value,
129 'type' => $type,
130 'msg' => $msg,
131 );
132 }
133
134 function execute() {
135 global $wgMinimalPasswordLength;
136
137 if( $this->data['message'] ) {
138 ?>
139 <div class="<?php $this->text('messagetype') ?>box">
140 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
141 <h2><?php $this->msg('loginerror') ?></h2>
142 <?php } ?>
143 <?php $this->html('message') ?>
144 </div>
145 <div class="visualClear"></div>
146 <?php } ?>
147 <div id="userlogin">
148
149 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
150 <h2><?php $this->msg('createaccount') ?></h2>
151 <p id="userloginlink"><?php $this->html('link') ?></p>
152 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
153 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
154 <table>
155 <tr>
156 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
157 <td class="mw-input">
158 <?php
159 echo Html::input( 'wpName', $this->data['name'], 'text', array(
160 'class' => 'loginText',
161 'id' => 'wpName2',
162 'tabindex' => '1',
163 'size' => '20',
164 'required'
165 ) ); ?>
166 </td>
167 </tr>
168 <tr>
169 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
170 <td class="mw-input">
171 <?php
172 echo Html::input( 'wpPassword', null, 'password', array(
173 'class' => 'loginPassword',
174 'id' => 'wpPassword2',
175 'tabindex' => '2',
176 'size' => '20'
177 ) + ( $wgMinimalPasswordLength > 0 ? array( 'required' ) : array() ) ); ?>
178 </td>
179 </tr>
180 <?php if( $this->data['usedomain'] ) {
181 $doms = "";
182 foreach( $this->data['domainnames'] as $dom ) {
183 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
184 }
185 ?>
186 <tr>
187 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
188 <td class="mw-input">
189 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
190 tabindex="3">
191 <?php echo $doms ?>
192 </select>
193 </td>
194 </tr>
195 <?php } ?>
196 <tr>
197 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
198 <td class="mw-input">
199 <?php
200 echo Html::input( 'wpRetype', null, 'password', array(
201 'class' => 'loginPassword',
202 'id' => 'wpRetype',
203 'tabindex' => '4',
204 'size' => '20'
205 ) + ( $wgMinimalPasswordLength > 0 ? array( 'required' ) : array() ) ); ?>
206 </td>
207 </tr>
208 <tr>
209 <?php if( $this->data['useemail'] ) { ?>
210 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
211 <td class="mw-input">
212 <?php
213 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
214 'class' => 'loginText',
215 'id' => 'wpEmail',
216 'tabindex' => '5',
217 'size' => '20'
218 ) ); ?>
219 <div class="prefsectiontip">
220 <?php if( $this->data['emailrequired'] ) {
221 $this->msgWiki('prefs-help-email-required');
222 } else {
223 $this->msgWiki('prefs-help-email');
224 } ?>
225 </div>
226 </td>
227 <?php } ?>
228 <?php if( $this->data['userealname'] ) { ?>
229 </tr>
230 <tr>
231 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
232 <td class="mw-input">
233 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
234 tabindex="6"
235 value="<?php $this->text('realname') ?>" size='20' />
236 <div class="prefsectiontip">
237 <?php $this->msgWiki('prefs-help-realname'); ?>
238 </div>
239 </td>
240 <?php } ?>
241 </tr>
242 <?php if( $this->data['canremember'] ) { ?>
243 <tr>
244 <td></td>
245 <td class="mw-input">
246 <input type='checkbox' name="wpRemember"
247 tabindex="7"
248 value="1" id="wpRemember"
249 <?php if( $this->data['remember'] ) { ?>checked="checked"<?php } ?>
250 /> <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
251 </td>
252 </tr>
253 <?php }
254
255 $tabIndex = 8;
256 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
257 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
258 <tr>
259 <?php
260 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
261 ?><td class="mw-label"><label for="<?php
262 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
263 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
264 } else {
265 ?><td><?php
266 }
267 ?></td>
268 <td class="mw-input">
269 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
270 echo htmlspecialchars( $inputItem['name'] ); ?>"
271 tabindex="<?php echo $tabIndex++; ?>"
272 value="<?php
273 if ( $inputItem['type'] != 'checkbox' ) {
274 echo htmlspecialchars( $inputItem['value'] );
275 } else {
276 echo '1';
277 }
278 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
279 <?php
280 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
281 echo 'checked="checked"';
282 ?> /> <?php
283 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
284 ?>
285 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
286 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
287 }
288 ?>
289 </td>
290 </tr>
291 <?php
292
293 }
294 }
295 ?>
296 <tr>
297 <td></td>
298 <td class="mw-submit">
299 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
300 tabindex="<?php echo $tabIndex++; ?>"
301 value="<?php $this->msg('createaccount') ?>" />
302 <?php if( $this->data['createemail'] ) { ?>
303 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
304 tabindex="<?php echo $tabIndex++; ?>"
305 value="<?php $this->msg('createaccountmail') ?>" />
306 <?php } ?>
307 </td>
308 </tr>
309 </table>
310 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
311 </form>
312 </div>
313 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
314 <?php
315
316 }
317 }