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