Merge "Add ss_active_users in SiteStats::isSane"
[mediawiki.git] / includes / templates / UsercreateVForm.php
blob2e72f70da118d65552a60106934baaf51453169c
1 <?php
2 /**
3 * Html form for account creation with new VForm appearance.
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.
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.
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
20 * @file
21 * @ingroup Templates
24 if ( !defined( 'MEDIAWIKI' ) ) {
25 die( -1 );
28 /**
29 * Html form for create account with new VForm appearance.
31 * @since 1.22
33 class UsercreateTemplateVForm extends BaseTemplate {
35 /**
36 * Extensions (AntiSpoof and TitleBlacklist) call this in response to
37 * UserCreateForm hook to add checkboxes to the create account form.
39 function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
40 $this->data['extraInput'][] = array(
41 'name' => $name,
42 'value' => $value,
43 'type' => $type,
44 'msg' => $msg,
45 'helptext' => $helptext,
49 function execute() {
50 global $wgCookieExpiration;
51 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
53 <div class="mw-ui-container">
54 <?php
55 if ( $this->haveData( 'languages' ) ) {
57 <div id="languagelinks">
58 <p><?php $this->html( 'languages' ); ?></p>
59 </div>
60 <?php
63 <div id="userloginForm">
64 <h2 class="createaccount-join"><?php $this->msg( 'createacct-join' ); ?></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'] ) {
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' ); ?>
83 <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
84 </label>
85 <?php echo Html::input( 'wpName', $this->data['name'], 'text', array(
86 'class' => 'mw-input loginText',
87 'id' => 'wpName2',
88 'tabindex' => '1',
89 'size' => '20',
90 'required',
91 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text(),
92 'autofocus'
93 ) ); ?>
94 </div>
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 } ?>
103 <?php $this->msg( 'createaccountmail' ); ?>
104 </label>
105 <?php } ?>
106 </div>
107 <div class="mw-row-password">
108 <label for='wpPassword2'><?php $this->msg( 'userlogin-yourpassword' ); ?></label>
109 <?php echo Html::input( 'wpPassword', null, 'password', array(
110 'class' => 'mw-input loginPassword',
111 'id' => 'wpPassword2',
112 'tabindex' => '3',
113 'size' => '20',
114 'required',
115 'placeholder' => $this->getMsg( 'createacct-yourpassword-ph' )->text()
116 ) + User::passwordChangeInputAttribs() ); ?>
117 </div>
118 <?php if ( $this->data['usedomain'] ) {
119 $doms = "";
120 foreach ( $this->data['domainnames'] as $dom ) {
121 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
124 <div>
125 <label><?php $this->msg( 'yourdomainname' ); ?></label>
126 <div class="mw-input">
127 <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>"
128 tabindex="4">
129 <?php echo $doms ?>
130 </select>
131 </div>
132 </div>
133 <?php } ?>
134 <div class="mw-row-password">
135 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
136 <?php
137 echo Html::input( 'wpRetype', null, 'password', array(
138 'class' => 'mw-input loginPassword',
139 'id' => 'wpRetype',
140 'tabindex' => '5',
141 'size' => '20',
142 'required',
143 'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
144 ) + User::passwordChangeInputAttribs() );
146 </div>
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'
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 'placeholder' => $this->getMsg( 'createacct-email-ph' )->text()
164 ) + ( $this->data['emailrequired'] ? array() : array( 'required' => '' ) ) );
166 <?php
167 // VForm eliminates the prefsectiontip div tip:
168 // prefs-help-email-required is redundant with the placeholder text
169 // Doesn't show the wordy prefs-help-email
170 // Doesn't show the wordy prefs-help-email-others
172 <?php } ?>
173 </div>
174 <?php if ( $this->data['userealname'] ) { ?>
175 <div>
176 <label for='wpRealName'><?php $this->msg( 'createacct-realname' ); ?></label>
177 <input type='text' class='mw-input loginText' name="wpRealName" id="wpRealName"
178 tabindex="7"
179 value="<?php $this->text( 'realname' ); ?>" size='20' />
180 <div class="prefsectiontip">
181 <?php $this->msgWiki( 'prefs-help-realname' ); ?>
182 </div>
183 </div>
184 <?php }
185 if ( $this->data['usereason'] ) { ?>
186 <div>
187 <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
188 <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
189 'class' => 'mw-input loginText',
190 'id' => 'wpReason',
191 'tabindex' => '8',
192 'size' => '20',
193 'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
194 ) ); ?>
195 </div>
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' ) {
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 } ?>
215 <?php $this->msg( $inputItem['msg'] ); ?>
216 </label>
217 <?php
218 } else {
219 // Not a checkbox.
220 if ( !empty( $inputItem['msg'] ) ) {
221 // Output the message label
223 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
224 <?php $this->msgWiki( $inputItem['msg'] ); ?>
225 </label>
226 <?php
229 <input
230 type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>"
231 class="mw-input"
232 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
233 tabindex="<?php echo $tabIndex++; ?>"
234 value="<?php echo htmlspecialchars( $inputItem['value'] ); ?>"
235 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
237 <?php
239 if ( $inputItem['helptext'] !== false ) {
241 <div class="prefsectiontip">
242 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
243 </div>
244 <?php
247 </div>
248 <?php
251 // JS attempts to move the image CAPTCHA below this part of the form,
252 // so skip one index.
253 $tabIndex++;
255 <div class="mw-submit">
256 <input type='submit' class="mw-ui-button mw-ui-big mw-ui-block mw-ui-primary" name="wpCreateaccount" id="wpCreateaccount"
257 tabindex="<?php echo $tabIndex++; ?>"
258 value="<?php $this->msg( 'createacct-submit' ); ?>" />
259 </div>
260 <input type="hidden" id="useNew" name="useNew" value="1" />
261 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
262 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
263 </form>
264 </div>
265 <div class="mw-createacct-benefits-container">
266 <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
267 <div class="mw-createacct-benefits-list">
268 <?php
269 for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
270 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
271 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
273 <div>
274 <div class="mw-benefits-icon <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>"></div>
275 <div class="mw-number-text">
276 <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
277 <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
278 </div>
279 </div>
280 <?php
283 </div>
284 </div>
285 </div>
286 <?php