Removes 'languageshtml' property in mediawiki API's 'parse' action
[lhc/web/wiklou.git] / includes / templates / Usercreate.php
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * Html form for account creation (since 1.22 with VForm appearance).
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 * @ingroup Templates
23 */
24
25 class UsercreateTemplate extends BaseTemplate {
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 <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 <!-- This element is used by the mediawiki.special.userlogin.signup.js module. -->
59 <div
60 id="mw-createacct-status-area"
61 <?php if ( $this->data['message'] ) { ?>
62 class="<?php echo $this->data['messagetype']; ?>box"
63 <?php } else { ?>
64 style="display: none;"
65 <?php } ?>
66 >
67 <?php if ( $this->data['message'] ) { ?>
68 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
69 <strong><?php $this->msg( 'createacct-error' ); ?></strong>
70 <br />
71 <?php } ?>
72 <?php $this->html( 'message' ); ?>
73 <?php } ?>
74 </div>
75
76 <div>
77 <label for='wpName2'>
78 <?php $this->msg( 'userlogin-yourname' ); ?>
79
80 <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
81 </label>
82 <?php
83 echo Html::input( 'wpName', $this->data['name'], 'text', array(
84 'class' => 'mw-input loginText',
85 'id' => 'wpName2',
86 'tabindex' => '1',
87 'size' => '20',
88 'required',
89 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
90 'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
91 ) );
92 ?>
93 </div>
94
95 <div>
96 <?php if ( $this->data['createemail'] ) { ?>
97 <label class="mw-ui-checkbox-label">
98 <input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2"
99 <?php if ( $this->data['createemailset'] ) {
100 echo 'checked="checked"';
101 } ?>
102 >
103 <?php $this->msg( 'createaccountmail' ); ?>
104 </label>
105 <?php } ?>
106 </div>
107
108 <div class="mw-row-password">
109 <label for='wpPassword2'><?php $this->msg( 'userlogin-yourpassword' ); ?></label>
110 <?php
111 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 ?>
120 </div>
121
122 <?php
123 if ( $this->data['usedomain'] ) {
124 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
125 $select->setAttribute( 'tabindex', 4 );
126 foreach ( $this->data['domainnames'] as $dom ) {
127 $select->addOption( $dom );
128 }
129 ?>
130 <div id="mw-user-domain-section">
131 <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
132 <div class="mw-input">
133 <?php echo $select->getHTML(); ?>
134 </div>
135 </div>
136 <?php } ?>
137
138 <div class="mw-row-password">
139 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
140 <?php
141 echo Html::input( 'wpRetype', null, 'password', array(
142 'class' => 'mw-input loginPassword',
143 'id' => 'wpRetype',
144 'tabindex' => '5',
145 'size' => '20',
146 'required',
147 'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
148 ) + User::passwordChangeInputAttribs() );
149 ?>
150 </div>
151
152 <div>
153 <?php if ( $this->data['useemail'] ) { ?>
154 <label for='wpEmail'>
155 <?php
156 $this->msg( $this->data['emailrequired'] ?
157 'createacct-emailrequired' :
158 'createacct-emailoptional'
159 );
160 ?>
161 </label>
162 <?php
163 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
164 'class' => 'mw-input loginText',
165 'id' => 'wpEmail',
166 'tabindex' => '6',
167 'size' => '20',
168 'required' => $this->data['emailrequired'],
169 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
170 'createacct-another-email-ph' : 'createacct-email-ph' )->text()
171 ) );
172 ?>
173 <?php } ?>
174 </div>
175
176 <?php if ( $this->data['userealname'] ) { ?>
177 <div>
178 <label for='wpRealName'><?php $this->msg( 'createacct-realname' ); ?></label>
179 <input type='text' class='mw-input loginText' name="wpRealName" id="wpRealName"
180 tabindex="7"
181 value="<?php $this->text( 'realname' ); ?>" size='20' />
182 <div class="prefsectiontip">
183 <?php $this->msgWiki( $this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
184 </div>
185 </div>
186 <?php } ?>
187
188 <?php if ( $this->data['usereason'] ) { ?>
189 <div>
190 <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
191 <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
192 'class' => 'mw-input loginText',
193 'id' => 'wpReason',
194 'tabindex' => '8',
195 'size' => '20',
196 'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
197 ) ); ?>
198 </div>
199 <?php } ?>
200
201 <?php
202 $tabIndex = 9;
203 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
204 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
205 <div>
206 <?php
207 // If it's a checkbox, output the whole thing (assume it has a msg).
208 if ( $inputItem['type'] == 'checkbox' ) {
209 ?>
210 <label class="mw-ui-checkbox-label">
211 <input
212 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
213 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
214 type="checkbox" value="1"
215 tabindex="<?php echo $tabIndex++; ?>"
216 <?php if ( !empty( $inputItem['value'] ) ) {
217 echo 'checked="checked"';
218 } ?>
219 >
220 <?php $this->msgHtml( $inputItem['msg'] ); ?>
221 </label>
222 <?php
223 } else {
224 // Not a checkbox.
225 // TODO (bug 31909) support other input types, e.g. select boxes.
226 ?>
227 <?php if ( !empty( $inputItem['msg'] ) ) { ?>
228 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
229 <?php $this->msgWiki( $inputItem['msg'] ); ?>
230 </label>
231 <?php } ?>
232 <input
233 type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>"
234 class="mw-input"
235 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
236 tabindex="<?php echo $tabIndex++; ?>"
237 value="<?php echo htmlspecialchars( $inputItem['value'] ); ?>"
238 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
239 />
240 <?php } ?>
241 <?php if ( $inputItem['helptext'] !== false ) { ?>
242 <div class="prefsectiontip">
243 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
244 </div>
245 <?php } ?>
246 </div>
247 <?php
248 }
249 }
250
251 // JS attempts to move the image CAPTCHA below this part of the form,
252 // so skip one index.
253 $tabIndex++;
254 ?>
255 <div class="mw-submit">
256 <?php
257 echo Html::input(
258 'wpCreateaccount',
259 $this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
260 'submit',
261 array(
262 'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive",
263 'id' => 'wpCreateaccount',
264 'tabindex' => $tabIndex++
265 )
266 );
267 ?>
268 </div>
269 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
270 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
271 </form>
272 <?php if ( !wfMessage( 'signupend' )->isDisabled() ) { ?>
273 <div id="signupend"><?php $this->html( 'signupend' ); ?></div>
274 <?php } ?>
275 </div>
276 <div class="mw-createacct-benefits-container">
277 <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
278 <div class="mw-createacct-benefits-list">
279 <?php
280 for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
281 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
282 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
283 ?>
284 <div class="mw-number-text <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>">
285 <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
286 <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
287 </div>
288 <?php } ?>
289 </div>
290 </div>
291 </div>
292 <?php
293
294 }
295 }