3 * Hold things related to displaying and saving user preferences.
5 * @subpackage SpecialPage
8 if( !defined( 'MEDIAWIKI' ) )
12 * Entry point that create the "Preferences" object
14 function wfSpecialPreferences() {
17 $form = new PreferencesForm( $wgRequest );
22 * Preferences form handling
23 * This object will show the preferences form and can save it as well.
25 * @subpackage SpecialPage
27 class PreferencesForm
{
28 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
29 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
30 var $mUserLanguage, $mUserVariant;
31 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
32 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
39 function PreferencesForm( &$request ) {
40 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
42 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
43 $this->mOldpass
= $request->getVal( 'wpOldpass' );
44 $this->mNewpass
= $request->getVal( 'wpNewpass' );
45 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
46 $this->mStubs
= $request->getVal( 'wpStubs' );
47 $this->mRows
= $request->getVal( 'wpRows' );
48 $this->mCols
= $request->getVal( 'wpCols' );
49 $this->mSkin
= $request->getVal( 'wpSkin' );
50 $this->mMath
= $request->getVal( 'wpMath' );
51 $this->mDate
= $request->getVal( 'wpDate' );
52 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
53 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
54 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
1 : 0;
55 $this->mNick
= $request->getVal( 'wpNick' );
56 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
57 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
58 $this->mSearch
= $request->getVal( 'wpSearch' );
59 $this->mRecent
= $request->getVal( 'wpRecent' );
60 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
61 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
62 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
63 $this->mImageSize
= $request->getVal( 'wpImageSize' );
64 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
65 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
66 $this->mAction
= $request->getVal( 'action' );
67 $this->mReset
= $request->getCheck( 'wpReset' );
68 $this->mPosted
= $request->wasPosted();
69 $this->mSuccess
= $request->getCheck( 'success' );
71 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
73 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
75 # User toggles (the big ugly unsorted list of checkboxes)
76 $this->mToggles
= array();
77 if ( $this->mPosted
) {
78 $togs = $wgLang->getUserToggles();
79 foreach ( $togs as $tname ) {
80 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
84 $this->mUsedToggles
= array();
86 # Search namespace options
87 # Note: namespaces don't necessarily have consecutive keys
88 $this->mSearchNs
= array();
89 if ( $this->mPosted
) {
90 $namespaces = $wgContLang->getNamespaces();
91 foreach ( $namespaces as $i => $namespace ) {
93 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
99 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
100 $this->mUserLanguage
= 'nolanguage';
105 global $wgUser, $wgOut;
107 if ( $wgUser->isAnon() ) {
108 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
111 if ( wfReadOnly() ) {
112 $wgOut->readOnlyPage();
115 if ( $this->mReset
) {
117 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
118 } else if ( $this->mSaveprefs
) {
119 $this->savePreferences();
122 $this->mainPrefsForm( '' );
128 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
130 $val = min($val, $max);
131 $val = max($val, $min);
138 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
143 return $this->validateInt( $val, $min, $max );
150 function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
151 if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) ||
$val == 'ISO 8601' )
158 * Used to validate the user inputed timezone before saving it as
159 * 'timeciorrection', will return '00:00' if fed bogus data.
160 * Note: It's not a 100% correct implementation timezone-wise, it will
161 * accept stuff like '14:30',
163 * @param string $s the user input
166 function validateTimeZone( $s ) {
168 if ( strpos( $s, ':' ) ) {
170 $array = explode( ':' , $s );
171 $hour = intval( $array[0] );
172 $minute = intval( $array[1] );
174 $minute = intval( $s * 60 );
175 $hour = intval( $minute / 60 );
176 $minute = abs( $minute ) %
60;
178 # Max is +14:00 and min is -12:00, see:
179 # http://en.wikipedia.org/wiki/Timezone
180 $hour = min( $hour, 14 );
181 $hour = max( $hour, -12 );
182 $minute = min( $minute, 59 );
183 $minute = max( $minute, 0 );
184 $s = sprintf( "%02d:%02d", $hour, $minute );
192 function savePreferences() {
193 global $wgUser, $wgLang, $wgOut;
194 global $wgEnableUserEmail, $wgEnableEmail;
195 global $wgEmailAuthentication, $wgMinimalPasswordLength;
199 if ( '' != $this->mNewpass
) {
200 if ( $this->mNewpass
!= $this->mRetypePass
) {
201 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
205 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
206 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
210 if (!$wgUser->checkPassword( $this->mOldpass
)) {
211 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
214 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
215 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
218 $wgUser->setPassword( $this->mNewpass
);
219 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
222 $wgUser->setRealName( $this->mRealName
);
224 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
225 $needRedirect = true;
227 $needRedirect = false;
230 $wgUser->setOption( 'language', $this->mUserLanguage
);
231 $wgUser->setOption( 'variant', $this->mUserVariant
);
232 $wgUser->setOption( 'nickname', $this->mNick
);
233 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
234 $wgUser->setOption( 'skin', $this->mSkin
);
237 $wgUser->setOption( 'math', $this->mMath
);
239 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
240 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
241 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
242 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
243 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
244 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
245 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
246 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
247 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
248 $wgUser->setOption( 'imagesize', $this->mImageSize
);
249 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
250 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
252 # Set search namespace options
253 foreach( $this->mSearchNs
as $i => $value ) {
254 $wgUser->setOption( "searchNs{$i}", $value );
257 if( $wgEnableEmail && $wgEnableUserEmail ) {
258 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
262 foreach ( $this->mToggles
as $tname => $tvalue ) {
263 $wgUser->setOption( $tname, $tvalue );
265 if (!$wgAuth->updateExternalDB($wgUser)) {
266 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
269 $wgUser->setCookies();
270 $wgUser->saveSettings();
273 if( $wgEnableEmail ) {
274 $newadr = $this->mUserEmail
;
275 $oldadr = $wgUser->getEmail();
276 if( ($newadr != '') && ($newadr != $oldadr) ) {
277 # the user has supplied a new email address on the login page
278 if( $wgUser->isValidEmailAddr( $newadr ) ) {
279 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
280 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
281 $wgUser->saveSettings();
282 if ($wgEmailAuthentication) {
283 # Mail a temporary password to the dirty address.
284 # User can come back through the confirmation URL to re-enable email.
285 $result = $wgUser->sendConfirmationMail();
286 if( WikiError
::isError( $result ) ) {
287 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
289 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
293 $error = wfMsg( 'invalidemailaddress' );
296 $wgUser->setEmail( $this->mUserEmail
);
297 $wgUser->setCookies();
298 $wgUser->saveSettings();
302 if( $needRedirect && $error === false ) {
303 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
304 $wgOut->redirect($title->getFullURL('success'));
308 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
309 $po = ParserOptions
::newFromUser( $wgUser );
310 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
316 function resetPrefs() {
317 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
319 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
320 $this->mUserEmail
= $wgUser->getEmail();
321 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
322 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
323 $this->mUserLanguage
= $wgUser->getOption( 'language' );
324 if( empty( $this->mUserLanguage
) ) {
325 # Quick hack for conversions, where this value is blank
326 global $wgContLanguageCode;
327 $this->mUserLanguage
= $wgContLanguageCode;
329 $this->mUserVariant
= $wgUser->getOption( 'variant');
330 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
331 $this->mNick
= $wgUser->getOption( 'nickname' );
333 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
334 $this->mSkin
= $wgUser->getOption( 'skin' );
335 $this->mMath
= $wgUser->getOption( 'math' );
336 $this->mDate
= $wgUser->getOption( 'date' );
337 $this->mRows
= $wgUser->getOption( 'rows' );
338 $this->mCols
= $wgUser->getOption( 'cols' );
339 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
340 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
341 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
342 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
343 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
344 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
345 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
346 $this->mRecent
= $wgUser->getOption( 'rclimit' );
347 $this->mUnderline
= $wgUser->getOption( 'underline' );
349 $togs = $wgLang->getUserToggles();
350 foreach ( $togs as $tname ) {
351 $ttext = wfMsg('tog-'.$tname);
352 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
355 $namespaces = $wgContLang->getNamespaces();
356 foreach ( $namespaces as $i => $namespace ) {
357 if ( $i >= NS_MAIN
) {
358 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
366 function namespacesCheckboxes() {
367 global $wgContLang, $wgUser;
369 # Determine namespace checkboxes
370 $namespaces = $wgContLang->getNamespaces();
373 foreach ( $namespaces as $i => $name ) {
376 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
377 $name = str_replace( '_', ' ', $namespaces[$i] );
380 $name = wfMsg( 'blanknamespace' );
382 $r1 .= "<label><input type='checkbox' value='1' name='wpNs$i' {$checked}/>{$name}</label>\n";
388 function getToggle( $tname, $trailer = false) {
389 global $wgUser, $wgLang;
391 $this->mUsedToggles
[$tname] = true;
392 $ttext = $wgLang->getUserToggle( $tname );
394 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
395 $trailer = $trailer ?
$trailer : '';
396 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
397 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
400 function getToggles( $items ) {
402 foreach( $items as $item ) {
403 if( $item === false )
405 if( is_array( $item ) ) {
406 list( $key, $trailer ) = $item;
411 $out .= $this->getToggle( $key, $trailer );
416 function addRow($td1, $td2) {
417 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
423 function mainPrefsForm( $status , $message = '' ) {
424 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
425 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
426 global $wgDisableLangConversion;
427 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
428 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
429 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
430 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
432 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
433 $wgOut->setArticleRelated( false );
434 $wgOut->setRobotpolicy( 'noindex,nofollow' );
436 if ( $this->mSuccess ||
'success' == $status ) {
437 $wgOut->addWikitext( '<span class="preferences-save-success">'. wfMsg( 'savedprefs' ) . "</span>\n----" );
438 } else if ( 'error' == $status ) {
439 $wgOut->addWikitext( "<span class='error'>" . $message . "</span>\n----" );
440 } else if ( '' != $status ) {
441 $wgOut->addWikitext( $message . "\n----" );
443 $uname = $wgUser->getName();
444 $uid = $wgUser->getID();
446 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
447 $wgOut->addWikiText( wfMsg('clearyourcache'));
449 $qbs = $wgLang->getQuickbarSettings();
450 $skinNames = $wgLang->getSkinNames();
451 $mathopts = $wgLang->getMathNames();
452 $dateopts = $wgLang->getDateFormats();
453 $togs = $wgLang->getUserToggles();
455 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
456 $action = $titleObj->escapeLocalURL();
458 # Pre-expire some toggles so they won't show if disabled
459 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
460 $this->mUsedToggles
[ 'showupdated' ] = true;
461 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
462 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
463 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
464 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
468 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
469 $this->mRealName
= htmlspecialchars( $this->mRealName
);
470 $this->mNick
= htmlspecialchars( $this->mNick
);
471 if ( $this->mEmailFlag
) { $emfc = 'checked="checked"'; }
474 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
475 if( $wgUser->getEmailAuthenticationTimestamp() ) {
476 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
478 $skin = $wgUser->getSkin();
479 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
480 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
481 wfMsg( 'emailconfirmlink' ) );
484 $emailauthenticated = '';
487 if ($this->mUserEmail
== '') {
488 $emailauthenticated = wfMsg( 'noemailprefs' );
491 $ps = $this->namespacesCheckboxes();
493 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages' ) : '';
494 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages' ) : '';
495 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits' ) : '';
496 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr' ) : '';
497 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
498 $prefs_help_realname = '';
502 $wgOut->addHTML( "<form id='preferences' name='preferences' action=\"$action\" method='post'>" );
507 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
509 if ($wgAllowRealName) {
512 wfMsg('yourrealname'),
513 "<input type='text' name='wpRealName' value=\"{$this->mRealName}\" size='25' />"
517 if ($wgEnableEmail) {
520 wfMsg( 'youremail' ),
521 "<input type='text' name='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
529 "<input type='text' name='wpNick' value=\"{$this->mNick}\" size='25' />"
531 # FIXME: The <input> part should be where the is, getToggle() needs
532 # to be changed to out return its output in two parts. -ævar
535 $this->getToggle( 'fancysig' )
540 * If a bogus value is set, default to the content language.
541 * Otherwise, no default is selected and the user ends up
542 * with an Afrikaans interface since it's first in the list.
544 $languages = $wgLang->getLanguageNames();
545 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
547 foreach($languages as $code => $name) {
549 /* only add languages that have a file */
550 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
551 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
552 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
553 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
556 $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "<select name='wpUserLanguage'>$selbox</select>" ));
558 /* see if there are multiple language variants to choose from*/
559 if(!$wgDisableLangConversion) {
560 $variants = $wgContLang->getVariants();
562 foreach($variants as $v) {
563 $v = str_replace( '_', '-', strtolower($v));
564 if($name = $languages[$v]) {
565 $variantArray[$v] = $name;
570 foreach($variantArray as $code => $name) {
571 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
572 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
575 if(count($variantArray) > 1) {
577 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
581 $wgOut->addHTML('</table>');
584 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
585 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
586 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
588 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
590 $this->addRow( wfMsg( 'oldpassword' ), "<input type='password' name='wpOldpass' value=\"{$this->mOldpass}\" size='20' />" ) .
591 $this->addRow( wfMsg( 'newpassword' ), "<input type='password' name='wpNewpass' value=\"{$this->mNewpass}\" size='20' />" ) .
592 $this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
594 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
598 if ($wgEnableEmail) {
599 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
603 $enotifwatchlistpages.
604 $enotifusertalkpages.
606 if ($wgEnableUserEmail) {
607 $emf = wfMsg( 'emailflag' );
609 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
612 $wgOut->addHTML( '</fieldset>' );
616 if ($wgAllowRealName ||
$wgEnableEmail) {
617 $wgOut->addHTML("<div class='prefsectiontip'>");
618 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
619 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
620 $wgOut->addHTML( $rn . $em . '</div>');
623 $wgOut->addHTML( '</fieldset>' );
627 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
628 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
629 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
630 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
631 else { $checked = ""; }
632 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
634 $wgOut->addHtml( "</fieldset>\n\n" );
636 # Need to output a hidden option even if the relevant skin is not in use,
637 # otherwise the preference will get reset to 0 on submit
638 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
643 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
644 $mptitle = Title
::newMainPage();
645 $previewtext = wfMsg('skinpreview');
646 # Only show members of $wgValidSkinNames rather than
647 # $skinNames (skins is all skin names from Language.php)
648 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
649 if ( in_array( $skinkey, $wgSkipSkins ) ) {
652 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
653 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
655 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
656 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
657 if( $skinkey == $wgDefaultSkin )
658 $sn .= ' (' . wfMsg( 'default' ) . ')';
659 $wgOut->addHTML( "<input type='radio' name='wpSkin' value=\"$skinkey\"$checked /> {$sn} $previewlink<br/>\n" );
661 $wgOut->addHTML( "</fieldset>\n\n" );
667 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
668 foreach ( $mathopts as $k => $v ) {
669 $checked = $k == $this->mMath ?
' checked="checked"' : '';
670 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
672 $wgOut->addHTML( "</fieldset>\n\n" );
677 $wgOut->addHTML("<fieldset>
678 <legend>" . wfMsg( 'files' ) . "</legend>
679 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
681 $imageLimitOptions = null;
682 foreach ( $wgImageLimits as $index => $limits ) {
683 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
684 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}×{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
687 $imageThumbOptions = null;
688 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
689 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
690 foreach ( $wgThumbLimits as $index => $size ) {
691 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
692 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
694 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
699 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n" );
700 foreach($dateopts as $key => $option) {
701 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
702 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
703 "value=\"$key\"$checked />$option</label></div>\n" );
705 $wgOut->addHTML( "</fieldset>\n\n");
711 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
712 $nowserver = $wgLang->time( $now, false );
714 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ) . '</legend><table>' .
715 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
716 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
718 wfMsg( 'timezoneoffset' ),
719 "<input type='text' name='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
720 ) . "<tr><td colspan='2'>
721 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
722 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
724 <div class='prefsectiontip'>¹" . wfMsg( 'timezonetext' ) . "</div>
729 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
731 <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
732 <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
734 $this->getToggles( array(
736 'editsectiononrightclick',
749 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
752 wfMsg ( 'stubthreshold' ),
753 "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
756 wfMsg( 'recentchangescount' ),
757 "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
760 $this->getToggles( array(
762 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
767 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
768 $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
769 $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
770 $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
771 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
775 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
777 $msgUnderline = htmlspecialchars(wfMsg("tog-underline"));
778 $msgUnderlinenever = htmlspecialchars(wfMsg("underline-never"));
779 $msgUnderlinealways = htmlspecialchars(wfMsg("underline-always"));
780 $msgUnderlinedefault = htmlspecialchars(wfMsg("underline-default"));
781 $uopt = $wgUser->getOption("underline");
782 $s0 = $uopt == 0 ?
" selected=\"selected\"" : "";
783 $s1 = $uopt == 1 ?
" selected=\"selected\"" : "";
784 $s2 = $uopt == 2 ?
" selected=\"selected\"" : "";
786 <div class='toggle'><label>$msgUnderline
787 <select name=\"wpOpunderline\">
788 <option value=\"0\"$s0>$msgUnderlinenever</option>
789 <option value=\"1\"$s1>$msgUnderlinealways</option>
790 <option value=\"2\"$s2>$msgUnderlinedefault</option>
795 foreach ( $togs as $tname ) {
796 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
797 $wgOut->addHTML( $this->getToggle( $tname ) );
800 $wgOut->addHTML( '</fieldset>' );
802 $token = $wgUser->editToken();
804 <div id='prefsubmit'>
806 <input type='submit' name='wpSaveprefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
807 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
808 <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
813 <input type='hidden' name='wpEditToken' value='{$token}' />