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