Move subclasses of LogFormatter to their own file
[lhc/web/wiklou.git] / includes / templates / Usercreate.php
1 <?php
2 /**
3 * Html form for account creation.
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 /**
25 * @defgroup Templates Templates
26 */
27
28 if( !defined( 'MEDIAWIKI' ) ) die( -1 );
29
30 /**
31 * @ingroup Templates
32 */
33 class UsercreateTemplate extends QuickTemplate {
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 if( $this->data['message'] ) {
46 ?>
47 <div class="<?php $this->text('messagetype') ?>box">
48 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
49 <strong><?php $this->msg( 'loginerror' )?></strong><br />
50 <?php } ?>
51 <?php $this->html('message') ?>
52 </div>
53 <div class="visualClear"></div>
54 <?php } ?>
55
56 <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
57 <div id="userlogin">
58
59 <form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
60 <h2><?php $this->msg('createaccount') ?></h2>
61 <p id="userloginlink"><?php $this->html('link') ?></p>
62 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
63 <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
64 <table>
65 <tr>
66 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
67 <td class="mw-input">
68 <?php
69 echo Html::input( 'wpName', $this->data['name'], 'text', array(
70 'class' => 'loginText',
71 'id' => 'wpName2',
72 'tabindex' => '1',
73 'size' => '20',
74 'required',
75 'autofocus'
76 ) ); ?>
77 </td>
78 </tr>
79 <tr>
80 <td></td>
81 <td class="mw-input">
82 <?php if( $this->data['createemail'] ) {
83 echo Xml::checkLabel(
84 wfMessage( 'createaccountmail' )->text(),
85 'wpCreateaccountMail',
86 'wpCreateaccountMail',
87 $this->data['createemailset'],
88 array( 'tabindex' => '2' )
89 );
90 } ?>
91 </td>
92 </tr>
93 <tr class="mw-row-password">
94 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
95 <td class="mw-input">
96 <?php
97 echo Html::input( 'wpPassword', null, 'password', array(
98 'class' => 'loginPassword',
99 'id' => 'wpPassword2',
100 'tabindex' => '3',
101 'size' => '20'
102 ) + User::passwordChangeInputAttribs() ); ?>
103 </td>
104 </tr>
105 <?php if( $this->data['usedomain'] ) {
106 $doms = "";
107 foreach( $this->data['domainnames'] as $dom ) {
108 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
109 }
110 ?>
111 <tr>
112 <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
113 <td class="mw-input">
114 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
115 tabindex="4">
116 <?php echo $doms ?>
117 </select>
118 </td>
119 </tr>
120 <?php } ?>
121 <tr class="mw-row-password">
122 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
123 <td class="mw-input">
124 <?php
125 echo Html::input( 'wpRetype', null, 'password', array(
126 'class' => 'loginPassword',
127 'id' => 'wpRetype',
128 'tabindex' => '5',
129 'size' => '20'
130 ) + User::passwordChangeInputAttribs() ); ?>
131 </td>
132 </tr>
133 <tr>
134 <?php if( $this->data['useemail'] ) { ?>
135 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
136 <td class="mw-input">
137 <?php
138 echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
139 'class' => 'loginText',
140 'id' => 'wpEmail',
141 'tabindex' => '6',
142 'size' => '20'
143 ) ); ?>
144 <div class="prefsectiontip">
145 <?php // duplicated in Preferences.php profilePreferences()
146 if( $this->data['emailrequired'] ) {
147 $this->msgWiki('prefs-help-email-required');
148 } else {
149 $this->msgWiki('prefs-help-email');
150 }
151 if( $this->data['emailothers'] ) {
152 $this->msgWiki('prefs-help-email-others');
153 } ?>
154 </div>
155 </td>
156 <?php } ?>
157 <?php if( $this->data['userealname'] ) { ?>
158 </tr>
159 <tr>
160 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
161 <td class="mw-input">
162 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
163 tabindex="7"
164 value="<?php $this->text('realname') ?>" size='20' />
165 <div class="prefsectiontip">
166 <?php $this->msgWiki('prefs-help-realname'); ?>
167 </div>
168 </td>
169 <?php } ?>
170 <?php if( $this->data['usereason'] ) { ?>
171 </tr>
172 <tr>
173 <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
174 <td class="mw-input">
175 <input type='text' class='loginText' name="wpReason" id="wpReason"
176 tabindex="8"
177 value="<?php $this->text('reason') ?>" size='20' />
178 </td>
179 <?php } ?>
180 </tr>
181 <?php if( $this->data['canremember'] ) { ?>
182 <tr>
183 <td></td>
184 <td class="mw-input">
185 <?php
186 global $wgCookieExpiration;
187 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
188 echo Xml::checkLabel(
189 wfMessage( 'remembermypassword' )->numParams( $expirationDays )->text(),
190 'wpRemember',
191 'wpRemember',
192 $this->data['remember'],
193 array( 'tabindex' => '9' )
194 )
195 ?>
196 </td>
197 </tr>
198 <?php }
199
200 $tabIndex = 10;
201 if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
202 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
203 <tr>
204 <?php
205 if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
206 ?><td class="mw-label"><label for="<?php
207 echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
208 $this->msgWiki( $inputItem['msg'] ) ?></label><?php
209 } else {
210 ?><td><?php
211 }
212 ?></td>
213 <td class="mw-input">
214 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
215 echo htmlspecialchars( $inputItem['name'] ); ?>"
216 tabindex="<?php echo $tabIndex++; ?>"
217 value="<?php
218 if ( $inputItem['type'] != 'checkbox' ) {
219 echo htmlspecialchars( $inputItem['value'] );
220 } else {
221 echo '1';
222 }
223 ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
224 <?php
225 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
226 echo 'checked="checked"';
227 ?> /> <?php
228 if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
229 ?>
230 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
231 $this->msgHtml( $inputItem['msg'] ) ?></label><?php
232 }
233 if( $inputItem['helptext'] !== false ) {
234 ?>
235 <div class="prefsectiontip">
236 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
237 </div>
238 <?php } ?>
239 </td>
240 </tr>
241 <?php
242 }
243 }
244 ?>
245 <tr>
246 <td></td>
247 <td class="mw-submit">
248 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
249 tabindex="<?php echo $tabIndex++; ?>"
250 value="<?php $this->msg('createaccount') ?>" />
251 </td>
252 </tr>
253 </table>
254 <?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
255 <?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
256 </form>
257 </div>
258 <div id="signupend"><?php $this->html( 'signupend' ); ?></div>
259 <?php
260
261 }
262 }