3 * Hold things related to displaying and saving user preferences.
5 * @subpackage SpecialPage
9 * Entry point that create the "Preferences" object
11 function wfSpecialPreferences() {
14 $form = new PreferencesForm( $wgRequest );
19 * Preferences form handling
20 * This object will show the preferences form and can save it as well.
22 * @subpackage SpecialPage
24 class PreferencesForm
{
61 function PreferencesForm( &$request ) {
62 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
64 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
65 $this->mOldpass
= $request->getVal( 'wpOldpass' );
66 $this->mNewpass
= $request->getVal( 'wpNewpass' );
67 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
68 $this->mStubs
= $request->getVal( 'wpStubs' );
69 $this->mRows
= $request->getVal( 'wpRows' );
70 $this->mCols
= $request->getVal( 'wpCols' );
71 $this->mSkin
= $request->getVal( 'wpSkin' );
72 $this->mMath
= $request->getVal( 'wpMath' );
73 $this->mDate
= $request->getVal( 'wpDate' );
74 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
75 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
76 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
0 : 1;
77 $this->mNick
= $request->getVal( 'wpNick' );
78 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
79 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
80 $this->mSearch
= $request->getVal( 'wpSearch' );
81 $this->mRecent
= $request->getVal( 'wpRecent' );
82 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
83 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
84 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
85 $this->mImageSize
= $request->getVal( 'wpImageSize' );
86 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
87 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
88 $this->mAction
= $request->getVal( 'action' );
89 $this->mReset
= $request->getCheck( 'wpReset' );
90 $this->mPosted
= $request->wasPosted();
91 $this->mSuccess
= $request->getCheck( 'success' );
92 $this->mWatchlistDays
= $request->getVal( 'wpWatchlistDays' );
93 $this->mWatchlistEdits
= $request->getVal( 'wpWatchlistEdits' );
95 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
97 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
99 # User toggles (the big ugly unsorted list of checkboxes)
100 $this->mToggles
= array();
101 if ( $this->mPosted
) {
102 $togs = $wgLang->getUserToggles();
103 foreach ( $togs as $tname ) {
104 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
108 $this->mUsedToggles
= array();
110 # Search namespace options
111 # Note: namespaces don't necessarily have consecutive keys
112 $this->mSearchNs
= array();
113 if ( $this->mPosted
) {
114 $namespaces = $wgContLang->getNamespaces();
115 foreach ( $namespaces as $i => $namespace ) {
117 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
123 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
124 $this->mUserLanguage
= 'nolanguage';
129 global $wgUser, $wgOut;
131 if ( $wgUser->isAnon() ) {
132 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
135 if ( wfReadOnly() ) {
136 $wgOut->readOnlyPage();
139 if ( $this->mReset
) {
141 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
142 } else if ( $this->mSaveprefs
) {
143 $this->savePreferences();
146 $this->mainPrefsForm( '' );
152 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
154 $val = min($val, $max);
155 $val = max($val, $min);
162 function validateFloat( &$val, $min, $max=0x7fffffff ) {
163 $val = floatval( $val );
164 $val = min( $val, $max );
165 $val = max( $val, $min );
172 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
177 return $this->validateInt( $val, $min, $max );
184 function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
185 if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) ||
$val == 'ISO 8601' )
192 * Used to validate the user inputed timezone before saving it as
193 * 'timeciorrection', will return '00:00' if fed bogus data.
194 * Note: It's not a 100% correct implementation timezone-wise, it will
195 * accept stuff like '14:30',
197 * @param string $s the user input
200 function validateTimeZone( $s ) {
202 if ( strpos( $s, ':' ) ) {
204 $array = explode( ':' , $s );
205 $hour = intval( $array[0] );
206 $minute = intval( $array[1] );
208 $minute = intval( $s * 60 );
209 $hour = intval( $minute / 60 );
210 $minute = abs( $minute ) %
60;
212 # Max is +14:00 and min is -12:00, see:
213 # http://en.wikipedia.org/wiki/Timezone
214 $hour = min( $hour, 14 );
215 $hour = max( $hour, -12 );
216 $minute = min( $minute, 59 );
217 $minute = max( $minute, 0 );
218 $s = sprintf( "%02d:%02d", $hour, $minute );
226 function savePreferences() {
227 global $wgUser, $wgOut, $wgParser;
228 global $wgEnableUserEmail, $wgEnableEmail;
229 global $wgEmailAuthentication, $wgMinimalPasswordLength;
233 if ( '' != $this->mNewpass
) {
234 if ( $this->mNewpass
!= $this->mRetypePass
) {
235 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
239 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
240 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
244 if (!$wgUser->checkPassword( $this->mOldpass
)) {
245 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
248 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
249 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
252 $wgUser->setPassword( $this->mNewpass
);
253 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
256 $wgUser->setRealName( $this->mRealName
);
258 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
259 $needRedirect = true;
261 $needRedirect = false;
264 # Validate the signature and clean it up as needed
265 if( $this->mToggles
['fancysig'] ) {
266 if( Parser
::validateSig( $this->mNick
) !== false ) {
267 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
269 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
273 $wgUser->setOption( 'language', $this->mUserLanguage
);
274 $wgUser->setOption( 'variant', $this->mUserVariant
);
275 $wgUser->setOption( 'nickname', $this->mNick
);
276 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
277 $wgUser->setOption( 'skin', $this->mSkin
);
280 $wgUser->setOption( 'math', $this->mMath
);
282 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
283 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
284 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
285 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
286 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
287 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
288 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
289 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
290 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
291 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
292 $wgUser->setOption( 'imagesize', $this->mImageSize
);
293 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
294 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
295 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
297 # Set search namespace options
298 foreach( $this->mSearchNs
as $i => $value ) {
299 $wgUser->setOption( "searchNs{$i}", $value );
302 if( $wgEnableEmail && $wgEnableUserEmail ) {
303 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
307 foreach ( $this->mToggles
as $tname => $tvalue ) {
308 $wgUser->setOption( $tname, $tvalue );
310 if (!$wgAuth->updateExternalDB($wgUser)) {
311 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
314 $wgUser->setCookies();
315 $wgUser->saveSettings();
318 if( $wgEnableEmail ) {
319 $newadr = $this->mUserEmail
;
320 $oldadr = $wgUser->getEmail();
321 if( ($newadr != '') && ($newadr != $oldadr) ) {
322 # the user has supplied a new email address on the login page
323 if( $wgUser->isValidEmailAddr( $newadr ) ) {
324 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
325 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
326 $wgUser->saveSettings();
327 if ($wgEmailAuthentication) {
328 # Mail a temporary password to the dirty address.
329 # User can come back through the confirmation URL to re-enable email.
330 $result = $wgUser->sendConfirmationMail();
331 if( WikiError
::isError( $result ) ) {
332 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
334 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
338 $error = wfMsg( 'invalidemailaddress' );
341 $wgUser->setEmail( $this->mUserEmail
);
342 $wgUser->setCookies();
343 $wgUser->saveSettings();
347 if( $needRedirect && $error === false ) {
348 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
349 $wgOut->redirect($title->getFullURL('success'));
353 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
354 $po = ParserOptions
::newFromUser( $wgUser );
355 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
361 function resetPrefs() {
362 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
364 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
365 $this->mUserEmail
= $wgUser->getEmail();
366 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
367 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
368 $this->mUserLanguage
= $wgUser->getOption( 'language' );
369 if( empty( $this->mUserLanguage
) ) {
370 # Quick hack for conversions, where this value is blank
371 global $wgContLanguageCode;
372 $this->mUserLanguage
= $wgContLanguageCode;
374 $this->mUserVariant
= $wgUser->getOption( 'variant');
375 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
376 $this->mNick
= $wgUser->getOption( 'nickname' );
378 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
379 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
380 $this->mMath
= $wgUser->getOption( 'math' );
381 $this->mDate
= $wgUser->getOption( 'date' );
382 $this->mRows
= $wgUser->getOption( 'rows' );
383 $this->mCols
= $wgUser->getOption( 'cols' );
384 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
385 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
386 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
387 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
388 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
389 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
390 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
391 $this->mRecent
= $wgUser->getOption( 'rclimit' );
392 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
393 $this->mUnderline
= $wgUser->getOption( 'underline' );
394 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
396 $togs = $wgLang->getUserToggles();
397 foreach ( $togs as $tname ) {
398 $ttext = wfMsg('tog-'.$tname);
399 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
402 $namespaces = $wgContLang->getNamespaces();
403 foreach ( $namespaces as $i => $namespace ) {
404 if ( $i >= NS_MAIN
) {
405 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
413 function namespacesCheckboxes() {
416 # Determine namespace checkboxes
417 $namespaces = $wgContLang->getNamespaces();
420 foreach ( $namespaces as $i => $name ) {
423 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
424 $name = str_replace( '_', ' ', $namespaces[$i] );
427 $name = wfMsg( 'blanknamespace' );
429 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
435 function getToggle( $tname, $trailer = false, $disabled = false ) {
436 global $wgUser, $wgLang;
438 $this->mUsedToggles
[$tname] = true;
439 $ttext = $wgLang->getUserToggle( $tname );
441 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
442 $disabled = $disabled ?
' disabled="disabled"' : '';
443 $trailer = $trailer ?
$trailer : '';
444 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
445 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
448 function getToggles( $items ) {
450 foreach( $items as $item ) {
451 if( $item === false )
453 if( is_array( $item ) ) {
454 list( $key, $trailer ) = $item;
459 $out .= $this->getToggle( $key, $trailer );
464 function addRow($td1, $td2) {
465 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
471 function mainPrefsForm( $status , $message = '' ) {
472 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
473 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
474 global $wgDisableLangConversion;
475 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
476 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
477 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
478 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
480 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
481 $wgOut->setArticleRelated( false );
482 $wgOut->setRobotpolicy( 'noindex,nofollow' );
484 if ( $this->mSuccess ||
'success' == $status ) {
485 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
486 } else if ( 'error' == $status ) {
487 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
488 } else if ( '' != $status ) {
489 $wgOut->addWikitext( $message . "\n----" );
492 $qbs = $wgLang->getQuickbarSettings();
493 $skinNames = $wgLang->getSkinNames();
494 $mathopts = $wgLang->getMathNames();
495 $dateopts = $wgLang->getDateFormats();
496 $togs = $wgLang->getUserToggles();
498 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
499 $action = $titleObj->escapeLocalURL();
501 # Pre-expire some toggles so they won't show if disabled
502 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
503 $this->mUsedToggles
[ 'showupdated' ] = true;
504 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
505 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
506 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
507 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
508 $this->mUsedToggles
[ 'uselivepreview' ] = true;
512 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
513 $this->mRealName
= htmlspecialchars( $this->mRealName
);
514 $rawNick = $this->mNick
;
515 $this->mNick
= htmlspecialchars( $this->mNick
);
516 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
520 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
521 if( $wgUser->getEmailAuthenticationTimestamp() ) {
522 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
523 $disableEmailPrefs = false;
525 $disableEmailPrefs = true;
526 $skin = $wgUser->getSkin();
527 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
528 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
529 wfMsg( 'emailconfirmlink' ) );
532 $emailauthenticated = '';
533 $disableEmailPrefs = false;
536 if ($this->mUserEmail
== '') {
537 $emailauthenticated = wfMsg( 'noemailprefs' );
540 $ps = $this->namespacesCheckboxes();
542 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
543 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
544 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
545 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
546 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
547 $prefs_help_realname = '';
551 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
552 $wgOut->addHTML( "<div id='preferences'>" );
557 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
574 if ($wgAllowRealName) {
577 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
578 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
582 if ($wgEnableEmail) {
585 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
586 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
592 if( !empty( $this->mToggles
['fancysig'] ) &&
593 false === $wgParser->validateSig( $rawNick ) ) {
594 $invalidSig = $this->addRow(
596 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
604 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
605 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
608 # FIXME: The <input> part should be where the is, getToggle() needs
609 # to be changed to out return its output in two parts. -รฆvar
612 $this->getToggle( 'fancysig' )
617 * Make sure the site language is in the list; a custom language code
618 * might not have a defined name...
620 $languages = $wgLang->getLanguageNames();
621 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
622 $languages[$wgContLanguageCode] = $wgContLanguageCode;
627 * If a bogus value is set, default to the content language.
628 * Otherwise, no default is selected and the user ends up
629 * with an Afrikaans interface since it's first in the list.
631 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
633 foreach($languages as $code => $name) {
635 /* only add languages that have a file */
636 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
637 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
638 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
639 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
644 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
645 "<select name='wpUserLanguage' id='wpUserLanguage'>$selbox</select>"
649 /* see if there are multiple language variants to choose from*/
650 if(!$wgDisableLangConversion) {
651 $variants = $wgContLang->getVariants();
652 $variantArray = array();
654 foreach($variants as $v) {
655 $v = str_replace( '_', '-', strtolower($v));
656 if( array_key_exists( $v, $languages ) ) {
657 // If it doesn't have a name, we'll pretend it doesn't exist
658 $variantArray[$v] = $languages[$v];
663 foreach($variantArray as $code => $name) {
664 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
665 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
668 if(count($variantArray) > 1) {
670 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
674 $wgOut->addHTML('</table>');
677 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
678 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
679 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
681 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
684 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
685 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
688 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
689 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
692 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
693 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
696 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
700 if ($wgEnableEmail) {
701 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
705 $enotifwatchlistpages.
706 $enotifusertalkpages.
708 if ($wgEnableUserEmail) {
709 $emf = wfMsg( 'allowemail' );
710 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
712 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
715 $wgOut->addHTML( '</fieldset>' );
719 if ($wgAllowRealName ||
$wgEnableEmail) {
720 $wgOut->addHTML("<div class='prefsectiontip'>");
721 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
722 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
723 $wgOut->addHTML( $rn . $em . '</div>');
726 $wgOut->addHTML( '</fieldset>' );
730 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
731 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
732 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
733 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
734 else { $checked = ""; }
735 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
737 $wgOut->addHtml( "</fieldset>\n\n" );
739 # Need to output a hidden option even if the relevant skin is not in use,
740 # otherwise the preference will get reset to 0 on submit
741 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
746 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
747 $mptitle = Title
::newMainPage();
748 $previewtext = wfMsg('skinpreview');
749 # Only show members of $wgValidSkinNames rather than
750 # $skinNames (skins is all skin names from Language.php)
751 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
752 if ( in_array( $skinkey, $wgSkipSkins ) ) {
755 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
756 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
758 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
759 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
760 if( $skinkey == $wgDefaultSkin )
761 $sn .= ' (' . wfMsg( 'default' ) . ')';
762 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br/>\n" );
764 $wgOut->addHTML( "</fieldset>\n\n" );
770 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
771 foreach ( $mathopts as $k => $v ) {
772 $checked = $k == $this->mMath ?
' checked="checked"' : '';
773 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
775 $wgOut->addHTML( "</fieldset>\n\n" );
780 $wgOut->addHTML("<fieldset>
781 <legend>" . wfMsg( 'files' ) . "</legend>
782 <div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
784 $imageLimitOptions = null;
785 foreach ( $wgImageLimits as $index => $limits ) {
786 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
787 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}ร{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
790 $imageThumbOptions = null;
791 $wgOut->addHTML( "{$imageLimitOptions}</select></div>
792 <div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
793 foreach ( $wgThumbLimits as $index => $size ) {
794 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
795 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
797 $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
804 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
807 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
809 $epoch = '20010408091234';
810 foreach($dateopts as $key => $option) {
811 if( $key == MW_DATE_DEFAULT
) {
812 $formatted = wfMsgHtml( 'datedefault' );
814 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
816 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
817 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
818 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
821 $wgOut->addHTML( "</fieldset>\n" );
824 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
825 $nowserver = $wgLang->time( $now, false );
827 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
828 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
829 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
831 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
832 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
833 ) . "<tr><td colspan='2'>
834 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
835 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
836 </td></tr></table></fieldset>
837 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
842 global $wgLivePreview, $wgUseRCPatrol;
843 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
845 <label for="wpRows">' . wfMsg( 'rows' ) . "</label> <input type='text' name='wpRows' id='wpRows' value=\"{$this->mRows}\" size='3' />
846 <label for='wpCols'>" . wfMsg( 'columns' ) . "</label> <input type='text' name='wpCols' id='wpCols' value=\"{$this->mCols}\" size='3' />
848 $this->getToggles( array(
850 'editsectiononrightclick',
861 $wgLivePreview ?
'uselivepreview' : false,
862 $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ?
'autopatrol' : false,
866 $this->mUsedToggles
['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it
868 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
869 '<label for="wpRecent">' . wfMsg ( 'recentchangescount' ) .
870 "</label> <input type='text' name='wpRecent' id='wpRecent' value=\"$this->mRecent\" size='3' />" .
871 $this->getToggles( array(
873 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
879 $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
881 $wgOut->addHTML( '<label for="wpWatchlistDays">' . wfMsgHtml( 'prefs-watchlist-days' ) . '</label> ' );
882 $wgOut->addHTML( '<input type="text" name="wpWatchlistDays" id="wpWatchlistDays" value="' . $this->mWatchlistDays
. '" size="3" />' );
883 $wgOut->addHTML( '<br /><br />' ); # Spacing
884 $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'extendwatchlist' ) ) );
885 $wgOut->addHTML( '<label for="wpWatchlistEdits">' . wfMsgHtml( 'prefs-watchlist-edits' ) . '</label> ' );
886 $wgOut->addHTML( '<input type="text" name="wpWatchlistEdits" id="wpWatchlistEdits" value="' . $this->mWatchlistEdits
. '" size="3" />' );
888 $wgOut->addHTML( '</fieldset>' );
891 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
893 '<label for="wpSearch">' . wfMsg( 'resultsperpage' ) . '</label>',
894 "<input type='text' name='wpSearch' id='wpSearch' value=\"$this->mSearch\" size='4' />"
897 '<label for="wpSearchLines">' . wfMsg( 'contextlines' ) . '</label>',
898 "<input type='text' name='wpSearchLines' id='wpSearchLines' value=\"$this->mSearchLines\" size='4' />"
901 '<label for="wpSearchChars">' . wfMsg( 'contextchars' ) . '</label>',
902 "<input type='text' name='wpSearchChars' id='wpSearchChars' value=\"$this->mSearchChars\" size='4' />"
904 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
908 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
910 '<label for="wpStubs">' . htmlspecialchars ( wfMsg ( 'stubthreshold' ) ) . '</label>' .
911 " <input type='text' name='wpStubs' id='wpStubs' value=\"$this->mStubs\" size='6' />"
913 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
914 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
915 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
916 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
917 $uopt = $wgUser->getOption("underline");
918 $s0 = $uopt == 0 ?
' selected="selected"' : '';
919 $s1 = $uopt == 1 ?
' selected="selected"' : '';
920 $s2 = $uopt == 2 ?
' selected="selected"' : '';
922 <div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
923 <select name='wpOpunderline' id='wpOpunderline'>
924 <option value=\"0\"$s0>$msgUnderlinenever</option>
925 <option value=\"1\"$s1>$msgUnderlinealways</option>
926 <option value=\"2\"$s2>$msgUnderlinedefault</option>
930 foreach ( $togs as $tname ) {
931 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
932 $wgOut->addHTML( $this->getToggle( $tname ) );
935 $wgOut->addHTML( '</fieldset>' );
937 $token = $wgUser->editToken();
939 <div id='prefsubmit'>
941 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
942 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
943 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
948 <input type='hidden' name='wpEditToken' value='{$token}' />
951 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );