Merge "Fixes to RedisBagOStuff"
[lhc/web/wiklou.git] / includes / templates / Usercreate.php
1 <?php
2 /**
3 * Html form for account creation (since 1.22 with VForm appearance).
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 class UsercreateTemplate extends BaseTemplate {
25
26 /**
27 * Extensions (AntiSpoof and TitleBlacklist) call this in response to
28 * UserCreateForm hook to add checkboxes to the create account form.
29 */
30 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
31 $this->data['extraInput'][] = array(
32 'name' => $name,
33 'value' => $value,
34 'type' => $type,
35 'msg' => $msg,
36 'helptext' => $helptext,
37 );
38 }
39
40 function execute() {
41 global $wgCookieExpiration;
42 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
43 ?>
44 <div class="mw-ui-container">
45 <?php if ( $this->haveData( 'languages' ) ) { ?>
46 <div id="languagelinks">
47 <p><?php $this->html( 'languages' ); ?></p>
48 </div>
49 <?php } ?>
50 <div id="userloginForm">
51 <h2 class="createaccount-join">
52 <?php $this->msg( $this->data['loggedin'] ? 'createacct-another-join' : 'createacct-join' ); ?>
53 </h2>
54 <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
55 <section class="mw-form-header">
56 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
57 </section>
58 <?php if ( $this->data['message'] ) { ?>
59 <div class="<?php $this->text( 'messagetype' ); ?>box">
60 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
61 <strong><?php $this->msg( 'createacct-error' ); ?></strong>
62 <br />
63 <?php } ?>
64 <?php $this->html( 'message' ); ?>
65 </div>
66 <?php } ?>
67
68 <div>
69 <label for='wpName2'>
70 <?php $this->msg( 'userlogin-yourname' ); ?>
71
72 <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
73 </label>
74 <?php
75 echo Html::input( 'wpName', $this->data['name'], 'text', array(
76 'class' => 'mw-input loginText',
77 'id' => 'wpName2',
78 'tabindex' => '1',
79 'size' => '20',
80 'required',
81 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
82 'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
83 ) );
84 ?>
85 </div>
86
87 <div>
88 <?php if ( $this->data['createemail'] ) { ?>
89 <label class="mw-ui-checkbox-label">
90 <input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2"
91 <?php if ( $this->data['createemailset'] ) {
92 echo 'checked="checked"';
93 } ?>
94 >
95 <?php $this->msg( 'createaccountmail' ); ?>
96 </label>
97 <?php } ?>
98 </div>
99
100 <div class="mw-row-password">
101 <label for='wpPassword2'><?php $this->msg( 'userlogin-yourpassword' ); ?></label>
102 <?php
103 echo Html::input( 'wpPassword', null, 'password', array(
104 'class' => 'mw-input loginPassword',
105 'id' => 'wpPassword2',
106 'tabindex' => '3',
107 'size' => '20',
108 'required',
109 'placeholder' => $this->getMsg( 'createacct-yourpassword-ph' )->text()
110 ) + User::passwordChangeInputAttribs() );
111 ?>
112 </div>
113
114 <?php
115 if ( $this->data['usedomain'] ) {
116 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
117 $select->setAttribute( 'tabindex', 4 );
118 foreach ( $this->data['domainnames'] as $dom ) {
119 $select->addOption( $dom );
120 }
121 ?>
122 <div id="mw-user-domain-section">
123 <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
124 <div class="mw-input">
125 <?php echo $select->getHTML(); ?>
126 </div>
127 </div>
128 <?php } ?>
129
130 <div class="mw-row-password">
131 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
132 <?php
133 echo Html::input( 'wpRetype', null, 'password', array(
134 'class' => 'mw-input loginPassword',
135 'id' => 'wpRetype',
136 'tabindex' => '5',
137 'size' => '20',
138 'required',
139 'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
140 ) + User::passwordChangeInputAttribs() );
141 ?>
142 </div>
143
144 <div>
145 <?php if ( $this->data['useemail'] ) { ?>
146 <label for='wpEmail'>
147 <?php
148 $this->msg( $this->data['emailrequired'] ?
149 'createacct-emailrequired' :
150 'createacct-emailoptional'
151 );
152 ?>
153 </label>
154 <?php
155 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
156 'class' => 'mw-input loginText',
157 'id' => 'wpEmail',
158 'tabindex' => '6',
159 'size' => '20',
160 'required' => $this->data['emailrequired'],
161 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
162 'createacct-another-email-ph' : 'createacct-email-ph' )->text()
163 ) );
164 ?>
165 <?php } ?>
166 </div>
167
168 <?php if ( $this->data['userealname'] ) { ?>
169 <div>
170 <label for='wpRealName'><?php $this->msg( 'createacct-realname' ); ?></label>
171 <input type='text' class='mw-input loginText' name="wpRealName" id="wpRealName"
172 tabindex="7"
173 value="<?php $this->text( 'realname' ); ?>" size='20' />
174 <div class="prefsectiontip">
175 <?php $this->msgWiki( $this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
176 </div>
177 </div>
178 <?php } ?>
179
180 <?php if ( $this->data['usereason'] ) { ?>
181 <div>
182 <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
183 <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
184 'class' => 'mw-input loginText',
185 'id' => 'wpReason',
186 'tabindex' => '8',
187 'size' => '20',
188 'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
189 ) ); ?>
190 </div>
191 <?php } ?>
192
193 <?php
194 $tabIndex = 9;
195 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
196 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
197 <div>
198 <?php
199 // If it's a checkbox, output the whole thing (assume it has a msg).
200 if ( $inputItem['type'] == 'checkbox' ) {
201 ?>
202 <label class="mw-ui-checkbox-label">
203 <input
204 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
205 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
206 type="checkbox" value="1"
207 tabindex="<?php echo $tabIndex++; ?>"
208 <?php if ( !empty( $inputItem['value'] ) ) {
209 echo 'checked="checked"';
210 } ?>
211 >
212 <?php $this->msg( $inputItem['msg'] ); ?>
213 </label>
214 <?php
215 } else {
216 // Not a checkbox.
217 // TODO (bug 31909) support other input types, e.g. select boxes.
218 ?>
219 <?php if ( !empty( $inputItem['msg'] ) ) { ?>
220 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
221 <?php $this->msgWiki( $inputItem['msg'] ); ?>
222 </label>
223 <?php } ?>
224 <input
225 type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>"
226 class="mw-input"
227 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
228 tabindex="<?php echo $tabIndex++; ?>"
229 value="<?php echo htmlspecialchars( $inputItem['value'] ); ?>"
230 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
231 />
232 <?php } ?>
233 <?php if ( $inputItem['helptext'] !== false ) { ?>
234 <div class="prefsectiontip">
235 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
236 </div>
237 <?php } ?>
238 </div>
239 <?php
240 }
241 }
242
243 // JS attempts to move the image CAPTCHA below this part of the form,
244 // so skip one index.
245 $tabIndex++;
246 ?>
247 <div class="mw-submit">
248 <?php
249 echo Html::input(
250 'wpCreateaccount',
251 $this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
252 'submit',
253 array(
254 'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-primary",
255 'id' => 'wpCreateaccount',
256 'tabindex' => $tabIndex++
257 )
258 );
259 ?>
260 </div>
261 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
262 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
263 </form>
264 </div>
265 <div class="mw-createacct-benefits-container">
266 <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
267 <div class="mw-createacct-benefits-list">
268 <?php
269 for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
270 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
271 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
272 ?>
273 <div class="mw-number-text <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>">
274 <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
275 <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
276 </div>
277 <?php } ?>
278 </div>
279 </div>
280 </div>
281 <?php
282
283 }
284 }