Merge "Added a few more trx sanity checks to DatabaseBase"
[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 $doms = "";
117 foreach ( $this->data['domainnames'] as $dom ) {
118 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
119 }
120 ?>
121 <div id="mw-user-domain-section">
122 <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
123 <div class="mw-input">
124 <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>" tabindex="4">
125 <?php echo $doms ?>
126 </select>
127 </div>
128 </div>
129 <?php } ?>
130
131 <div class="mw-row-password">
132 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
133 <?php
134 echo Html::input( 'wpRetype', null, 'password', array(
135 'class' => 'mw-input loginPassword',
136 'id' => 'wpRetype',
137 'tabindex' => '5',
138 'size' => '20',
139 'required',
140 'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
141 ) + User::passwordChangeInputAttribs() );
142 ?>
143 </div>
144
145 <div>
146 <?php if ( $this->data['useemail'] ) { ?>
147 <label for='wpEmail'>
148 <?php
149 $this->msg( $this->data['emailrequired'] ?
150 'createacct-emailrequired' :
151 'createacct-emailoptional'
152 );
153 ?>
154 </label>
155 <?php
156 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
157 'class' => 'mw-input loginText',
158 'id' => 'wpEmail',
159 'tabindex' => '6',
160 'size' => '20',
161 'required' => $this->data['emailrequired'],
162 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
163 'createacct-another-email-ph' : 'createacct-email-ph' )->text()
164 ) );
165 ?>
166 <?php } ?>
167 </div>
168
169 <?php if ( $this->data['userealname'] ) { ?>
170 <div>
171 <label for='wpRealName'><?php $this->msg( 'createacct-realname' ); ?></label>
172 <input type='text' class='mw-input loginText' name="wpRealName" id="wpRealName"
173 tabindex="7"
174 value="<?php $this->text( 'realname' ); ?>" size='20' />
175 <div class="prefsectiontip">
176 <?php $this->msgWiki( $this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
177 </div>
178 </div>
179 <?php } ?>
180
181 <?php if ( $this->data['usereason'] ) { ?>
182 <div>
183 <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
184 <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
185 'class' => 'mw-input loginText',
186 'id' => 'wpReason',
187 'tabindex' => '8',
188 'size' => '20',
189 'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
190 ) ); ?>
191 </div>
192 <?php } ?>
193
194 <?php
195 $tabIndex = 9;
196 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
197 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
198 <div>
199 <?php
200 // If it's a checkbox, output the whole thing (assume it has a msg).
201 if ( $inputItem['type'] == 'checkbox' ) {
202 ?>
203 <label class="mw-ui-checkbox-label">
204 <input
205 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
206 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
207 type="checkbox" value="1"
208 tabindex="<?php echo $tabIndex++; ?>"
209 <?php if ( !empty( $inputItem['value'] ) ) {
210 echo 'checked="checked"';
211 } ?>
212 >
213 <?php $this->msg( $inputItem['msg'] ); ?>
214 </label>
215 <?php
216 } else {
217 // Not a checkbox.
218 // TODO (bug 31909) support other input types, e.g. select boxes.
219 ?>
220 <?php if ( !empty( $inputItem['msg'] ) ) { ?>
221 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
222 <?php $this->msgWiki( $inputItem['msg'] ); ?>
223 </label>
224 <?php } ?>
225 <input
226 type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>"
227 class="mw-input"
228 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
229 tabindex="<?php echo $tabIndex++; ?>"
230 value="<?php echo htmlspecialchars( $inputItem['value'] ); ?>"
231 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
232 />
233 <?php } ?>
234 <?php if ( $inputItem['helptext'] !== false ) { ?>
235 <div class="prefsectiontip">
236 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
237 </div>
238 <?php } ?>
239 </div>
240 <?php
241 }
242 }
243
244 // JS attempts to move the image CAPTCHA below this part of the form,
245 // so skip one index.
246 $tabIndex++;
247 ?>
248 <div class="mw-submit">
249 <?php
250 echo Html::input(
251 'wpCreateaccount',
252 $this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
253 'submit',
254 array(
255 'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-primary",
256 'id' => 'wpCreateaccount',
257 'tabindex' => $tabIndex++
258 )
259 );
260 ?>
261 </div>
262 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
263 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
264 </form>
265 </div>
266 <div class="mw-createacct-benefits-container">
267 <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
268 <div class="mw-createacct-benefits-list">
269 <?php
270 for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
271 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
272 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
273 ?>
274 <div class="mw-number-text <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>">
275 <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
276 <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
277 </div>
278 <?php } ?>
279 </div>
280 </div>
281 </div>
282 <?php
283
284 }
285 }