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
{
25 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
26 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
27 var $mUserLanguage, $mUserVariant;
28 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
29 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
30 var $mUnderline, $mWatchlistEdits;
36 function PreferencesForm( &$request ) {
37 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
39 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
40 $this->mOldpass
= $request->getVal( 'wpOldpass' );
41 $this->mNewpass
= $request->getVal( 'wpNewpass' );
42 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
43 $this->mStubs
= $request->getVal( 'wpStubs' );
44 $this->mRows
= $request->getVal( 'wpRows' );
45 $this->mCols
= $request->getVal( 'wpCols' );
46 $this->mSkin
= $request->getVal( 'wpSkin' );
47 $this->mMath
= $request->getVal( 'wpMath' );
48 $this->mDate
= $request->getVal( 'wpDate' );
49 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
50 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
51 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
0 : 1;
52 $this->mNick
= $request->getVal( 'wpNick' );
53 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
54 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
55 $this->mSearch
= $request->getVal( 'wpSearch' );
56 $this->mRecent
= $request->getVal( 'wpRecent' );
57 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
58 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
59 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
60 $this->mImageSize
= $request->getVal( 'wpImageSize' );
61 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
62 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
63 $this->mAction
= $request->getVal( 'action' );
64 $this->mReset
= $request->getCheck( 'wpReset' );
65 $this->mPosted
= $request->wasPosted();
66 $this->mSuccess
= $request->getCheck( 'success' );
67 $this->mWatchlistDays
= $request->getVal( 'wpWatchlistDays' );
68 $this->mWatchlistEdits
= $request->getVal( 'wpWatchlistEdits' );
70 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
72 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
74 # User toggles (the big ugly unsorted list of checkboxes)
75 $this->mToggles
= array();
76 if ( $this->mPosted
) {
77 $togs = $wgLang->getUserToggles();
78 foreach ( $togs as $tname ) {
79 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
83 $this->mUsedToggles
= array();
85 # Search namespace options
86 # Note: namespaces don't necessarily have consecutive keys
87 $this->mSearchNs
= array();
88 if ( $this->mPosted
) {
89 $namespaces = $wgContLang->getNamespaces();
90 foreach ( $namespaces as $i => $namespace ) {
92 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
98 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
99 $this->mUserLanguage
= 'nolanguage';
104 global $wgUser, $wgOut;
106 if ( $wgUser->isAnon() ) {
107 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext' );
110 if ( wfReadOnly() ) {
111 $wgOut->readOnlyPage();
114 if ( $this->mReset
) {
116 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
117 } else if ( $this->mSaveprefs
) {
118 $this->savePreferences();
121 $this->mainPrefsForm( '' );
127 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
129 $val = min($val, $max);
130 $val = max($val, $min);
137 function validateFloat( &$val, $min, $max=0x7fffffff ) {
138 $val = floatval( $val );
139 $val = min( $val, $max );
140 $val = max( $val, $min );
147 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
152 return $this->validateInt( $val, $min, $max );
159 function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
160 if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) ||
$val == 'ISO 8601' )
167 * Used to validate the user inputed timezone before saving it as
168 * 'timeciorrection', will return '00:00' if fed bogus data.
169 * Note: It's not a 100% correct implementation timezone-wise, it will
170 * accept stuff like '14:30',
172 * @param string $s the user input
175 function validateTimeZone( $s ) {
177 if ( strpos( $s, ':' ) ) {
179 $array = explode( ':' , $s );
180 $hour = intval( $array[0] );
181 $minute = intval( $array[1] );
183 $minute = intval( $s * 60 );
184 $hour = intval( $minute / 60 );
185 $minute = abs( $minute ) %
60;
187 # Max is +14:00 and min is -12:00, see:
188 # http://en.wikipedia.org/wiki/Timezone
189 $hour = min( $hour, 14 );
190 $hour = max( $hour, -12 );
191 $minute = min( $minute, 59 );
192 $minute = max( $minute, 0 );
193 $s = sprintf( "%02d:%02d", $hour, $minute );
201 function savePreferences() {
202 global $wgUser, $wgOut, $wgParser;
203 global $wgEnableUserEmail, $wgEnableEmail;
204 global $wgEmailAuthentication, $wgMinimalPasswordLength;
208 if ( '' != $this->mNewpass
) {
209 if ( $this->mNewpass
!= $this->mRetypePass
) {
210 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
214 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
215 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
219 if (!$wgUser->checkPassword( $this->mOldpass
)) {
220 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
223 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
224 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
227 $wgUser->setPassword( $this->mNewpass
);
228 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
231 $wgUser->setRealName( $this->mRealName
);
233 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
234 $needRedirect = true;
236 $needRedirect = false;
239 # Validate the signature and clean it up as needed
240 if( $this->mToggles
['fancysig'] ) {
241 if( Parser
::validateSig( $this->mNick
) !== false ) {
242 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
244 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
248 $wgUser->setOption( 'language', $this->mUserLanguage
);
249 $wgUser->setOption( 'variant', $this->mUserVariant
);
250 $wgUser->setOption( 'nickname', $this->mNick
);
251 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
252 $wgUser->setOption( 'skin', $this->mSkin
);
255 $wgUser->setOption( 'math', $this->mMath
);
257 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
258 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
259 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
260 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
261 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
262 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
263 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
264 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
265 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
266 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
267 $wgUser->setOption( 'imagesize', $this->mImageSize
);
268 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
269 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
270 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
272 # Set search namespace options
273 foreach( $this->mSearchNs
as $i => $value ) {
274 $wgUser->setOption( "searchNs{$i}", $value );
277 if( $wgEnableEmail && $wgEnableUserEmail ) {
278 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
282 foreach ( $this->mToggles
as $tname => $tvalue ) {
283 $wgUser->setOption( $tname, $tvalue );
285 if (!$wgAuth->updateExternalDB($wgUser)) {
286 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
289 $wgUser->setCookies();
290 $wgUser->saveSettings();
293 if( $wgEnableEmail ) {
294 $newadr = $this->mUserEmail
;
295 $oldadr = $wgUser->getEmail();
296 if( ($newadr != '') && ($newadr != $oldadr) ) {
297 # the user has supplied a new email address on the login page
298 if( $wgUser->isValidEmailAddr( $newadr ) ) {
299 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
300 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
301 $wgUser->saveSettings();
302 if ($wgEmailAuthentication) {
303 # Mail a temporary password to the dirty address.
304 # User can come back through the confirmation URL to re-enable email.
305 $result = $wgUser->sendConfirmationMail();
306 if( WikiError
::isError( $result ) ) {
307 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
309 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
313 $error = wfMsg( 'invalidemailaddress' );
316 $wgUser->setEmail( $this->mUserEmail
);
317 $wgUser->setCookies();
318 $wgUser->saveSettings();
322 if( $needRedirect && $error === false ) {
323 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
324 $wgOut->redirect($title->getFullURL('success'));
328 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
329 $po = ParserOptions
::newFromUser( $wgUser );
330 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
336 function resetPrefs() {
337 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
339 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
340 $this->mUserEmail
= $wgUser->getEmail();
341 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
342 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
343 $this->mUserLanguage
= $wgUser->getOption( 'language' );
344 if( empty( $this->mUserLanguage
) ) {
345 # Quick hack for conversions, where this value is blank
346 global $wgContLanguageCode;
347 $this->mUserLanguage
= $wgContLanguageCode;
349 $this->mUserVariant
= $wgUser->getOption( 'variant');
350 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
351 $this->mNick
= $wgUser->getOption( 'nickname' );
353 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
354 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
355 $this->mMath
= $wgUser->getOption( 'math' );
356 $this->mDate
= $wgUser->getOption( 'date' );
357 $this->mRows
= $wgUser->getOption( 'rows' );
358 $this->mCols
= $wgUser->getOption( 'cols' );
359 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
360 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
361 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
362 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
363 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
364 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
365 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
366 $this->mRecent
= $wgUser->getOption( 'rclimit' );
367 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
368 $this->mUnderline
= $wgUser->getOption( 'underline' );
369 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
371 $togs = $wgLang->getUserToggles();
372 foreach ( $togs as $tname ) {
373 $ttext = wfMsg('tog-'.$tname);
374 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
377 $namespaces = $wgContLang->getNamespaces();
378 foreach ( $namespaces as $i => $namespace ) {
379 if ( $i >= NS_MAIN
) {
380 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
388 function namespacesCheckboxes() {
391 # Determine namespace checkboxes
392 $namespaces = $wgContLang->getNamespaces();
395 foreach ( $namespaces as $i => $name ) {
398 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
399 $name = str_replace( '_', ' ', $namespaces[$i] );
402 $name = wfMsg( 'blanknamespace' );
404 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
410 function getToggle( $tname, $trailer = false, $disabled = false ) {
411 global $wgUser, $wgLang;
413 $this->mUsedToggles
[$tname] = true;
414 $ttext = $wgLang->getUserToggle( $tname );
416 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
417 $disabled = $disabled ?
' disabled="disabled"' : '';
418 $trailer = $trailer ?
$trailer : '';
419 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
420 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
423 function getToggles( $items ) {
425 foreach( $items as $item ) {
426 if( $item === false )
428 if( is_array( $item ) ) {
429 list( $key, $trailer ) = $item;
434 $out .= $this->getToggle( $key, $trailer );
439 function addRow($td1, $td2) {
440 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
446 function mainPrefsForm( $status , $message = '' ) {
447 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
448 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
449 global $wgDisableLangConversion;
450 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
451 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
452 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
453 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
455 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
456 $wgOut->setArticleRelated( false );
457 $wgOut->setRobotpolicy( 'noindex,nofollow' );
459 if ( $this->mSuccess ||
'success' == $status ) {
460 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
461 } else if ( 'error' == $status ) {
462 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
463 } else if ( '' != $status ) {
464 $wgOut->addWikitext( $message . "\n----" );
467 $qbs = $wgLang->getQuickbarSettings();
468 $skinNames = $wgLang->getSkinNames();
469 $mathopts = $wgLang->getMathNames();
470 $dateopts = $wgLang->getDateFormats();
471 $togs = $wgLang->getUserToggles();
473 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
474 $action = $titleObj->escapeLocalURL();
476 # Pre-expire some toggles so they won't show if disabled
477 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
478 $this->mUsedToggles
[ 'showupdated' ] = true;
479 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
480 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
481 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
482 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
483 $this->mUsedToggles
[ 'uselivepreview' ] = true;
487 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
488 $this->mRealName
= htmlspecialchars( $this->mRealName
);
489 $rawNick = $this->mNick
;
490 $this->mNick
= htmlspecialchars( $this->mNick
);
491 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
495 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
496 if( $wgUser->getEmailAuthenticationTimestamp() ) {
497 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
498 $disableEmailPrefs = false;
500 $disableEmailPrefs = true;
501 $skin = $wgUser->getSkin();
502 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
503 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
504 wfMsg( 'emailconfirmlink' ) );
507 $emailauthenticated = '';
508 $disableEmailPrefs = false;
511 if ($this->mUserEmail
== '') {
512 $emailauthenticated = wfMsg( 'noemailprefs' );
515 $ps = $this->namespacesCheckboxes();
517 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
518 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
519 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
520 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
521 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
522 $prefs_help_realname = '';
526 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
527 $wgOut->addHTML( "<div id='preferences'>" );
532 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
549 if ($wgAllowRealName) {
552 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
553 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
557 if ($wgEnableEmail) {
560 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
561 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
567 if( !empty( $this->mToggles
['fancysig'] ) &&
568 false === $wgParser->validateSig( $rawNick ) ) {
569 $invalidSig = $this->addRow(
571 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
579 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
580 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
583 # FIXME: The <input> part should be where the is, getToggle() needs
584 # to be changed to out return its output in two parts. -รฆvar
587 $this->getToggle( 'fancysig' )
592 * Make sure the site language is in the list; a custom language code
593 * might not have a defined name...
595 $languages = $wgLang->getLanguageNames();
596 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
597 $languages[$wgContLanguageCode] = $wgContLanguageCode;
602 * If a bogus value is set, default to the content language.
603 * Otherwise, no default is selected and the user ends up
604 * with an Afrikaans interface since it's first in the list.
606 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
608 foreach($languages as $code => $name) {
610 /* only add languages that have a file */
611 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
612 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
613 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
614 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
619 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
620 "<select name='wpUserLanguage' id='wpUserLanguage'>$selbox</select>"
624 /* see if there are multiple language variants to choose from*/
625 if(!$wgDisableLangConversion) {
626 $variants = $wgContLang->getVariants();
627 $variantArray = array();
629 foreach($variants as $v) {
630 $v = str_replace( '_', '-', strtolower($v));
631 if( array_key_exists( $v, $languages ) ) {
632 // If it doesn't have a name, we'll pretend it doesn't exist
633 $variantArray[$v] = $languages[$v];
638 foreach($variantArray as $code => $name) {
639 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
640 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
643 if(count($variantArray) > 1) {
645 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
649 $wgOut->addHTML('</table>');
652 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
653 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
654 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
656 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
659 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
660 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
663 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
664 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
667 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
668 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
671 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
675 if ($wgEnableEmail) {
676 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
680 $enotifwatchlistpages.
681 $enotifusertalkpages.
683 if ($wgEnableUserEmail) {
684 $emf = wfMsg( 'allowemail' );
685 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
687 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
690 $wgOut->addHTML( '</fieldset>' );
694 if ($wgAllowRealName ||
$wgEnableEmail) {
695 $wgOut->addHTML("<div class='prefsectiontip'>");
696 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
697 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
698 $wgOut->addHTML( $rn . $em . '</div>');
701 $wgOut->addHTML( '</fieldset>' );
705 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
706 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
707 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
708 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
709 else { $checked = ""; }
710 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
712 $wgOut->addHtml( "</fieldset>\n\n" );
714 # Need to output a hidden option even if the relevant skin is not in use,
715 # otherwise the preference will get reset to 0 on submit
716 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
721 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
722 $mptitle = Title
::newMainPage();
723 $previewtext = wfMsg('skinpreview');
724 # Only show members of $wgValidSkinNames rather than
725 # $skinNames (skins is all skin names from Language.php)
726 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
727 if ( in_array( $skinkey, $wgSkipSkins ) ) {
730 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
731 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
733 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
734 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
735 if( $skinkey == $wgDefaultSkin )
736 $sn .= ' (' . wfMsg( 'default' ) . ')';
737 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br/>\n" );
739 $wgOut->addHTML( "</fieldset>\n\n" );
745 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
746 foreach ( $mathopts as $k => $v ) {
747 $checked = $k == $this->mMath ?
' checked="checked"' : '';
748 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
750 $wgOut->addHTML( "</fieldset>\n\n" );
755 $wgOut->addHTML("<fieldset>
756 <legend>" . wfMsg( 'files' ) . "</legend>
757 <div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
759 $imageLimitOptions = null;
760 foreach ( $wgImageLimits as $index => $limits ) {
761 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
762 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}ร{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
765 $imageThumbOptions = null;
766 $wgOut->addHTML( "{$imageLimitOptions}</select></div>
767 <div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
768 foreach ( $wgThumbLimits as $index => $size ) {
769 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
770 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
772 $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
779 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
782 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
784 $epoch = '20010408091234';
785 foreach($dateopts as $key => $option) {
786 if( $key == MW_DATE_DEFAULT
) {
787 $formatted = wfMsgHtml( 'datedefault' );
789 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
791 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
792 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
793 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
796 $wgOut->addHTML( "</fieldset>\n" );
799 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
800 $nowserver = $wgLang->time( $now, false );
802 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
803 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
804 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
806 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
807 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
808 ) . "<tr><td colspan='2'>
809 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
810 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
811 </td></tr></table></fieldset>
812 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
817 global $wgLivePreview, $wgUseRCPatrol;
818 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
820 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
822 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
824 $this->getToggles( array(
826 'editsectiononrightclick',
837 $wgLivePreview ?
'uselivepreview' : false,
838 $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ?
'autopatrol' : false,
842 $this->mUsedToggles
['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it
844 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
845 wfInputLabel( wfMsg( 'recentchangescount' ),
846 'wpRecent', 'wpRecent', 3, $this->mRecent
) .
847 $this->getToggles( array(
849 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
855 $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
857 $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-days' ),
858 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
859 $wgOut->addHTML( '<br /><br />' ); # Spacing
860 $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'extendwatchlist' ) ) );
861 $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ),
862 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
864 $wgOut->addHTML( '</fieldset>' );
867 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
869 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
870 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
873 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
874 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
877 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
878 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
880 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
884 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
885 $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ),
886 'wpStubs', 'wpStubs', 6, $this->mStubs
) );
887 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
888 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
889 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
890 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
891 $uopt = $wgUser->getOption("underline");
892 $s0 = $uopt == 0 ?
' selected="selected"' : '';
893 $s1 = $uopt == 1 ?
' selected="selected"' : '';
894 $s2 = $uopt == 2 ?
' selected="selected"' : '';
896 <div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
897 <select name='wpOpunderline' id='wpOpunderline'>
898 <option value=\"0\"$s0>$msgUnderlinenever</option>
899 <option value=\"1\"$s1>$msgUnderlinealways</option>
900 <option value=\"2\"$s2>$msgUnderlinedefault</option>
904 foreach ( $togs as $tname ) {
905 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
906 $wgOut->addHTML( $this->getToggle( $tname ) );
909 $wgOut->addHTML( '</fieldset>' );
911 $token = $wgUser->editToken();
913 <div id='prefsubmit'>
915 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
916 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
917 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
922 <input type='hidden' name='wpEditToken' value='{$token}' />
925 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );