partial revert of r55447: breaks url wpName prefilling
[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 # 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 </form>
115 </div>
116 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
117 <?php
118
119 }
120 }
121
122 /**
123 * @ingroup Templates
124 */
125 class UsercreateTemplate extends QuickTemplate {
126 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
127 $this->data['extraInput'][] = array(
128 'name' => $name,
129 'value' => $value,
130 'type' => $type,
131 'msg' => $msg,
132 'helptext' => $helptext,
133 );
134 }
135
136 function execute() {
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 'autofocus'
166 ) ); ?>
167 </td>
168 </tr>
169 <tr>
170 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
171 <td class="mw-input">
172 <?php
173 echo Html::input( 'wpPassword', null, 'password', array(
174 'class' => 'loginPassword',
175 'id' => 'wpPassword2',
176 'tabindex' => '2',
177 'size' => '20'
178 ) + User::passwordChangeInputAttribs() ); ?>
179 </td>
180 </tr>
181 <?php if( $this->data['usedomain'] ) {
182 $doms = "";
183 foreach( $this->data['domainnames'] as $dom ) {
184 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
185 }
186 ?>
187 <tr>
188 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
189 <td class="mw-input">
190 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
191 tabindex="3">
192 <?php echo $doms ?>
193 </select>
194 </td>
195 </tr>
196 <?php } ?>
197 <tr>
198 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
199 <td class="mw-input">
200 <?php
201 echo Html::input( 'wpRetype', null, 'password', array(
202 'class' => 'loginPassword',
203 'id' => 'wpRetype',
204 'tabindex' => '4',
205 'size' => '20'
206 ) + User::passwordChangeInputAttribs() ); ?>
207 </td>
208 </tr>
209 <tr>
210 <?php if( $this->data['useemail'] ) { ?>
211 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
212 <td class="mw-input">
213 <?php
214 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
215 'class' => 'loginText',
216 'id' => 'wpEmail',
217 'tabindex' => '5',
218 'size' => '20'
219 ) ); ?>
220 <div class="prefsectiontip">
221 <?php if( $this->data['emailrequired'] ) {
222 $this->msgWiki('prefs-help-email-required');
223 } else {
224 $this->msgWiki('prefs-help-email');
225 } ?>
226 </div>
227 </td>
228 <?php } ?>
229 <?php if( $this->data['userealname'] ) { ?>
230 </tr>
231 <tr>
232 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
233 <td class="mw-input">
234 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
235 tabindex="6"
236 value="<?php $this->text('realname') ?>" size='20' />
237 <div class="prefsectiontip">
238 <?php $this->msgWiki('prefs-help-realname'); ?>
239 </div>
240 </td>
241 <?php } ?>
242 </tr>
243 <?php if( $this->data['canremember'] ) { ?>
244 <tr>
245 <td></td>
246 <td class="mw-input">
247 <input type='checkbox' name="wpRemember"
248 tabindex="7"
249 value="1" id="wpRemember"
250 <?php if( $this->data['remember'] ) { ?>checked="checked"<?php } ?>
251 /> <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
252 </td>
253 </tr>
254 <?php }
255
256 $tabIndex = 8;
257 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
258 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
259 <tr>
260 <?php
261 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
262 ?><td class="mw-label"><label for="<?php
263 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
264 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
265 } else {
266 ?><td><?php
267 }
268 ?></td>
269 <td class="mw-input">
270 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
271 echo htmlspecialchars( $inputItem['name'] ); ?>"
272 tabindex="<?php echo $tabIndex++; ?>"
273 value="<?php
274 if ( $inputItem['type'] != 'checkbox' ) {
275 echo htmlspecialchars( $inputItem['value'] );
276 } else {
277 echo '1';
278 }
279 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
280 <?php
281 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
282 echo 'checked="checked"';
283 ?> /> <?php
284 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
285 ?>
286 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
287 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
288 }
289 if( $inputItem['helptext'] !== false ) {
290 ?>
291 <div class="prefsectiontip">
292 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
293 </div>
294 <?php } ?>
295 </td>
296 </tr>
297 <?php
298
299 }
300 }
301 ?>
302 <tr>
303 <td></td>
304 <td class="mw-submit">
305 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
306 tabindex="<?php echo $tabIndex++; ?>"
307 value="<?php $this->msg('createaccount') ?>" />
308 <?php if( $this->data['createemail'] ) { ?>
309 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
310 tabindex="<?php echo $tabIndex++; ?>"
311 value="<?php $this->msg('createaccountmail') ?>" />
312 <?php } ?>
313 </td>
314 </tr>
315 </table>
316 <?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
317 </form>
318 </div>
319 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
320 <?php
321
322 }
323 }