a36fa2c533ab1ac09218a3bda0854f94032d0390
[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 <strong><?php $this->msg( 'loginerror' )?></strong><br />
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 # Can't do + array( 'autofocus' ) because + for arrays in PHP
46 # only works right for associative arrays! Thanks, PHP.
47 ) + ( $this->data['name'] ? array() : array( 'autofocus' => '' ) ) ); ?>
48
49 </td>
50 </tr>
51 <tr>
52 <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
53 <td class="mw-input">
54 <?php
55 echo Html::input( 'wpPassword', null, 'password', array(
56 'class' => 'loginPassword',
57 'id' => 'wpPassword1',
58 'tabindex' => '2',
59 'size' => '20'
60 ) + ( $this->data['name'] ? array( 'autofocus' ) : array() ) ); ?>
61
62 </td>
63 </tr>
64 <?php if( $this->data['usedomain'] ) {
65 $doms = "";
66 foreach( $this->data['domainnames'] as $dom ) {
67 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
68 }
69 ?>
70 <tr id="mw-user-domain-section">
71 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
72 <td class="mw-input">
73 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
74 tabindex="3">
75 <?php echo $doms ?>
76 </select>
77 </td>
78 </tr>
79 <?php }
80 if( $this->data['canremember'] ) { ?>
81 <tr>
82 <td></td>
83 <td class="mw-input">
84 <?php
85 global $wgCookieExpiration, $wgLang;
86 echo Xml::checkLabel(
87 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
88 'wpRemember',
89 'wpRemember',
90 $this->data['remember'],
91 array( 'tabindex' => '4' )
92 )
93 ?>
94 </td>
95 </tr>
96 <?php } ?>
97 <tr>
98 <td></td>
99 <td class="mw-submit">
100 <?php
101 echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
102 'id' => 'wpLoginAttempt',
103 'tabindex' => '5'
104 ) );
105 if ( $this->data['useemail'] && $this->data['canreset'] ) {
106 echo '&#160;';
107 echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
108 'id' => 'wpMailmypassword',
109 'tabindex' => '6'
110 ) );
111 } ?>
112
113 </td>
114 </tr>
115 </table>
116 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
117 <?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
118 </form>
119 </div>
120 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
121 <?php
122
123 }
124 }
125
126 /**
127 * @ingroup Templates
128 */
129 class UsercreateTemplate extends QuickTemplate {
130 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
131 $this->data['extraInput'][] = array(
132 'name' => $name,
133 'value' => $value,
134 'type' => $type,
135 'msg' => $msg,
136 'helptext' => $helptext,
137 );
138 }
139
140 function execute() {
141 if( $this->data['message'] ) {
142 ?>
143 <div class="<?php $this->text('messagetype') ?>box">
144 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
145 <strong><?php $this->msg( 'loginerror' )?></strong><br />
146 <?php } ?>
147 <?php $this->html('message') ?>
148 </div>
149 <div class="visualClear"></div>
150 <?php } ?>
151 <div id="userlogin">
152
153 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
154 <h2><?php $this->msg('createaccount') ?></h2>
155 <p id="userloginlink"><?php $this->html('link') ?></p>
156 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
157 <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
158 <table>
159 <tr>
160 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
161 <td class="mw-input">
162 <?php
163 echo Html::input( 'wpName', $this->data['name'], 'text', array(
164 'class' => 'loginText',
165 'id' => 'wpName2',
166 'tabindex' => '1',
167 'size' => '20',
168 'required',
169 'autofocus'
170 ) ); ?>
171 </td>
172 </tr>
173 <tr>
174 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
175 <td class="mw-input">
176 <?php
177 echo Html::input( 'wpPassword', null, 'password', array(
178 'class' => 'loginPassword',
179 'id' => 'wpPassword2',
180 'tabindex' => '2',
181 'size' => '20'
182 ) + User::passwordChangeInputAttribs() ); ?>
183 </td>
184 </tr>
185 <?php if( $this->data['usedomain'] ) {
186 $doms = "";
187 foreach( $this->data['domainnames'] as $dom ) {
188 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
189 }
190 ?>
191 <tr>
192 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
193 <td class="mw-input">
194 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
195 tabindex="3">
196 <?php echo $doms ?>
197 </select>
198 </td>
199 </tr>
200 <?php } ?>
201 <tr>
202 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
203 <td class="mw-input">
204 <?php
205 echo Html::input( 'wpRetype', null, 'password', array(
206 'class' => 'loginPassword',
207 'id' => 'wpRetype',
208 'tabindex' => '4',
209 'size' => '20'
210 ) + User::passwordChangeInputAttribs() ); ?>
211 </td>
212 </tr>
213 <tr>
214 <?php if( $this->data['useemail'] ) { ?>
215 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
216 <td class="mw-input">
217 <?php
218 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
219 'class' => 'loginText',
220 'id' => 'wpEmail',
221 'tabindex' => '5',
222 'size' => '20'
223 ) ); ?>
224 <div class="prefsectiontip">
225 <?php if( $this->data['emailrequired'] ) {
226 $this->msgWiki('prefs-help-email-required');
227 } else {
228 $this->msgWiki('prefs-help-email');
229 } ?>
230 </div>
231 </td>
232 <?php } ?>
233 <?php if( $this->data['userealname'] ) { ?>
234 </tr>
235 <tr>
236 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
237 <td class="mw-input">
238 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
239 tabindex="6"
240 value="<?php $this->text('realname') ?>" size='20' />
241 <div class="prefsectiontip">
242 <?php $this->msgWiki('prefs-help-realname'); ?>
243 </div>
244 </td>
245 <?php } ?>
246 <?php if( $this->data['usereason'] ) { ?>
247 </tr>
248 <tr>
249 <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
250 <td class="mw-input">
251 <input type='text' class='loginText' name="wpReason" id="wpReason"
252 tabindex="7"
253 value="<?php $this->text('reason') ?>" size='20' />
254 </td>
255 <?php } ?>
256 </tr>
257 <?php if( $this->data['canremember'] ) { ?>
258 <tr>
259 <td></td>
260 <td class="mw-input">
261 <?php
262 global $wgCookieExpiration, $wgLang;
263 echo Xml::checkLabel(
264 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
265 'wpRemember',
266 'wpRemember',
267 $this->data['remember'],
268 array( 'tabindex' => '8' )
269 )
270 ?>
271 </td>
272 </tr>
273 <?php }
274
275 $tabIndex = 9;
276 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
277 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
278 <tr>
279 <?php
280 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
281 ?><td class="mw-label"><label for="<?php
282 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
283 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
284 } else {
285 ?><td><?php
286 }
287 ?></td>
288 <td class="mw-input">
289 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
290 echo htmlspecialchars( $inputItem['name'] ); ?>"
291 tabindex="<?php echo $tabIndex++; ?>"
292 value="<?php
293 if ( $inputItem['type'] != 'checkbox' ) {
294 echo htmlspecialchars( $inputItem['value'] );
295 } else {
296 echo '1';
297 }
298 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
299 <?php
300 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
301 echo 'checked="checked"';
302 ?> /> <?php
303 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
304 ?>
305 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
306 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
307 }
308 if( $inputItem['helptext'] !== false ) {
309 ?>
310 <div class="prefsectiontip">
311 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
312 </div>
313 <?php } ?>
314 </td>
315 </tr>
316 <?php
317
318 }
319 }
320 ?>
321 <tr>
322 <td></td>
323 <td class="mw-submit">
324 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
325 tabindex="<?php echo $tabIndex++; ?>"
326 value="<?php $this->msg('createaccount') ?>" />
327 <?php if( $this->data['createemail'] ) { ?>
328 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
329 tabindex="<?php echo $tabIndex++; ?>"
330 value="<?php $this->msg('createaccountmail') ?>" />
331 <?php } ?>
332 </td>
333 </tr>
334 </table>
335 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
336 <?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
337 </form>
338 </div>
339 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
340 <?php
341
342 }
343 }