BUG#621 Require a minimum password length at account creation
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
1 <?php
2 /**
3 * Hold things related to displaying and saving user preferences.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 if( !defined( 'MEDIAWIKI' ) )
9 die();
10
11 /** to get a list of languages in setting user's language preference */
12 require_once('languages/Names.php');
13
14 /**
15 * Entry point that create the "Preferences" object
16 */
17 function wfSpecialPreferences() {
18 global $wgRequest;
19
20 $form = new PreferencesForm( $wgRequest );
21 $form->execute();
22 }
23
24 /**
25 * Preferences form handling
26 * This object will show the preferences form and can save it as well.
27 * @package MediaWiki
28 * @subpackage SpecialPage
29 */
30 class PreferencesForm {
31 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
32 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
33 var $mUserLanguage, $mUserVariant;
34 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
35 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
36
37 /**
38 * Constructor
39 * Load some values
40 */
41 function PreferencesForm( &$request ) {
42 global $wgLang, $wgContLang, $wgAllowRealName;
43
44 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
45 $this->mOldpass = $request->getVal( 'wpOldpass' );
46 $this->mNewpass = $request->getVal( 'wpNewpass' );
47 $this->mRetypePass =$request->getVal( 'wpRetypePass' );
48 $this->mStubs = $request->getVal( 'wpStubs' );
49 $this->mRows = $request->getVal( 'wpRows' );
50 $this->mCols = $request->getVal( 'wpCols' );
51 $this->mSkin = $request->getVal( 'wpSkin' );
52 $this->mMath = $request->getVal( 'wpMath' );
53 $this->mDate = $request->getVal( 'wpDate' );
54 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
55 $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
56 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
57 $this->mNick = $request->getVal( 'wpNick' );
58 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
59 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
60 $this->mSearch = $request->getVal( 'wpSearch' );
61 $this->mRecent = $request->getVal( 'wpRecent' );
62 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
63 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
64 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
65 $this->mImageSize = $request->getVal( 'wpImageSize' );
66
67 $this->mAction = $request->getVal( 'action' );
68 $this->mReset = $request->getCheck( 'wpReset' );
69 $this->mPosted = $request->wasPosted();
70 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) && $this->mPosted;
71
72 # User toggles (the big ugly unsorted list of checkboxes)
73 $this->mToggles = array();
74 if ( $this->mPosted ) {
75 $togs = $wgLang->getUserToggles();
76 foreach ( $togs as $tname ) {
77 $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
78 }
79 }
80
81 $this->mUsedToggles = array();
82
83 # Search namespace options
84 # Note: namespaces don't necessarily have consecutive keys
85 $this->mSearchNs = array();
86 if ( $this->mPosted ) {
87 $namespaces = $wgContLang->getNamespaces();
88 foreach ( $namespaces as $i => $namespace ) {
89 if ( $i >= 0 ) {
90 $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
91 }
92 }
93 }
94
95 # Validate language
96 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
97 $this->mUserLanguage = 'nolanguage';
98 }
99 }
100
101 function execute() {
102 global $wgUser, $wgOut, $wgUseDynamicDates;
103
104 if ( 0 == $wgUser->getID() ) {
105 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
106 return;
107 }
108 if ( wfReadOnly() ) {
109 $wgOut->readOnlyPage();
110 return;
111 }
112 if ( $this->mReset ) {
113 $this->resetPrefs();
114 $this->mainPrefsForm( wfMsg( 'prefsreset' ) );
115 } else if ( $this->mSaveprefs ) {
116 $this->savePreferences();
117 } else {
118 $this->resetPrefs();
119 $this->mainPrefsForm( '' );
120 }
121 }
122
123 /**
124 * @access private
125 */
126 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
127 $val = intval($val);
128 $val = min($val, $max);
129 $val = max($val, $min);
130 return $val;
131 }
132
133 /**
134 * @access private
135 */
136 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
137 $val = trim($val);
138 if($val === '') {
139 return $val;
140 } else {
141 return $this->validateInt( $val, $min, $max );
142 }
143 }
144
145 /**
146 * @access private
147 */
148 function validateTimeZone( $s ) {
149 if ( $s !== '' ) {
150 if ( strpos( $s, ':' ) ) {
151 # HH:MM
152 $array = explode( ':' , $s );
153 $hour = intval( $array[0] );
154 $minute = intval( $array[1] );
155 } else {
156 $minute = intval( $s * 60 );
157 $hour = intval( $minute / 60 );
158 $minute = abs( $minute ) % 60;
159 }
160 $hour = min( $hour, 15 );
161 $hour = max( $hour, -15 );
162 $minute = min( $minute, 59 );
163 $minute = max( $minute, 0 );
164 $s = sprintf( "%02d:%02d", $hour, $minute );
165 }
166 return $s;
167 }
168
169 /**
170 * @access private
171 */
172 function savePreferences() {
173 global $wgUser, $wgLang, $wgOut;
174 global $wgEnableUserEmail, $wgEnableEmail;
175 global $wgEmailAuthentication, $wgMinimalPasswordLength;
176 ;
177
178 if ( '' != $this->mNewpass ) {
179 if ( $this->mNewpass != $this->mRetypePass ) {
180 $this->mainPrefsForm( wfMsg( 'badretype' ) );
181 return;
182 }
183
184 if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) {
185 $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
186 return;
187 }
188
189 if (!$wgUser->checkPassword( $this->mOldpass )) {
190 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
191 return;
192 }
193 $wgUser->setPassword( $this->mNewpass );
194 }
195 $wgUser->setRealName( $this->mRealName );
196 $wgUser->setOption( 'language', $this->mUserLanguage );
197 $wgUser->setOption( 'variant', $this->mUserVariant );
198 $wgUser->setOption( 'nickname', $this->mNick );
199 $wgUser->setOption( 'quickbar', $this->mQuickbar );
200 $wgUser->setOption( 'skin', $this->mSkin );
201 $wgUser->setOption( 'math', $this->mMath );
202 $wgUser->setOption( 'date', $this->mDate );
203 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
204 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
205 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
206 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
207 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
208 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
209 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
210 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
211 $wgUser->setOption( 'imagesize', $this->mImageSize );
212
213 # Set search namespace options
214 foreach( $this->mSearchNs as $i => $value ) {
215 $wgUser->setOption( "searchNs{$i}", $value );
216 }
217
218 if( $wgEnableEmail && $wgEnableUserEmail ) {
219 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
220 }
221
222 # Set user toggles
223 foreach ( $this->mToggles as $tname => $tvalue ) {
224 $wgUser->setOption( $tname, $tvalue );
225 }
226 $wgUser->setCookies();
227 $wgUser->saveSettings();
228
229 if( $wgEnableEmail ) {
230 $newadr = strtolower( $this->mUserEmail );
231 $oldadr = strtolower($wgUser->getEmail());
232 if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page
233 # prepare for authentication and mail a temporary password to newadr
234 require_once( 'SpecialUserlogin.php' );
235 if ( !$wgUser->isValidEmailAddr( $newadr ) ) {
236 $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) );
237 return;
238 }
239 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
240 $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated
241 $wgUser->saveSettings();
242 if ($wgEmailAuthentication) {
243 # mail a temporary password to the dirty address
244 # on "save options", this user will be logged-out automatically
245 $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy );
246 if ($error === '') {
247 return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) );
248 } else {
249 return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) );
250 }
251 # if user returns, that new email address gets authenticated in checkpassword()
252 }
253 } else {
254 $wgUser->setEmail( strtolower($this->mUserEmail) );
255 $wgUser->setCookies();
256 $wgUser->saveSettings();
257 }
258 }
259
260 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
261 $po = ParserOptions::newFromUser( $wgUser );
262 $this->mainPrefsForm( wfMsg( 'savedprefs' ) );
263 }
264
265 /**
266 * @access private
267 */
268 function resetPrefs() {
269 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
270
271 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
272 $this->mUserEmail = $wgUser->getEmail();
273 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
274 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
275 $this->mUserLanguage = $wgUser->getOption( 'language' );
276 if( empty( $this->mUserLanguage ) ) {
277 # Quick hack for conversions, where this value is blank
278 global $wgContLanguageCode;
279 $this->mUserLanguage = $wgContLanguageCode;
280 }
281 $this->mUserVariant = $wgUser->getOption( 'variant');
282 if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
283 else { $this->mEmailFlag = 0; }
284 $this->mNick = $wgUser->getOption( 'nickname' );
285
286 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
287 $this->mSkin = $wgUser->getOption( 'skin' );
288 $this->mMath = $wgUser->getOption( 'math' );
289 $this->mDate = $wgUser->getOption( 'date' );
290 $this->mRows = $wgUser->getOption( 'rows' );
291 $this->mCols = $wgUser->getOption( 'cols' );
292 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
293 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
294 $this->mSearch = $wgUser->getOption( 'searchlimit' );
295 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
296 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
297 $this->mImageSize = $wgUser->getOption( 'imagesize' );
298 $this->mRecent = $wgUser->getOption( 'rclimit' );
299
300 $togs = $wgLang->getUserToggles();
301 foreach ( $togs as $tname ) {
302 $ttext = wfMsg('tog-'.$tname);
303 $this->mToggles[$tname] = $wgUser->getOption( $tname );
304 }
305
306 $namespaces = $wgContLang->getNamespaces();
307 foreach ( $namespaces as $i => $namespace ) {
308 if ( $i >= 0 ) {
309 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
310 }
311 }
312 }
313
314 /**
315 * @access private
316 */
317 function namespacesCheckboxes() {
318 global $wgContLang, $wgUser;
319
320 # Determine namespace checkboxes
321 $namespaces = $wgContLang->getNamespaces();
322 $r1 = '';
323
324 foreach ( $namespaces as $i => $name ) {
325 # Skip special or anything similar
326 if ( $i >= 0 ) {
327 $checked = '';
328 if ( $this->mSearchNs[$i] ) {
329 $checked = ' checked="checked"';
330 }
331 $name = str_replace( '_', ' ', $namespaces[$i] );
332 if ( '' == $name ) {
333 $name = wfMsg( 'blanknamespace' );
334 }
335
336 if ( 0 != $i ) {
337 $r1 .= ' ';
338 }
339 $r1 .= "<label><input type='checkbox' value=\"1\" name=\"" .
340 "wpNs$i\"{$checked} />{$name}</label>\n";
341 }
342 }
343
344 return $r1;
345 }
346
347
348 function getToggle( $tname, $trailer = false) {
349 global $wgUser, $wgLang;
350
351 $this->mUsedToggles[$tname] = true;
352 $ttext = $wgLang->getUserToggle( $tname );
353
354 if ( 1 == $wgUser->getOption( $tname ) ) {
355 $checked = ' checked="checked"';
356 } else {
357 $checked = '';
358 }
359 $trailer =($trailer) ? $trailer : '';
360 return "<div><input type='checkbox' value=\"1\" "
361 . "id=\"$tname\" name=\"wpOp$tname\"$checked /><label for=\"$tname\">$ttext</label>$trailer</div>\n";
362 }
363
364 /**
365 * @access private
366 */
367 function mainPrefsForm( $err ) {
368 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames;
369 global $wgAllowRealName, $wgImageLimits;
370 global $wgLanguageNames, $wgDisableLangConversion;
371 global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
372 global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
373 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
374 global $wgContLanguageCode;
375
376 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
377 $wgOut->setArticleRelated( false );
378 $wgOut->setRobotpolicy( 'noindex,nofollow' );
379
380 if ( '' != $err ) {
381 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
382 }
383 $uname = $wgUser->getName();
384 $uid = $wgUser->getID();
385
386 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
387 $wgOut->addWikiText( wfMsg('clearyourcache'));
388
389 $qbs = $wgLang->getQuickbarSettings();
390 $skinNames = $wgLang->getSkinNames();
391 $mathopts = $wgLang->getMathNames();
392 $dateopts = $wgLang->getDateFormats();
393 $togs = $wgLang->getUserToggles();
394
395 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
396 $action = $titleObj->escapeLocalURL();
397
398 $qb = wfMsg( 'qbsettings' );
399 $cp = wfMsg( 'changepassword' );
400 $sk = wfMsg( 'skin' );
401 $math = wfMsg( 'math' );
402 $dateFormat = wfMsg('dateformat');
403 $opw = wfMsg( 'oldpassword' );
404 $npw = wfMsg( 'newpassword' );
405 $rpw = wfMsg( 'retypenew' );
406 $svp = wfMsg( 'saveprefs' );
407 $rsp = wfMsg( 'resetprefs' );
408 $tbs = wfMsg( 'textboxsize' );
409 $tbr = wfMsg( 'rows' );
410 $tbc = wfMsg( 'columns' );
411 $ltz = wfMsg( 'localtime' );
412 $timezone = wfMsg( 'timezonelegend' );
413 $tzt = wfMsg( 'timezonetext' );
414 $tzo = wfMsg( 'timezoneoffset' );
415 $tzGuess = wfMsg( 'guesstimezone' );
416 $tzServerTime = wfMsg( 'servertime' );
417 $yem = wfMsg( 'youremail' );
418 $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
419 $yl = wfMsg( 'yourlanguage' );
420 $yv = wfMsg( 'yourvariant' );
421 $emf = wfMsg( 'emailflag' );
422 $ynn = wfMsg( 'yournick' );
423 $stt = wfMsg ( 'stubthreshold' ) ;
424 $srh = wfMsg( 'searchresultshead' );
425 $rpp = wfMsg( 'resultsperpage' );
426 $scl = wfMsg( 'contextlines' );
427 $scc = wfMsg( 'contextchars' );
428 $rcc = wfMsg( 'recentchangescount' );
429 $dsn = wfMsg( 'defaultns' );
430
431 $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
432 method=\"post\">" );
433
434 # First section: identity
435 # Email, etc.
436 #
437 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
438 $this->mRealName = htmlspecialchars( $this->mRealName );
439 $this->mNick = htmlspecialchars( $this->mNick );
440 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
441 else { $emfc = ''; }
442
443 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
444 if ($wgUser->getEmailAuthenticationtimestamp() != 0) {
445 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationtimestamp(), true ) ).'<br />';
446 $disabled = '';
447 } else {
448 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />';
449 $disabled = ' '.wfMsg('disableduntilauthent');
450 }
451 } else {
452 $emailauthenticated = '';
453 }
454
455 if ($this->mUserEmail == '') {
456 $disabled = ' '.wfMsg('disablednoemail');
457 }
458
459 $ps = $this->namespacesCheckboxes();
460
461 $enotifwatchlistpages = ($wgEmailNotificationForWatchlistPages) ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
462 $enotifusertalkpages = ($wgEmailNotificationForUserTalkPages) ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
463 $enotifminoredits = ($wgEmailNotificationForMinorEdits) ? $this->getToggle( 'enotifminoredits', $disabled) : '';
464 $enotifrevealaddr = ($wgEmailNotificationRevealPageEditorAddress) ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
465 $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
466 $prefs_help_realname = '';
467
468 $wgOut->addHTML( "<fieldset>
469 <legend>".wfMsg('prefs-personal')."</legend>");
470
471 if ($wgAllowRealName) {
472 $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
473 $prefs_help_realname = wfMsg('prefs-help-realname').'<br />';
474 }
475
476 if( $wgEnableEmail ) {
477 $wgOut->addHTML("
478 <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>" );
479 if( $wgEnableUserEmail ) {
480 $wgOut->addHTML(
481 $emailauthenticated.
482 $enotifrevealaddr.
483 $enotifwatchlistpages.
484 $enotifusertalkpages.
485 $enotifminoredits.
486 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf.$disabled</label></div>" );
487 }
488 }
489
490 $fancysig = $this->getToggle( 'fancysig' );
491 $wgOut->addHTML("
492 <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='25' /></label></div>
493 <div>$fancysig<br /></div>
494 <div><label>$yl: <select name=\"wpUserLanguage\">\n");
495
496 /**
497 * If a bogus value is set, default to the content language.
498 * Otherwise, no default is selected and the user ends up
499 * with an Afrikaans interface since it's first in the list.
500 */
501 if( isset( $wgLanguageNames[$this->mUserLanguage] ) ) {
502 $selectedLang = $this->mUserLanguage;
503 } else {
504 $selectedLang = $wgContLanguageCode;
505 }
506 foreach($wgLanguageNames as $code => $name) {
507 global $IP;
508 /* only add languages that have a file */
509 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
510 if(file_exists($langfile) || $code == $wgContLanguageCode) {
511 $sel = ($code == $selectedLang)? 'selected="selected"' : '';
512 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
513 }
514 }
515 $wgOut->addHtml("</select></label></div>\n" );
516
517 /* see if there are multiple language variants to choose from*/
518 if(!$wgDisableLangConversion) {
519 $variants = $wgContLang->getVariants();
520 $size=sizeof($variants);
521
522 $variantArray=array();
523 foreach($variants as $v) {
524 $v = str_replace( '_', '-', strtolower($v));
525 if($name=$wgLanguageNames[$v]) {
526 $variantArray[$v] = $name;
527 }
528 }
529 $size=sizeof($variantArray);
530
531 if(sizeof($variantArray) > 1) {
532 $wgOut->addHtml("
533 <div><label>$yv: <select name=\"wpUserVariant\">\n");
534 foreach($variantArray as $code => $name) {
535 $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
536 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
537 }
538 }
539 }
540 # Fields for changing password
541 #
542 $this->mOldpass = htmlspecialchars( $this->mOldpass );
543 $this->mNewpass = htmlspecialchars( $this->mNewpass );
544 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
545
546 $wgOut->addHTML( "<fieldset>
547 <legend>$cp</legend>
548 <div><label>$opw: <input type='password' name=\"wpOldpass\" value=\"{$this->mOldpass}\" size='20' /></label></div>
549 <div><label>$npw: <input type='password' name=\"wpNewpass\" value=\"{$this->mNewpass}\" size='20' /></label></div>
550 <div><label>$rpw: <input type='password' name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size='20' /></label></div>
551 " . $this->getToggle( "rememberpassword" ) . "
552 </fieldset>
553 <div class='prefsectiontip'>".$prefs_help_realname.wfMsg('prefs-help-email').$prefs_help_email_enotif."</div>\n</fieldset>\n" );
554
555
556 # Quickbar setting
557 #
558 $wgOut->addHtml( "<fieldset>\n<legend>$qb</legend>\n" );
559 for ( $i = 0; $i < count( $qbs ); ++$i ) {
560 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
561 else { $checked = ""; }
562 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpQuickbar\"
563 value=\"$i\"$checked /> {$qbs[$i]}</label></div>\n" );
564 }
565 $wgOut->addHtml('<div class="prefsectiontip">'.wfMsg('qbsettingsnote').'</div>');
566 $wgOut->addHtml( "</fieldset>\n\n" );
567
568 # Skin setting
569 #
570 $wgOut->addHTML( "<fieldset>\n<legend>$sk</legend>\n" );
571 # Only show members of $wgValidSkinNames rather than
572 # $skinNames (skins is all skin names from Language.php)
573 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
574 if ( $skinkey == $this->mSkin ) {
575 $checked = ' checked="checked"';
576 } else {
577 $checked = '';
578 }
579 if ( isset( $skinNames[$skinkey] ) ) {
580 $sn = $skinNames[$skinkey];
581 } else {
582 $sn = $skinname;
583 }
584 global $wgDefaultSkin;
585 if( $skinkey == $wgDefaultSkin ) {
586 $sn .= ' (' . wfMsg( 'default' ) . ')';
587 }
588 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpSkin\"
589 value=\"$skinkey\"$checked /> {$sn}</label></div>\n" );
590 }
591 $wgOut->addHTML( "</fieldset>\n\n" );
592
593 # Math setting
594 #
595 $wgOut->addHTML( "<fieldset>\n<legend>$math</legend>\n" );
596 for ( $i = 0; $i < count( $mathopts ); ++$i ) {
597 if ( $i == $this->mMath ) { $checked = ' checked="checked"'; }
598 else { $checked = ""; }
599 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpMath\"
600 value=\"$i\"$checked /> ".wfMsg($mathopts[$i])."</label></div>\n" );
601 }
602 $wgOut->addHTML( "</fieldset>\n\n" );
603
604 # Date format
605 #
606 if ( $wgUseDynamicDates ) {
607 $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
608 for ( $i = 0; $i < count( $dateopts ); ++$i) {
609 if ( $i == $this->mDate ) {
610 $checked = ' checked="checked"';
611 } else {
612 $checked = "";
613 }
614 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
615 "value=\"$i\"$checked /> {$dateopts[$i]}</label></div>\n" );
616 }
617 $wgOut->addHTML( "</fieldset>\n\n");
618 }
619
620 # Textbox rows, cols
621 #
622 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
623 $nowserver = $wgLang->time( $now, false );
624 $wgOut->addHTML( "<fieldset>
625 <legend>$tbs</legend>\n
626 <div>
627 <label>$tbr: <input type='text' name=\"wpRows\" value=\"{$this->mRows}\" size='6' /></label>
628 <label>$tbc: <input type='text' name=\"wpCols\" value=\"{$this->mCols}\" size='6' /></label>
629 </div> " .
630 $this->getToggle( "editwidth" ) .
631 $this->getToggle( "showtoolbar" ) .
632 $this->getToggle( "previewonfirst" ) .
633 $this->getToggle( "previewontop" ) .
634 $this->getToggle( "watchdefault" ) .
635 $this->getToggle( "minordefault" ) . "
636 </fieldset>
637
638 <fieldset>
639 <legend>$timezone</legend>
640 <div><b>$tzServerTime:</b> $nowserver</div>
641 <div><b>$ltz:</b> $nowlocal</div>
642 <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' /></label></div>
643 <div><input type=\"button\" value=\"$tzGuess\" onclick=\"javascript:guessTimezone()\" id=\"guesstimezonebutton\" style=\"display:none\" /></div>
644 <div class='prefsectiontip'>* {$tzt}</div>
645 </fieldset>\n\n" );
646
647 $shownumberswatching = ($wgRCShowWatchingUsers) ? $this->getToggle('shownumberswatching') : '';
648
649 $wgOut->addHTML( "
650 <fieldset><legend>".wfMsg('prefs-rc')."</legend>
651 <div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>" .
652 $this->getToggle( "hideminor" ) . $shownumberswatching .
653 $this->getToggle( "usenewrc" ) . $this->getToggle('showupdated', wfMsg('updatedmarker')) .
654 "<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
655 <div><label>".wfMsg('imagemaxsize')."<select name=\"wpImageSize\">");
656
657 $imageLimitOptions='';
658 foreach ( $wgImageLimits as $index => $limits ) {
659 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
660 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
661 }
662 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
663
664 </fieldset>
665
666 <fieldset>
667 <legend>$srh</legend>
668 <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
669 <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
670 <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
671
672 <fieldset>
673 <legend>$dsn</legend>
674 $ps
675 </fieldset>
676 </fieldset>
677 " );
678
679 # Various checkbox options
680 #
681 $wgOut->addHTML("<fieldset><legend>".wfMsg('prefs-misc')."</legend>");
682 foreach ( $togs as $tname ) {
683 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
684 $wgOut->addHTML( $this->getToggle( $tname ) );
685 }
686 }
687 $wgOut->addHTML( "</fieldset>\n\n" );
688
689 $wgOut->addHTML( "
690 <div id='prefsubmit'>
691 <div>
692 <input type='submit' name=\"wpSaveprefs\" value=\"$svp\" accesskey=\"".
693 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
694 <input type='submit' name=\"wpReset\" value=\"$rsp\" />
695 </div>
696
697 </div>
698
699 </form>\n" );
700 }
701 }
702 ?>