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;
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' );
69 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
71 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
73 # User toggles (the big ugly unsorted list of checkboxes)
74 $this->mToggles
= array();
75 if ( $this->mPosted
) {
76 $togs = $wgLang->getUserToggles();
77 foreach ( $togs as $tname ) {
78 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
82 $this->mUsedToggles
= array();
84 # Search namespace options
85 # Note: namespaces don't necessarily have consecutive keys
86 $this->mSearchNs
= array();
87 if ( $this->mPosted
) {
88 $namespaces = $wgContLang->getNamespaces();
89 foreach ( $namespaces as $i => $namespace ) {
91 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
97 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
98 $this->mUserLanguage
= 'nolanguage';
103 global $wgUser, $wgOut;
105 if ( $wgUser->isAnon() ) {
106 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
109 if ( wfReadOnly() ) {
110 $wgOut->readOnlyPage();
113 if ( $this->mReset
) {
115 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
116 } else if ( $this->mSaveprefs
) {
117 $this->savePreferences();
120 $this->mainPrefsForm( '' );
126 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
128 $val = min($val, $max);
129 $val = max($val, $min);
136 function validateFloat( &$val, $min, $max=0x7fffffff ) {
137 $val = floatval( $val );
138 $val = min( $val, $max );
139 $val = max( $val, $min );
146 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
151 return $this->validateInt( $val, $min, $max );
158 function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
159 if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) ||
$val == 'ISO 8601' )
166 * Used to validate the user inputed timezone before saving it as
167 * 'timeciorrection', will return '00:00' if fed bogus data.
168 * Note: It's not a 100% correct implementation timezone-wise, it will
169 * accept stuff like '14:30',
171 * @param string $s the user input
174 function validateTimeZone( $s ) {
176 if ( strpos( $s, ':' ) ) {
178 $array = explode( ':' , $s );
179 $hour = intval( $array[0] );
180 $minute = intval( $array[1] );
182 $minute = intval( $s * 60 );
183 $hour = intval( $minute / 60 );
184 $minute = abs( $minute ) %
60;
186 # Max is +14:00 and min is -12:00, see:
187 # http://en.wikipedia.org/wiki/Timezone
188 $hour = min( $hour, 14 );
189 $hour = max( $hour, -12 );
190 $minute = min( $minute, 59 );
191 $minute = max( $minute, 0 );
192 $s = sprintf( "%02d:%02d", $hour, $minute );
200 function savePreferences() {
201 global $wgUser, $wgOut, $wgParser;
202 global $wgEnableUserEmail, $wgEnableEmail;
203 global $wgEmailAuthentication, $wgMinimalPasswordLength;
207 if ( '' != $this->mNewpass
) {
208 if ( $this->mNewpass
!= $this->mRetypePass
) {
209 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
213 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
214 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
218 if (!$wgUser->checkPassword( $this->mOldpass
)) {
219 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
222 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
223 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
226 $wgUser->setPassword( $this->mNewpass
);
227 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
230 $wgUser->setRealName( $this->mRealName
);
232 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
233 $needRedirect = true;
235 $needRedirect = false;
238 # Validate the signature and clean it up as needed
239 if( $this->mToggles
['fancysig'] ) {
240 if( Parser
::validateSig( $this->mNick
) !== false ) {
241 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
243 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
247 $wgUser->setOption( 'language', $this->mUserLanguage
);
248 $wgUser->setOption( 'variant', $this->mUserVariant
);
249 $wgUser->setOption( 'nickname', $this->mNick
);
250 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
251 $wgUser->setOption( 'skin', $this->mSkin
);
254 $wgUser->setOption( 'math', $this->mMath
);
256 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
257 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
258 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
259 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
260 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
261 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
262 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
263 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
264 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
265 $wgUser->setOption( 'imagesize', $this->mImageSize
);
266 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
267 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
268 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0.5, 5 ) );
270 # Set search namespace options
271 foreach( $this->mSearchNs
as $i => $value ) {
272 $wgUser->setOption( "searchNs{$i}", $value );
275 if( $wgEnableEmail && $wgEnableUserEmail ) {
276 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
280 foreach ( $this->mToggles
as $tname => $tvalue ) {
281 $wgUser->setOption( $tname, $tvalue );
283 if (!$wgAuth->updateExternalDB($wgUser)) {
284 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
287 $wgUser->setCookies();
288 $wgUser->saveSettings();
291 if( $wgEnableEmail ) {
292 $newadr = $this->mUserEmail
;
293 $oldadr = $wgUser->getEmail();
294 if( ($newadr != '') && ($newadr != $oldadr) ) {
295 # the user has supplied a new email address on the login page
296 if( $wgUser->isValidEmailAddr( $newadr ) ) {
297 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
298 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
299 $wgUser->saveSettings();
300 if ($wgEmailAuthentication) {
301 # Mail a temporary password to the dirty address.
302 # User can come back through the confirmation URL to re-enable email.
303 $result = $wgUser->sendConfirmationMail();
304 if( WikiError
::isError( $result ) ) {
305 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
307 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
311 $error = wfMsg( 'invalidemailaddress' );
314 $wgUser->setEmail( $this->mUserEmail
);
315 $wgUser->setCookies();
316 $wgUser->saveSettings();
320 if( $needRedirect && $error === false ) {
321 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
322 $wgOut->redirect($title->getFullURL('success'));
326 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
327 $po = ParserOptions
::newFromUser( $wgUser );
328 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
334 function resetPrefs() {
335 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
337 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
338 $this->mUserEmail
= $wgUser->getEmail();
339 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
340 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
341 $this->mUserLanguage
= $wgUser->getOption( 'language' );
342 if( empty( $this->mUserLanguage
) ) {
343 # Quick hack for conversions, where this value is blank
344 global $wgContLanguageCode;
345 $this->mUserLanguage
= $wgContLanguageCode;
347 $this->mUserVariant
= $wgUser->getOption( 'variant');
348 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
349 $this->mNick
= $wgUser->getOption( 'nickname' );
351 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
352 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
353 $this->mMath
= $wgUser->getOption( 'math' );
354 $this->mDate
= $wgUser->getOption( 'date' );
355 $this->mRows
= $wgUser->getOption( 'rows' );
356 $this->mCols
= $wgUser->getOption( 'cols' );
357 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
358 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
359 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
360 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
361 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
362 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
363 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
364 $this->mRecent
= $wgUser->getOption( 'rclimit' );
365 $this->mUnderline
= $wgUser->getOption( 'underline' );
366 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
368 $togs = $wgLang->getUserToggles();
369 foreach ( $togs as $tname ) {
370 $ttext = wfMsg('tog-'.$tname);
371 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
374 $namespaces = $wgContLang->getNamespaces();
375 foreach ( $namespaces as $i => $namespace ) {
376 if ( $i >= NS_MAIN
) {
377 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
385 function namespacesCheckboxes() {
388 # Determine namespace checkboxes
389 $namespaces = $wgContLang->getNamespaces();
392 foreach ( $namespaces as $i => $name ) {
395 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
396 $name = str_replace( '_', ' ', $namespaces[$i] );
399 $name = wfMsg( 'blanknamespace' );
401 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
407 function getToggle( $tname, $trailer = false, $disabled = false ) {
408 global $wgUser, $wgLang;
410 $this->mUsedToggles
[$tname] = true;
411 $ttext = $wgLang->getUserToggle( $tname );
413 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
414 $disabled = $disabled ?
' disabled="disabled"' : '';
415 $trailer = $trailer ?
$trailer : '';
416 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
417 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
420 function getToggles( $items ) {
422 foreach( $items as $item ) {
423 if( $item === false )
425 if( is_array( $item ) ) {
426 list( $key, $trailer ) = $item;
431 $out .= $this->getToggle( $key, $trailer );
436 function addRow($td1, $td2) {
437 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
443 function mainPrefsForm( $status , $message = '' ) {
444 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
445 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
446 global $wgDisableLangConversion;
447 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
448 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
449 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
450 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
452 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
453 $wgOut->setArticleRelated( false );
454 $wgOut->setRobotpolicy( 'noindex,nofollow' );
456 if ( $this->mSuccess ||
'success' == $status ) {
457 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
458 } else if ( 'error' == $status ) {
459 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
460 } else if ( '' != $status ) {
461 $wgOut->addWikitext( $message . "\n----" );
464 $qbs = $wgLang->getQuickbarSettings();
465 $skinNames = $wgLang->getSkinNames();
466 $mathopts = $wgLang->getMathNames();
467 $dateopts = $wgLang->getDateFormats();
468 $togs = $wgLang->getUserToggles();
470 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
471 $action = $titleObj->escapeLocalURL();
473 # Pre-expire some toggles so they won't show if disabled
474 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
475 $this->mUsedToggles
[ 'showupdated' ] = true;
476 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
477 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
478 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
479 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
480 $this->mUsedToggles
[ 'uselivepreview' ] = true;
484 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
485 $this->mRealName
= htmlspecialchars( $this->mRealName
);
486 $rawNick = $this->mNick
;
487 $this->mNick
= htmlspecialchars( $this->mNick
);
488 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
492 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
493 if( $wgUser->getEmailAuthenticationTimestamp() ) {
494 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
495 $disableEmailPrefs = false;
497 $disableEmailPrefs = true;
498 $skin = $wgUser->getSkin();
499 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
500 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
501 wfMsg( 'emailconfirmlink' ) );
504 $emailauthenticated = '';
505 $disableEmailPrefs = false;
508 if ($this->mUserEmail
== '') {
509 $emailauthenticated = wfMsg( 'noemailprefs' );
512 $ps = $this->namespacesCheckboxes();
514 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
515 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
516 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
517 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
518 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
519 $prefs_help_realname = '';
523 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
524 $wgOut->addHTML( "<div id='preferences'>" );
529 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
546 if ($wgAllowRealName) {
549 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
550 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
554 if ($wgEnableEmail) {
557 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
558 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
564 if( !empty( $this->mToggles
['fancysig'] ) &&
565 false === $wgParser->validateSig( $rawNick ) ) {
566 $invalidSig = $this->addRow(
568 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
576 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
577 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
580 # FIXME: The <input> part should be where the is, getToggle() needs
581 # to be changed to out return its output in two parts. -รฆvar
584 $this->getToggle( 'fancysig' )
589 * Make sure the site language is in the list; a custom language code
590 * might not have a defined name...
592 $languages = $wgLang->getLanguageNames();
593 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
594 $languages[$wgContLanguageCode] = $wgContLanguageCode;
599 * If a bogus value is set, default to the content language.
600 * Otherwise, no default is selected and the user ends up
601 * with an Afrikaans interface since it's first in the list.
603 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
605 foreach($languages as $code => $name) {
607 /* only add languages that have a file */
608 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
609 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
610 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
611 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
616 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
617 "<select name='wpUserLanguage' id='wpUserLanguage'>$selbox</select>"
621 /* see if there are multiple language variants to choose from*/
622 if(!$wgDisableLangConversion) {
623 $variants = $wgContLang->getVariants();
624 $variantArray = array();
626 foreach($variants as $v) {
627 $v = str_replace( '_', '-', strtolower($v));
628 if( array_key_exists( $v, $languages ) ) {
629 // If it doesn't have a name, we'll pretend it doesn't exist
630 $variantArray[$v] = $languages[$v];
635 foreach($variantArray as $code => $name) {
636 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
637 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
640 if(count($variantArray) > 1) {
642 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
646 $wgOut->addHTML('</table>');
649 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
650 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
651 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
653 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
656 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
657 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
660 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
661 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
664 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
665 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
668 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
672 if ($wgEnableEmail) {
673 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
677 $enotifwatchlistpages.
678 $enotifusertalkpages.
680 if ($wgEnableUserEmail) {
681 $emf = wfMsg( 'allowemail' );
682 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
684 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
687 $wgOut->addHTML( '</fieldset>' );
691 if ($wgAllowRealName ||
$wgEnableEmail) {
692 $wgOut->addHTML("<div class='prefsectiontip'>");
693 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
694 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
695 $wgOut->addHTML( $rn . $em . '</div>');
698 $wgOut->addHTML( '</fieldset>' );
702 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
703 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
704 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
705 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
706 else { $checked = ""; }
707 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
709 $wgOut->addHtml( "</fieldset>\n\n" );
711 # Need to output a hidden option even if the relevant skin is not in use,
712 # otherwise the preference will get reset to 0 on submit
713 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
718 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
719 $mptitle = Title
::newMainPage();
720 $previewtext = wfMsg('skinpreview');
721 # Only show members of $wgValidSkinNames rather than
722 # $skinNames (skins is all skin names from Language.php)
723 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
724 if ( in_array( $skinkey, $wgSkipSkins ) ) {
727 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
728 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
730 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
731 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
732 if( $skinkey == $wgDefaultSkin )
733 $sn .= ' (' . wfMsg( 'default' ) . ')';
734 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br/>\n" );
736 $wgOut->addHTML( "</fieldset>\n\n" );
742 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
743 foreach ( $mathopts as $k => $v ) {
744 $checked = $k == $this->mMath ?
' checked="checked"' : '';
745 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
747 $wgOut->addHTML( "</fieldset>\n\n" );
752 $wgOut->addHTML("<fieldset>
753 <legend>" . wfMsg( 'files' ) . "</legend>
754 <div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
756 $imageLimitOptions = null;
757 foreach ( $wgImageLimits as $index => $limits ) {
758 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
759 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}ร{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
762 $imageThumbOptions = null;
763 $wgOut->addHTML( "{$imageLimitOptions}</select></div>
764 <div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
765 foreach ( $wgThumbLimits as $index => $size ) {
766 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
767 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
769 $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
776 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
779 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
781 $epoch = '20010115161234';
782 foreach($dateopts as $key => $option) {
783 if( $key == MW_DATE_DEFAULT
) {
784 $formatted = wfMsgHtml( 'datedefault' );
786 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
788 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
789 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
790 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
793 $wgOut->addHTML( "</fieldset>\n" );
796 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
797 $nowserver = $wgLang->time( $now, false );
799 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
800 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
801 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
803 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
804 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
805 ) . "<tr><td colspan='2'>
806 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
807 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
808 </td></tr></table></fieldset>
809 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
814 global $wgLivePreview, $wgUseRCPatrol;
815 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
817 <label for="wpRows">' . wfMsg( 'rows' ) . "</label> <input type='text' name='wpRows' id='wpRows' value=\"{$this->mRows}\" size='3' />
818 <label for='wpCols'>" . wfMsg( 'columns' ) . "</label> <input type='text' name='wpCols' id='wpCols' value=\"{$this->mCols}\" size='3' />
820 $this->getToggles( array(
822 'editsectiononrightclick',
833 $wgLivePreview ?
'uselivepreview' : false,
834 $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ?
'autopatrol' : false,
838 $this->mUsedToggles
['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it
840 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
841 '<label for="wpRecent">' . wfMsg ( 'recentchangescount' ) .
842 "</label> <input type='text' name='wpRecent' id='wpRecent' value=\"$this->mRecent\" size='3' />" .
843 $this->getToggles( array(
845 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
851 $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
853 $wgOut->addHTML( '<label for="wpWatchlistDays">' . wfMsgHtml( 'prefs-watchlist-days' ) . '</label> ' );
854 $wgOut->addHTML( '<input type="text" name="wpWatchlistDays" id="wpWatchlistDays" value="' . $this->mWatchlistDays
. '" size="3" />' );
855 $wgOut->addHTML( '<p></p>' ); # Spacing
856 $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown' ) ) );
858 $wgOut->addHTML( '</fieldset>' );
861 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
863 '<label for="wpSearch">' . wfMsg( 'resultsperpage' ) . '</label>',
864 "<input type='text' name='wpSearch' id='wpSearch' value=\"$this->mSearch\" size='4' />"
867 '<label for="wpSearchLines">' . wfMsg( 'contextlines' ) . '</label>',
868 "<input type='text' name='wpSearchLines' id='wpSearchLines' value=\"$this->mSearchLines\" size='4' />"
871 '<label for="wpSearchChars">' . wfMsg( 'contextchars' ) . '</label>',
872 "<input type='text' name='wpSearchChars' id='wpSearchChars' value=\"$this->mSearchChars\" size='4' />"
874 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
878 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
880 '<label for="wpStubs">' . htmlspecialchars ( wfMsg ( 'stubthreshold' ) ) . '</label>' .
881 " <input type='text' name='wpStubs' id='wpStubs' value=\"$this->mStubs\" size='6' />"
883 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
884 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
885 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
886 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
887 $uopt = $wgUser->getOption("underline");
888 $s0 = $uopt == 0 ?
' selected="selected"' : '';
889 $s1 = $uopt == 1 ?
' selected="selected"' : '';
890 $s2 = $uopt == 2 ?
' selected="selected"' : '';
892 <div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
893 <select name='wpOpunderline' id='wpOpunderline'>
894 <option value=\"0\"$s0>$msgUnderlinenever</option>
895 <option value=\"1\"$s1>$msgUnderlinealways</option>
896 <option value=\"2\"$s2>$msgUnderlinedefault</option>
900 foreach ( $togs as $tname ) {
901 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
902 $wgOut->addHTML( $this->getToggle( $tname ) );
905 $wgOut->addHTML( '</fieldset>' );
907 $token = $wgUser->editToken();
909 <div id='prefsubmit'>
911 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
912 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
913 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
918 <input type='hidden' name='wpEditToken' value='{$token}' />
921 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );