Merge "Fix positioning of jQuery.tipsy tooltip arrows"
[mediawiki.git] / includes / templates / Usercreate.php
bloba39690a72c9e1c6407855efd50b0374b98ba671a
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * Html form for account creation (since 1.22 with VForm appearance).
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.
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.
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
21 * @file
22 * @ingroup Templates
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.
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,
40 function execute() {
42 <div class="mw-ui-container">
43 <?php if ( $this->haveData( 'languages' ) ) { ?>
44 <div id="languagelinks">
45 <p><?php $this->html( 'languages' ); ?></p>
46 </div>
47 <?php }
48 if ( !wfMessage( 'signupstart' )->isDisabled() ) { ?>
49 <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
50 <?php } ?>
51 <div id="userloginForm">
52 <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
53 <section class="mw-form-header">
54 <?php $this->html( 'header' ); ?>
55 </section>
56 <!-- This element is used by the mediawiki.special.userlogin.signup.js module. -->
57 <div
58 id="mw-createacct-status-area"
59 <?php if ( $this->data['message'] ) { ?>
60 class="<?php echo $this->data['messagetype']; ?>box"
61 <?php } else { ?>
62 style="display: none;"
63 <?php } ?>
65 <?php if ( $this->data['message'] ) { ?>
66 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
67 <strong><?php $this->msg( 'createacct-error' ); ?></strong>
68 <br />
69 <?php } ?>
70 <?php $this->html( 'message' ); ?>
71 <?php } ?>
72 </div>
74 <?php if ( $this->data['formheader'] ) { ?>
75 <div class="mw-form-formheader">
76 <?php $this->html( 'formheader' ); /* extensions such as MobileFrontend add html here */ ?>
77 </div>
78 <?php } ?>
80 <div class="mw-ui-vform-field">
81 <label for='wpName2'>
82 <?php $this->msg( 'userlogin-yourname' ); ?>
84 <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
85 </label>
86 <?php
87 echo Html::input( 'wpName', $this->data['name'], 'text', array(
88 'class' => 'mw-ui-input loginText',
89 'id' => 'wpName2',
90 'tabindex' => '1',
91 'size' => '20',
92 'required',
93 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
94 'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
95 ) );
97 </div>
99 <div class="mw-ui-vform-field">
100 <?php if ( $this->data['createemail'] ) { ?>
101 <div class="mw-ui-checkbox">
102 <input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2"
103 <?php if ( $this->data['createemailset'] ) {
104 echo 'checked="checked"';
105 } ?>
106 ><label for="wpCreateaccountMail">
107 <?php $this->msg( 'createaccountmail' ); ?>
108 </label>
109 </div>
110 <?php } ?>
111 </div>
113 <div class="mw-ui-vform-field mw-row-password">
114 <label for='wpPassword2'><?php $this->msg( 'userlogin-yourpassword' ); ?></label>
115 <?php
116 echo Html::input( 'wpPassword', null, 'password', array(
117 'class' => 'mw-ui-input loginPassword',
118 'id' => 'wpPassword2',
119 'tabindex' => '3',
120 'size' => '20',
121 'required',
122 'placeholder' => $this->getMsg( 'createacct-yourpassword-ph' )->text()
123 ) + User::passwordChangeInputAttribs() );
125 </div>
127 <?php
128 if ( $this->data['usedomain'] ) {
129 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
130 $select->setAttribute( 'tabindex', 4 );
131 foreach ( $this->data['domainnames'] as $dom ) {
132 $select->addOption( $dom );
135 <div class="mw-ui-vform-field" id="mw-user-domain-section">
136 <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
137 <div>
138 <?php echo $select->getHTML(); ?>
139 </div>
140 </div>
141 <?php } ?>
143 <div class="mw-ui-vform-field mw-row-password">
144 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
145 <?php
146 echo Html::input( 'wpRetype', null, 'password', array(
147 'class' => 'mw-ui-input loginPassword',
148 'id' => 'wpRetype',
149 'tabindex' => '5',
150 'size' => '20',
151 'required',
152 'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
153 ) + User::passwordChangeInputAttribs() );
155 </div>
157 <div class="mw-ui-vform-field">
158 <?php if ( $this->data['useemail'] ) { ?>
159 <label for='wpEmail'>
160 <?php
161 $this->msg( $this->data['emailrequired'] ?
162 'createacct-emailrequired' :
163 'createacct-emailoptional'
166 </label>
167 <?php
168 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
169 'class' => 'mw-ui-input loginText',
170 'id' => 'wpEmail',
171 'tabindex' => '6',
172 'size' => '20',
173 'required' => $this->data['emailrequired'],
174 'placeholder' => $this->getMsg( $this->data['loggedin'] ?
175 'createacct-another-email-ph' : 'createacct-email-ph' )->text()
176 ) );
178 <?php } ?>
179 </div>
181 <?php if ( $this->data['userealname'] ) { ?>
182 <div class="mw-ui-vform-field">
183 <label for='wpRealName'><?php $this->msg( 'createacct-realname' ); ?></label>
184 <input type='text' class='mw-ui-input loginText' name="wpRealName" id="wpRealName"
185 tabindex="7"
186 value="<?php $this->text( 'realname' ); ?>" size='20' />
187 <div class="prefsectiontip">
188 <?php $this->msgWiki( $this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
189 </div>
190 </div>
191 <?php } ?>
193 <?php if ( $this->data['usereason'] ) { ?>
194 <div class="mw-ui-vform-field">
195 <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
196 <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
197 'class' => 'mw-ui-input loginText',
198 'id' => 'wpReason',
199 'tabindex' => '8',
200 'size' => '20',
201 'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
202 ) ); ?>
203 </div>
204 <?php } ?>
206 <?php
207 $tabIndex = 9;
208 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
209 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
210 <div class="mw-ui-vform-field">
211 <?php
212 // If it's a checkbox, output the whole thing (assume it has a msg).
213 if ( $inputItem['type'] == 'checkbox' ) {
215 <div class="mw-ui-checkbox">
216 <input
217 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
218 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
219 type="checkbox" value="1"
220 tabindex="<?php echo $tabIndex++; ?>"
221 <?php if ( !empty( $inputItem['value'] ) ) {
222 echo 'checked="checked"';
223 } ?>
224 ><label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
225 <?php $this->msg( $inputItem['msg'] ); ?>
226 </label>
227 </div>
228 <?php
229 } else {
230 // Not a checkbox.
231 // TODO (bug 31909) support other input types, e.g. select boxes.
233 <?php if ( !empty( $inputItem['msg'] ) ) { ?>
234 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
235 <?php $this->msgWiki( $inputItem['msg'] ); ?>
236 </label>
237 <?php } ?>
238 <input
239 type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>"
240 class="mw-ui-input"
241 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
242 tabindex="<?php echo $tabIndex++; ?>"
243 value="<?php echo htmlspecialchars( $inputItem['value'] ); ?>"
244 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
246 <?php } ?>
247 <?php if ( $inputItem['helptext'] !== false ) { ?>
248 <div class="prefsectiontip">
249 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
250 </div>
251 <?php } ?>
252 </div>
253 <?php
257 // A separate placeholder for any inserting any extrafields, e.g used by ConfirmEdit extension
258 if ( $this->haveData( 'extrafields' ) ) {
259 echo $this->data['extrafields'];
261 // skip one index.
262 $tabIndex++;
264 <div class="mw-ui-vform-field mw-submit">
265 <?php
266 echo Html::submitButton(
267 $this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
268 array(
269 'id' => 'wpCreateaccount',
270 'name' => 'wpCreateaccount',
271 'tabindex' => $tabIndex++
273 array(
274 'mw-ui-block',
275 'mw-ui-constructive',
279 </div>
280 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
281 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
282 </form>
283 <?php if ( !wfMessage( 'signupend' )->isDisabled() ) { ?>
284 <div id="signupend"><?php $this->html( 'signupend' ); ?></div>
285 <?php } ?>
286 </div>
287 <div class="mw-createacct-benefits-container">
288 <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
289 <div class="mw-createacct-benefits-list">
290 <?php
291 for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
292 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
293 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
295 <div class="mw-number-text <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>">
296 <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
297 <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
298 </div>
299 <?php } ?>
300 </div>
301 </div>
302 </div>
303 <?php