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