Merge "Make FakeConverter more realistic"
[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 if ( !defined( 'MEDIAWIKI' ) ) {
25 die( -1 );
26 }
27
28 class UsercreateTemplate extends BaseTemplate {
29
30 /**
31 * Extensions (AntiSpoof and TitleBlacklist) call this in response to
32 * UserCreateForm hook to add checkboxes to the create account form.
33 */
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 global $wgCookieExpiration;
46 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
47 ?>
48 <div class="mw-ui-container">
49 <?php
50 if ( $this->haveData( 'languages' ) ) {
51 ?>
52 <div id="languagelinks">
53 <p><?php $this->html( 'languages' ); ?></p>
54 </div>
55 <?php
56 }
57 ?>
58 <div id="userloginForm">
59 <h2 class="createaccount-join">
60 <?php
61 $this->msg( $this->data['createAnother'] ?
62 'createacct-another-join' : 'createacct-join' );
63 ?>
64 </h2>
65 <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
66 <section class="mw-form-header">
67 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
68 </section>
69 <?php
70 if ( $this->data['message'] ) {
71 ?>
72 <div class="<?php $this->text( 'messagetype' ); ?>box">
73 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
74 <strong><?php $this->msg( 'createacct-error' ); ?></strong><br />
75 <?php } ?>
76 <?php $this->html( 'message' ); ?>
77 </div>
78 <?php } ?>
79 <div>
80 <label for='wpName2'>
81 <?php $this->msg( 'userlogin-yourname' ); ?>
82
83 <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
84 </label>
85 <?php
86 echo Html::input( 'wpName', $this->data['name'], 'text', array(
87 'class' => 'mw-input loginText',
88 'id' => 'wpName2',
89 'tabindex' => '1',
90 'size' => '20',
91 'required',
92 'placeholder' => $this->getMsg( $this->data['createAnother'] ?
93 'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
94 ) );
95 ?>
96 </div>
97 <div>
98 <?php if ( $this->data['createemail'] ) { ?>
99 <label class="mw-ui-checkbox-label">
100 <input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2"
101 <?php if ( $this->data['createemailset'] ) {
102 echo 'checked="checked"';
103 } ?>
104 >
105 <?php $this->msg( 'createaccountmail' ); ?>
106 </label>
107 <?php } ?>
108 </div>
109 <div class="mw-row-password">
110 <label for='wpPassword2'><?php $this->msg( 'userlogin-yourpassword' ); ?></label>
111 <?php echo Html::input( 'wpPassword', null, 'password', array(
112 'class' => 'mw-input loginPassword',
113 'id' => 'wpPassword2',
114 'tabindex' => '3',
115 'size' => '20',
116 'required',
117 'placeholder' => $this->getMsg( 'createacct-yourpassword-ph' )->text()
118 ) + User::passwordChangeInputAttribs() ); ?>
119 </div>
120 <?php if ( $this->data['usedomain'] ) {
121 $doms = "";
122 foreach ( $this->data['domainnames'] as $dom ) {
123 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
124 }
125 ?>
126 <div id="mw-user-domain-section">
127 <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
128 <div class="mw-input">
129 <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>"
130 tabindex="4">
131 <?php echo $doms ?>
132 </select>
133 </div>
134 </div>
135 <?php } ?>
136 <div class="mw-row-password">
137 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
138 <?php
139 echo Html::input( 'wpRetype', null, 'password', array(
140 'class' => 'mw-input loginPassword',
141 'id' => 'wpRetype',
142 'tabindex' => '5',
143 'size' => '20',
144 'required',
145 'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
146 ) + User::passwordChangeInputAttribs() );
147 ?>
148 </div>
149 <div>
150 <?php if ( $this->data['useemail'] ) { ?>
151 <label for='wpEmail'>
152 <?php
153 $this->msg( $this->data['emailrequired'] ?
154 'createacct-emailrequired' :
155 'createacct-emailoptional'
156 );
157 ?>
158 </label>
159 <?php
160 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
161 'class' => 'mw-input loginText',
162 'id' => 'wpEmail',
163 'tabindex' => '6',
164 'size' => '20',
165 'placeholder' => $this->getMsg( $this->data['createAnother'] ?
166 'createacct-another-email-ph' : 'createacct-email-ph' )->text()
167 ) + ( $this->data['emailrequired'] ? array() : array( 'required' => '' ) ) );
168 ?>
169 <?php } ?>
170 </div>
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['createAnother'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
179 </div>
180 </div>
181 <?php }
182 if ( $this->data['usereason'] ) { ?>
183 <div>
184 <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
185 <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
186 'class' => 'mw-input loginText',
187 'id' => 'wpReason',
188 'tabindex' => '8',
189 'size' => '20',
190 'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
191 ) ); ?>
192 </div>
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 if ( !empty( $inputItem['msg'] ) ) {
219 // Output the message label
220 ?>
221 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
222 <?php $this->msgWiki( $inputItem['msg'] ); ?>
223 </label>
224 <?php
225 }
226 ?>
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 }
237 if ( $inputItem['helptext'] !== false ) {
238 ?>
239 <div class="prefsectiontip">
240 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
241 </div>
242 <?php
243 }
244 ?>
245 </div>
246 <?php
247 }
248 }
249 // JS attempts to move the image CAPTCHA below this part of the form,
250 // so skip one index.
251 $tabIndex++;
252 ?>
253 <div class="mw-submit">
254 <?php
255 echo Html::input( 'wpCreateaccount',
256 $this->getMsg( $this->data['createAnother'] ?
257 'createacct-another-submit' : 'createacct-submit' ),
258 'submit',
259 array(
260 'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-primary",
261 'id' => 'wpCreateaccount',
262 'tabindex' => $tabIndex++
263 ) );
264 ?>
265 </div>
266 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
267 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
268 </form>
269 </div>
270 <div class="mw-createacct-benefits-container">
271 <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
272 <div class="mw-createacct-benefits-list">
273 <?php
274 for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
275 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
276 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
277 ?>
278 <div class="mw-number-text <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>">
279 <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
280 <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
281 </div>
282 <?php
283 }
284 ?>
285 </div>
286 </div>
287 </div>
288 <?php
289
290 }
291 }