b22c144f4ea691787c3b84c00b0f4f4a00e7a6c0
[lhc/web/wiklou.git] / includes / templates / Usercreate.php
1 <?php
2 /**
3 * Html form for account creation.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Templates
22 */
23
24 /**
25 * @defgroup Templates Templates
26 */
27
28 if( !defined( 'MEDIAWIKI' ) ) die( -1 );
29
30 /**
31 * @ingroup Templates
32 */
33 class UsercreateTemplate extends QuickTemplate {
34 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
35 $this->data['extraInput'][] = array(
36 'name' => $name,
37 'value' => $value,
38 'type' => $type,
39 'msg' => $msg,
40 'helptext' => $helptext,
41 );
42 }
43
44 function execute() {
45 if( $this->data['message'] ) {
46 ?>
47 <div class="<?php $this->text('messagetype') ?>box">
48 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
49 <strong><?php $this->msg( 'loginerror' )?></strong><br />
50 <?php } ?>
51 <?php $this->html('message') ?>
52 </div>
53 <div class="visualClear"></div>
54 <?php } ?>
55
56 <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
57 <div id="userlogin">
58
59 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
60 <h2><?php $this->msg('createaccount') ?></h2>
61 <p id="userloginlink"><?php $this->html('link') ?></p>
62 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
63 <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
64 <table>
65 <tr>
66 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
67 <td class="mw-input">
68 <?php
69 echo Html::input( 'wpName', $this->data['name'], 'text', array(
70 'class' => 'loginText',
71 'id' => 'wpName2',
72 'tabindex' => '1',
73 'size' => '20',
74 'required',
75 'autofocus'
76 ) ); ?>
77 </td>
78 </tr>
79 <tr>
80 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
81 <td class="mw-input">
82 <?php
83 echo Html::input( 'wpPassword', null, 'password', array(
84 'class' => 'loginPassword',
85 'id' => 'wpPassword2',
86 'tabindex' => '2',
87 'size' => '20'
88 ) + User::passwordChangeInputAttribs() ); ?>
89 </td>
90 </tr>
91 <?php if( $this->data['usedomain'] ) {
92 $doms = "";
93 foreach( $this->data['domainnames'] as $dom ) {
94 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
95 }
96 ?>
97 <tr>
98 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
99 <td class="mw-input">
100 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
101 tabindex="3">
102 <?php echo $doms ?>
103 </select>
104 </td>
105 </tr>
106 <?php } ?>
107 <tr>
108 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
109 <td class="mw-input">
110 <?php
111 echo Html::input( 'wpRetype', null, 'password', array(
112 'class' => 'loginPassword',
113 'id' => 'wpRetype',
114 'tabindex' => '4',
115 'size' => '20'
116 ) + User::passwordChangeInputAttribs() ); ?>
117 </td>
118 </tr>
119 <tr>
120 <?php if( $this->data['useemail'] ) { ?>
121 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
122 <td class="mw-input">
123 <?php
124 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
125 'class' => 'loginText',
126 'id' => 'wpEmail',
127 'tabindex' => '5',
128 'size' => '20'
129 ) ); ?>
130 <div class="prefsectiontip">
131 <?php // duplicated in Preferences.php profilePreferences()
132 if( $this->data['emailrequired'] ) {
133 $this->msgWiki('prefs-help-email-required');
134 } else {
135 $this->msgWiki('prefs-help-email');
136 }
137 if( $this->data['emailothers'] ) {
138 $this->msgWiki('prefs-help-email-others');
139 } ?>
140 </div>
141 </td>
142 <?php } ?>
143 <?php if( $this->data['userealname'] ) { ?>
144 </tr>
145 <tr>
146 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
147 <td class="mw-input">
148 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
149 tabindex="6"
150 value="<?php $this->text('realname') ?>" size='20' />
151 <div class="prefsectiontip">
152 <?php $this->msgWiki('prefs-help-realname'); ?>
153 </div>
154 </td>
155 <?php } ?>
156 <?php if( $this->data['usereason'] ) { ?>
157 </tr>
158 <tr>
159 <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
160 <td class="mw-input">
161 <input type='text' class='loginText' name="wpReason" id="wpReason"
162 tabindex="7"
163 value="<?php $this->text('reason') ?>" size='20' />
164 </td>
165 <?php } ?>
166 </tr>
167 <?php if( $this->data['canremember'] ) { ?>
168 <tr>
169 <td></td>
170 <td class="mw-input">
171 <?php
172 global $wgCookieExpiration, $wgLang;
173 echo Xml::checkLabel(
174 wfMsgExt( 'remembermypassword', 'parsemag', $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) ),
175 'wpRemember',
176 'wpRemember',
177 $this->data['remember'],
178 array( 'tabindex' => '8' )
179 )
180 ?>
181 </td>
182 </tr>
183 <?php }
184
185 $tabIndex = 9;
186 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
187 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
188 <tr>
189 <?php
190 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
191 ?><td class="mw-label"><label for="<?php
192 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
193 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
194 } else {
195 ?><td><?php
196 }
197 ?></td>
198 <td class="mw-input">
199 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
200 echo htmlspecialchars( $inputItem['name'] ); ?>"
201 tabindex="<?php echo $tabIndex++; ?>"
202 value="<?php
203 if ( $inputItem['type'] != 'checkbox' ) {
204 echo htmlspecialchars( $inputItem['value'] );
205 } else {
206 echo '1';
207 }
208 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
209 <?php
210 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
211 echo 'checked="checked"';
212 ?> /> <?php
213 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
214 ?>
215 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
216 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
217 }
218 if( $inputItem['helptext'] !== false ) {
219 ?>
220 <div class="prefsectiontip">
221 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
222 </div>
223 <?php } ?>
224 </td>
225 </tr>
226 <?php
227
228 }
229 }
230 ?>
231 <tr>
232 <td></td>
233 <td class="mw-submit">
234 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
235 tabindex="<?php echo $tabIndex++; ?>"
236 value="<?php $this->msg('createaccount') ?>" />
237 <?php if( $this->data['createemail'] ) { ?>
238 <input type='submit' name="wpCreateaccountMail" id="wpCreateaccountMail"
239 tabindex="<?php echo $tabIndex++; ?>"
240 value="<?php $this->msg('createaccountmail') ?>" />
241 <?php } ?>
242 </td>
243 </tr>
244 </table>
245 <?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
246 <?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
247 </form>
248 </div>
249 <div id="signupend"><?php $this->html( 'signupend' ); ?></div>
250 <?php
251
252 }
253 }