* (bug 829) Fix URL-escaping on block success
[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;
176
177 if ( '' != $this->mNewpass ) {
178 if ( $this->mNewpass != $this->mRetypePass ) {
179 $this->mainPrefsForm( wfMsg( 'badretype' ) );
180 return;
181 }
182
183 if (!$wgUser->checkPassword( $this->mOldpass )) {
184 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
185 return;
186 }
187 $wgUser->setPassword( $this->mNewpass );
188 }
189 $wgUser->setRealName( $this->mRealName );
190 $wgUser->setOption( 'language', $this->mUserLanguage );
191 $wgUser->setOption( 'variant', $this->mUserVariant );
192 $wgUser->setOption( 'nickname', $this->mNick );
193 $wgUser->setOption( 'quickbar', $this->mQuickbar );
194 $wgUser->setOption( 'skin', $this->mSkin );
195 $wgUser->setOption( 'math', $this->mMath );
196 $wgUser->setOption( 'date', $this->mDate );
197 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
198 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
199 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
200 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
201 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
202 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
203 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
204 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
205 $wgUser->setOption( 'imagesize', $this->mImageSize );
206
207 # Set search namespace options
208 foreach( $this->mSearchNs as $i => $value ) {
209 $wgUser->setOption( "searchNs{$i}", $value );
210 }
211
212 if( $wgEnableEmail && $wgEnableUserEmail ) {
213 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
214 }
215
216 # Set user toggles
217 foreach ( $this->mToggles as $tname => $tvalue ) {
218 $wgUser->setOption( $tname, $tvalue );
219 }
220 $wgUser->setCookies();
221 $wgUser->saveSettings();
222
223 if( $wgEnableEmail ) {
224 $newadr = strtolower( $this->mUserEmail );
225 $oldadr = strtolower($wgUser->getEmail());
226 if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page
227 # prepare for authentication and mail a temporary password to newadr
228 require_once( 'SpecialUserlogin.php' );
229 if ( !$wgUser->isValidEmailAddr( $newadr ) ) {
230 $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) );
231 return;
232 }
233 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
234 $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated
235 $wgUser->saveSettings();
236 if ($wgEmailAuthentication) {
237 # mail a temporary password to the dirty address
238 # on "save options", this user will be logged-out automatically
239 $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy );
240 if ($error === '') {
241 return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) );
242 } else {
243 return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) );
244 }
245 # if user returns, that new email address gets authenticated in checkpassword()
246 }
247 } else {
248 $wgUser->setEmail( strtolower($this->mUserEmail) );
249 $wgUser->setCookies();
250 $wgUser->saveSettings();
251 }
252 }
253
254 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
255 $po = ParserOptions::newFromUser( $wgUser );
256 $this->mainPrefsForm( wfMsg( 'savedprefs' ) );
257 }
258
259 /**
260 * @access private
261 */
262 function resetPrefs() {
263 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
264
265 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
266 $this->mUserEmail = $wgUser->getEmail();
267 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
268 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
269 $this->mUserLanguage = $wgUser->getOption( 'language' );
270 if( empty( $this->mUserLanguage ) ) {
271 # Quick hack for conversions, where this value is blank
272 global $wgContLanguageCode;
273 $this->mUserLanguage = $wgContLanguageCode;
274 }
275 $this->mUserVariant = $wgUser->getOption( 'variant');
276 if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
277 else { $this->mEmailFlag = 0; }
278 $this->mNick = $wgUser->getOption( 'nickname' );
279
280 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
281 $this->mSkin = $wgUser->getOption( 'skin' );
282 $this->mMath = $wgUser->getOption( 'math' );
283 $this->mDate = $wgUser->getOption( 'date' );
284 $this->mRows = $wgUser->getOption( 'rows' );
285 $this->mCols = $wgUser->getOption( 'cols' );
286 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
287 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
288 $this->mSearch = $wgUser->getOption( 'searchlimit' );
289 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
290 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
291 $this->mImageSize = $wgUser->getOption( 'imagesize' );
292 $this->mRecent = $wgUser->getOption( 'rclimit' );
293
294 $togs = $wgLang->getUserToggles();
295 foreach ( $togs as $tname ) {
296 $ttext = wfMsg('tog-'.$tname);
297 $this->mToggles[$tname] = $wgUser->getOption( $tname );
298 }
299
300 $namespaces = $wgContLang->getNamespaces();
301 foreach ( $namespaces as $i => $namespace ) {
302 if ( $i >= 0 ) {
303 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
304 }
305 }
306 }
307
308 /**
309 * @access private
310 */
311 function namespacesCheckboxes() {
312 global $wgContLang, $wgUser;
313
314 # Determine namespace checkboxes
315 $namespaces = $wgContLang->getNamespaces();
316 $r1 = '';
317
318 foreach ( $namespaces as $i => $name ) {
319 # Skip special or anything similar
320 if ( $i >= 0 ) {
321 $checked = '';
322 if ( $this->mSearchNs[$i] ) {
323 $checked = ' checked="checked"';
324 }
325 $name = str_replace( '_', ' ', $namespaces[$i] );
326 if ( '' == $name ) {
327 $name = wfMsg( 'blanknamespace' );
328 }
329
330 if ( 0 != $i ) {
331 $r1 .= ' ';
332 }
333 $r1 .= "<label><input type='checkbox' value=\"1\" name=\"" .
334 "wpNs$i\"{$checked} />{$name}</label>\n";
335 }
336 }
337
338 return $r1;
339 }
340
341
342 function getToggle( $tname, $trailer = false) {
343 global $wgUser, $wgLang;
344
345 $this->mUsedToggles[$tname] = true;
346 $ttext = $wgLang->getUserToggle( $tname );
347
348 if ( 1 == $wgUser->getOption( $tname ) ) {
349 $checked = ' checked="checked"';
350 } else {
351 $checked = '';
352 }
353 $trailer =($trailer) ? $trailer : '';
354 return "<div><input type='checkbox' value=\"1\" "
355 . "id=\"$tname\" name=\"wpOp$tname\"$checked /><label for=\"$tname\">$ttext</label>$trailer</div>\n";
356 }
357
358 /**
359 * @access private
360 */
361 function mainPrefsForm( $err ) {
362 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames;
363 global $wgAllowRealName, $wgImageLimits;
364 global $wgLanguageNames, $wgDisableLangConversion;
365 global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
366 global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
367 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
368 global $wgContLanguageCode;
369
370 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
371 $wgOut->setArticleRelated( false );
372 $wgOut->setRobotpolicy( 'noindex,nofollow' );
373
374 if ( '' != $err ) {
375 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
376 }
377 $uname = $wgUser->getName();
378 $uid = $wgUser->getID();
379
380 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
381 $wgOut->addWikiText( wfMsg('clearyourcache'));
382
383 $qbs = $wgLang->getQuickbarSettings();
384 $skinNames = $wgLang->getSkinNames();
385 $mathopts = $wgLang->getMathNames();
386 $dateopts = $wgLang->getDateFormats();
387 $togs = $wgLang->getUserToggles();
388
389 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
390 $action = $titleObj->escapeLocalURL();
391
392 $qb = wfMsg( 'qbsettings' );
393 $cp = wfMsg( 'changepassword' );
394 $sk = wfMsg( 'skin' );
395 $math = wfMsg( 'math' );
396 $dateFormat = wfMsg('dateformat');
397 $opw = wfMsg( 'oldpassword' );
398 $npw = wfMsg( 'newpassword' );
399 $rpw = wfMsg( 'retypenew' );
400 $svp = wfMsg( 'saveprefs' );
401 $rsp = wfMsg( 'resetprefs' );
402 $tbs = wfMsg( 'textboxsize' );
403 $tbr = wfMsg( 'rows' );
404 $tbc = wfMsg( 'columns' );
405 $ltz = wfMsg( 'localtime' );
406 $timezone = wfMsg( 'timezonelegend' );
407 $tzt = wfMsg( 'timezonetext' );
408 $tzo = wfMsg( 'timezoneoffset' );
409 $tzGuess = wfMsg( 'guesstimezone' );
410 $tzServerTime = wfMsg( 'servertime' );
411 $yem = wfMsg( 'youremail' );
412 $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
413 $yl = wfMsg( 'yourlanguage' );
414 $yv = wfMsg( 'yourvariant' );
415 $emf = wfMsg( 'emailflag' );
416 $ynn = wfMsg( 'yournick' );
417 $stt = wfMsg ( 'stubthreshold' ) ;
418 $srh = wfMsg( 'searchresultshead' );
419 $rpp = wfMsg( 'resultsperpage' );
420 $scl = wfMsg( 'contextlines' );
421 $scc = wfMsg( 'contextchars' );
422 $rcc = wfMsg( 'recentchangescount' );
423 $dsn = wfMsg( 'defaultns' );
424
425 $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
426 method=\"post\">" );
427
428 # First section: identity
429 # Email, etc.
430 #
431 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
432 $this->mRealName = htmlspecialchars( $this->mRealName );
433 $this->mNick = htmlspecialchars( $this->mNick );
434 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
435 else { $emfc = ''; }
436
437 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
438 if ($wgUser->getEmailAuthenticationtimestamp() != 0) {
439 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationtimestamp(), true ) ).'<br />';
440 $disabled = '';
441 } else {
442 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />';
443 $disabled = ' '.wfMsg('disableduntilauthent');
444 }
445 } else {
446 $emailauthenticated = '';
447 }
448
449 if ($this->mUserEmail == '') {
450 $disabled = ' '.wfMsg('disablednoemail');
451 }
452
453 $ps = $this->namespacesCheckboxes();
454
455 $enotifwatchlistpages = ($wgEmailNotificationForWatchlistPages) ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
456 $enotifusertalkpages = ($wgEmailNotificationForUserTalkPages) ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
457 $enotifminoredits = ($wgEmailNotificationForMinorEdits) ? $this->getToggle( 'enotifminoredits', $disabled) : '';
458 $enotifrevealaddr = ($wgEmailNotificationRevealPageEditorAddress) ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
459 $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
460 $prefs_help_realname = '';
461
462 $wgOut->addHTML( "<fieldset>
463 <legend>".wfMsg('prefs-personal')."</legend>");
464
465 if ($wgAllowRealName) {
466 $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
467 $prefs_help_realname = wfMsg('prefs-help-realname').'<br />';
468 }
469
470 if( $wgEnableEmail ) {
471 $wgOut->addHTML("
472 <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>" );
473 if( $wgEnableUserEmail ) {
474 $wgOut->addHTML(
475 $emailauthenticated.
476 $enotifrevealaddr.
477 $enotifwatchlistpages.
478 $enotifusertalkpages.
479 $enotifminoredits.
480 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf.$disabled</label></div>" );
481 }
482 }
483
484 $fancysig = $this->getToggle( 'fancysig' );
485 $wgOut->addHTML("
486 <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='25' /></label></div>
487 <div>$fancysig<br /></div>
488 <div><label>$yl: <select name=\"wpUserLanguage\">\n");
489
490 /**
491 * If a bogus value is set, default to the content language.
492 * Otherwise, no default is selected and the user ends up
493 * with an Afrikaans interface since it's first in the list.
494 */
495 if( isset( $wgLanguageNames[$this->mUserLanguage] ) ) {
496 $selectedLang = $this->mUserLanguage;
497 } else {
498 $selectedLang = $wgContLanguageCode;
499 }
500 foreach($wgLanguageNames as $code => $name) {
501 global $IP;
502 /* only add languages that have a file */
503 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
504 if(file_exists($langfile) || $code == $wgContLanguageCode) {
505 $sel = ($code == $selectedLang)? 'selected="selected"' : '';
506 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
507 }
508 }
509 $wgOut->addHtml("</select></label></div>\n" );
510
511 /* see if there are multiple language variants to choose from*/
512 if(!$wgDisableLangConversion) {
513 $variants = $wgContLang->getVariants();
514 $size=sizeof($variants);
515
516 $variantArray=array();
517 foreach($variants as $v) {
518 $v = str_replace( '_', '-', strtolower($v));
519 if($name=$wgLanguageNames[$v]) {
520 $variantArray[$v] = $name;
521 }
522 }
523 $size=sizeof($variantArray);
524
525 if(sizeof($variantArray) > 1) {
526 $wgOut->addHtml("
527 <div><label>$yv: <select name=\"wpUserVariant\">\n");
528 foreach($variantArray as $code => $name) {
529 $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
530 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
531 }
532 }
533 }
534 # Fields for changing password
535 #
536 $this->mOldpass = htmlspecialchars( $this->mOldpass );
537 $this->mNewpass = htmlspecialchars( $this->mNewpass );
538 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
539
540 $wgOut->addHTML( "<fieldset>
541 <legend>$cp</legend>
542 <div><label>$opw: <input type='password' name=\"wpOldpass\" value=\"{$this->mOldpass}\" size='20' /></label></div>
543 <div><label>$npw: <input type='password' name=\"wpNewpass\" value=\"{$this->mNewpass}\" size='20' /></label></div>
544 <div><label>$rpw: <input type='password' name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size='20' /></label></div>
545 " . $this->getToggle( "rememberpassword" ) . "
546 </fieldset>
547 <div class='prefsectiontip'>".$prefs_help_realname.wfMsg('prefs-help-email').$prefs_help_email_enotif."</div>\n</fieldset>\n" );
548
549
550 # Quickbar setting
551 #
552 $wgOut->addHtml( "<fieldset>\n<legend>$qb</legend>\n" );
553 for ( $i = 0; $i < count( $qbs ); ++$i ) {
554 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
555 else { $checked = ""; }
556 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpQuickbar\"
557 value=\"$i\"$checked /> {$qbs[$i]}</label></div>\n" );
558 }
559 $wgOut->addHtml('<div class="prefsectiontip">'.wfMsg('qbsettingsnote').'</div>');
560 $wgOut->addHtml( "</fieldset>\n\n" );
561
562 # Skin setting
563 #
564 $wgOut->addHTML( "<fieldset>\n<legend>$sk</legend>\n" );
565 # Only show members of $wgValidSkinNames rather than
566 # $skinNames (skins is all skin names from Language.php)
567 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
568 if ( $skinkey == $this->mSkin ) {
569 $checked = ' checked="checked"';
570 } else {
571 $checked = '';
572 }
573 if ( isset( $skinNames[$skinkey] ) ) {
574 $sn = $skinNames[$skinkey];
575 } else {
576 $sn = $skinname;
577 }
578 global $wgDefaultSkin;
579 if( $skinkey == $wgDefaultSkin ) {
580 $sn .= ' (' . wfMsg( 'default' ) . ')';
581 }
582 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpSkin\"
583 value=\"$skinkey\"$checked /> {$sn}</label></div>\n" );
584 }
585 $wgOut->addHTML( "</fieldset>\n\n" );
586
587 # Math setting
588 #
589 $wgOut->addHTML( "<fieldset>\n<legend>$math</legend>\n" );
590 for ( $i = 0; $i < count( $mathopts ); ++$i ) {
591 if ( $i == $this->mMath ) { $checked = ' checked="checked"'; }
592 else { $checked = ""; }
593 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpMath\"
594 value=\"$i\"$checked /> ".wfMsg($mathopts[$i])."</label></div>\n" );
595 }
596 $wgOut->addHTML( "</fieldset>\n\n" );
597
598 # Date format
599 #
600 if ( $wgUseDynamicDates ) {
601 $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
602 for ( $i = 0; $i < count( $dateopts ); ++$i) {
603 if ( $i == $this->mDate ) {
604 $checked = ' checked="checked"';
605 } else {
606 $checked = "";
607 }
608 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
609 "value=\"$i\"$checked /> {$dateopts[$i]}</label></div>\n" );
610 }
611 $wgOut->addHTML( "</fieldset>\n\n");
612 }
613
614 # Textbox rows, cols
615 #
616 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
617 $nowserver = $wgLang->time( $now, false );
618 $wgOut->addHTML( "<fieldset>
619 <legend>$tbs</legend>\n
620 <div>
621 <label>$tbr: <input type='text' name=\"wpRows\" value=\"{$this->mRows}\" size='6' /></label>
622 <label>$tbc: <input type='text' name=\"wpCols\" value=\"{$this->mCols}\" size='6' /></label>
623 </div> " .
624 $this->getToggle( "editwidth" ) .
625 $this->getToggle( "showtoolbar" ) .
626 $this->getToggle( "previewonfirst" ) .
627 $this->getToggle( "previewontop" ) .
628 $this->getToggle( "watchdefault" ) .
629 $this->getToggle( "minordefault" ) . "
630 </fieldset>
631
632 <fieldset>
633 <legend>$timezone</legend>
634 <div><b>$tzServerTime:</b> $nowserver</div>
635 <div><b>$ltz:</b> $nowlocal</div>
636 <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' /></label></div>
637 <div><input type=\"button\" value=\"$tzGuess\" onclick=\"javascript:guessTimezone()\" id=\"guesstimezonebutton\" style=\"display:none\" /></div>
638 <div class='prefsectiontip'>* {$tzt}</div>
639 </fieldset>\n\n" );
640
641 $shownumberswatching = ($wgRCShowWatchingUsers) ? $this->getToggle('shownumberswatching') : '';
642
643 $wgOut->addHTML( "
644 <fieldset><legend>".wfMsg('prefs-rc')."</legend>
645 <div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>" .
646 $this->getToggle( "hideminor" ) . $shownumberswatching .
647 $this->getToggle( "usenewrc" ) . $this->getToggle('showupdated', wfMsg('updatedmarker')) .
648 "<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
649 <div><label>".wfMsg('imagemaxsize')."<select name=\"wpImageSize\">");
650
651 $imageLimitOptions='';
652 foreach ( $wgImageLimits as $index => $limits ) {
653 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
654 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
655 }
656 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
657
658 </fieldset>
659
660 <fieldset>
661 <legend>$srh</legend>
662 <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
663 <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
664 <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
665
666 <fieldset>
667 <legend>$dsn</legend>
668 $ps
669 </fieldset>
670 </fieldset>
671 " );
672
673 # Various checkbox options
674 #
675 $wgOut->addHTML("<fieldset><legend>".wfMsg('prefs-misc')."</legend>");
676 foreach ( $togs as $tname ) {
677 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
678 $wgOut->addHTML( $this->getToggle( $tname ) );
679 }
680 }
681 $wgOut->addHTML( "</fieldset>\n\n" );
682
683 $wgOut->addHTML( "
684 <div id='prefsubmit'>
685 <div>
686 <input type='submit' name=\"wpSaveprefs\" value=\"$svp\" accesskey=\"".
687 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
688 <input type='submit' name=\"wpReset\" value=\"$rsp\" />
689 </div>
690
691 </div>
692
693 </form>\n" );
694 }
695 }
696 ?>