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