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 $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 = User
::getToggles();
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 ) {
160 global $wgLang, $wgContLang;
161 if ( $val !== false && (
162 in_array( $val, (array)$wgLang->getDatePreferences() ) ||
163 in_array( $val, (array)$wgContLang->getDatePreferences() ) ) )
167 return $wgLang->getDefaultDateFormat();
172 * Used to validate the user inputed timezone before saving it as
173 * 'timeciorrection', will return '00:00' if fed bogus data.
174 * Note: It's not a 100% correct implementation timezone-wise, it will
175 * accept stuff like '14:30',
177 * @param string $s the user input
180 function validateTimeZone( $s ) {
182 if ( strpos( $s, ':' ) ) {
184 $array = explode( ':' , $s );
185 $hour = intval( $array[0] );
186 $minute = intval( $array[1] );
188 $minute = intval( $s * 60 );
189 $hour = intval( $minute / 60 );
190 $minute = abs( $minute ) %
60;
192 # Max is +14:00 and min is -12:00, see:
193 # http://en.wikipedia.org/wiki/Timezone
194 $hour = min( $hour, 14 );
195 $hour = max( $hour, -12 );
196 $minute = min( $minute, 59 );
197 $minute = max( $minute, 0 );
198 $s = sprintf( "%02d:%02d", $hour, $minute );
206 function savePreferences() {
207 global $wgUser, $wgOut, $wgParser;
208 global $wgEnableUserEmail, $wgEnableEmail;
209 global $wgEmailAuthentication;
213 if ( '' != $this->mNewpass
&& $wgAuth->allowPasswordChange() ) {
214 if ( $this->mNewpass
!= $this->mRetypePass
) {
215 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
219 if (!$wgUser->checkPassword( $this->mOldpass
)) {
220 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
225 $wgUser->setPassword( $this->mNewpass
);
226 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
227 } catch( PasswordError
$e ) {
228 $this->mainPrefsForm( 'error', $e->getMessage() );
232 $wgUser->setRealName( $this->mRealName
);
234 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
235 $needRedirect = true;
237 $needRedirect = false;
240 # Validate the signature and clean it up as needed
241 if( $this->mToggles
['fancysig'] ) {
242 if( Parser
::validateSig( $this->mNick
) !== false ) {
243 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
245 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
248 // When no fancy sig used, make sure ~{3,5} get removed.
249 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
252 $wgUser->setOption( 'language', $this->mUserLanguage
);
253 $wgUser->setOption( 'variant', $this->mUserVariant
);
254 $wgUser->setOption( 'nickname', $this->mNick
);
255 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
256 $wgUser->setOption( 'skin', $this->mSkin
);
259 $wgUser->setOption( 'math', $this->mMath
);
261 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
) );
262 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
263 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
264 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
265 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
266 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
267 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
268 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
269 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
270 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
271 $wgUser->setOption( 'imagesize', $this->mImageSize
);
272 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
273 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
274 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
276 # Set search namespace options
277 foreach( $this->mSearchNs
as $i => $value ) {
278 $wgUser->setOption( "searchNs{$i}", $value );
281 if( $wgEnableEmail && $wgEnableUserEmail ) {
282 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
286 foreach ( $this->mToggles
as $tname => $tvalue ) {
287 $wgUser->setOption( $tname, $tvalue );
289 if (!$wgAuth->updateExternalDB($wgUser)) {
290 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
293 $wgUser->setCookies();
294 $wgUser->saveSettings();
297 if( $wgEnableEmail ) {
298 $newadr = $this->mUserEmail
;
299 $oldadr = $wgUser->getEmail();
300 if( ($newadr != '') && ($newadr != $oldadr) ) {
301 # the user has supplied a new email address on the login page
302 if( $wgUser->isValidEmailAddr( $newadr ) ) {
303 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
304 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
305 $wgUser->saveSettings();
306 if ($wgEmailAuthentication) {
307 # Mail a temporary password to the dirty address.
308 # User can come back through the confirmation URL to re-enable email.
309 $result = $wgUser->sendConfirmationMail();
310 if( WikiError
::isError( $result ) ) {
311 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
313 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
317 $error = wfMsg( 'invalidemailaddress' );
320 $wgUser->setEmail( $this->mUserEmail
);
321 $wgUser->setCookies();
322 $wgUser->saveSettings();
326 if( $needRedirect && $error === false ) {
327 $title =& SpecialPage
::getTitleFor( "Preferences" );
328 $wgOut->redirect($title->getFullURL('success'));
332 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
333 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
339 function resetPrefs() {
340 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
342 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
343 $this->mUserEmail
= $wgUser->getEmail();
344 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
345 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
347 # language value might be blank, default to content language
348 $this->mUserLanguage
= $wgUser->getOption( 'language', $wgContLanguageCode );
350 $this->mUserVariant
= $wgUser->getOption( 'variant');
351 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
352 $this->mNick
= $wgUser->getOption( 'nickname' );
354 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
355 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
356 $this->mMath
= $wgUser->getOption( 'math' );
357 $this->mDate
= $wgUser->getDatePreference();
358 $this->mRows
= $wgUser->getOption( 'rows' );
359 $this->mCols
= $wgUser->getOption( 'cols' );
360 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
361 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
362 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
363 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
364 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
365 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
366 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
367 $this->mRecent
= $wgUser->getOption( 'rclimit' );
368 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
369 $this->mUnderline
= $wgUser->getOption( 'underline' );
370 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
372 $togs = User
::getToggles();
373 foreach ( $togs as $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;
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, $wgAuth;
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->getDatePreferences();
471 $togs = User
::getToggles();
473 $titleObj = SpecialPage
::getTitleFor( '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
[ 'ccmeonemails' ] = true;
484 $this->mUsedToggles
[ 'uselivepreview' ] = true;
488 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
489 $this->mRealName
= htmlspecialchars( $this->mRealName
);
490 $rawNick = $this->mNick
;
491 $this->mNick
= htmlspecialchars( $this->mNick
);
492 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
496 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
497 if( $wgUser->getEmailAuthenticationTimestamp() ) {
498 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
499 $disableEmailPrefs = false;
501 $disableEmailPrefs = true;
502 $skin = $wgUser->getSkin();
503 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
504 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
505 wfMsg( 'emailconfirmlink' ) );
508 $emailauthenticated = '';
509 $disableEmailPrefs = false;
512 if ($this->mUserEmail
== '') {
513 $emailauthenticated = wfMsg( 'noemailprefs' );
516 $ps = $this->namespacesCheckboxes();
518 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
519 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
520 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
521 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
525 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
526 $wgOut->addHTML( "<div id='preferences'>" );
531 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
533 $userInformationHtml =
543 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
544 $wgOut->addHtml( $userInformationHtml );
548 if ($wgAllowRealName) {
551 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
552 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
556 if ($wgEnableEmail) {
559 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
560 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
566 if( !empty( $this->mToggles
['fancysig'] ) &&
567 false === $wgParser->validateSig( $rawNick ) ) {
568 $invalidSig = $this->addRow(
570 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
578 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
579 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
582 # FIXME: The <input> part should be where the is, getToggle() needs
583 # to be changed to out return its output in two parts. -รฆvar
586 $this->getToggle( 'fancysig' )
591 * Make sure the site language is in the list; a custom language code
592 * might not have a defined name...
594 $languages = Language
::getLanguageNames( true );
595 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
596 $languages[$wgContLanguageCode] = $wgContLanguageCode;
601 * If a bogus value is set, default to the content language.
602 * Otherwise, no default is selected and the user ends up
603 * with an Afrikaans interface since it's first in the list.
605 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
607 foreach( $languages as $code => $name ) {
608 $selected = ($code == $selectedLang);
609 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
613 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
614 "<select name='wpUserLanguage' id='wpUserLanguage'>$options</select>"
618 /* see if there are multiple language variants to choose from*/
619 if(!$wgDisableLangConversion) {
620 $variants = $wgContLang->getVariants();
621 $variantArray = array();
623 foreach($variants as $v) {
624 $v = str_replace( '_', '-', strtolower($v));
625 if( array_key_exists( $v, $languages ) ) {
626 // If it doesn't have a name, we'll pretend it doesn't exist
627 $variantArray[$v] = $languages[$v];
632 foreach( $variantArray as $code => $name ) {
633 $selected = ($code == $this->mUserVariant
);
634 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
637 if(count($variantArray) > 1) {
639 $this->addRow( wfMsg( 'yourvariant' ),
640 "<select name='wpUserVariant'>$options</select>" )
644 $wgOut->addHTML('</table>');
647 if( $wgAuth->allowPasswordChange() ) {
648 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
649 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
650 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
652 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
655 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
656 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
659 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
660 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
663 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
664 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
667 $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>" );
686 $wgOut->addHtml( $this->getToggle( 'ccmeonemails' ) );
688 $wgOut->addHTML( '</fieldset>' );
692 # Show little "help" tips for the real name and email address options
693 if( $wgAllowRealName ||
$wgEnableEmail ) {
694 if( $wgAllowRealName )
695 $tips[] = wfMsg( 'prefs-help-realname' );
697 $tips[] = wfMsg( 'prefs-help-email' );
698 $wgOut->addHtml( '<div class="prefsectiontip">' . implode( '<br />', $tips ) . '</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 Skin::getSkinNames() rather than
725 # $skinNames (skins is all skin names from Language.php)
726 $validSkinNames = Skin
::getSkinNames();
727 # Sort by UI skin name. First though need to update validSkinNames as sometimes
728 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
729 foreach ($validSkinNames as $skinkey => & $skinname ) {
730 if ( isset( $skinNames[$skinkey] ) ) {
731 $skinname = $skinNames[$skinkey];
734 asort($validSkinNames);
735 foreach ($validSkinNames as $skinkey => $sn ) {
736 if ( in_array( $skinkey, $wgSkipSkins ) ) {
739 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
741 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
742 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
743 if( $skinkey == $wgDefaultSkin )
744 $sn .= ' (' . wfMsg( 'default' ) . ')';
745 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
747 $wgOut->addHTML( "</fieldset>\n\n" );
753 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
754 foreach ( $mathopts as $k => $v ) {
755 $checked = $k == $this->mMath ?
' checked="checked"' : '';
756 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
758 $wgOut->addHTML( "</fieldset>\n\n" );
764 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
767 $imageLimitOptions = null;
768 foreach ( $wgImageLimits as $index => $limits ) {
769 $selected = ($index == $this->mImageSize
);
770 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
771 wfMsg('unit-pixel'), $index, $selected );
774 $imageSizeId = 'wpImageSize';
776 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
777 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
779 Xml
::closeElement( 'select' ) . "</div>\n"
782 $imageThumbOptions = null;
783 foreach ( $wgThumbLimits as $index => $size ) {
784 $selected = ($index == $this->mThumbSize
);
785 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
789 $thumbSizeId = 'wpThumbSize';
791 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
792 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
794 Xml
::closeElement( 'select' ) . "</div>\n"
797 $wgOut->addHTML( "</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 = '20010115161234'; # Wikipedia day
810 foreach( $dateopts as $key ) {
811 if( $key == '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><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
841 global $wgLivePreview, $wgUseRCPatrol;
842 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
844 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
846 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
848 $this->getToggles( array(
850 'editsectiononrightclick',
859 $wgLivePreview ?
'uselivepreview' : false,
864 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
865 wfInputLabel( wfMsg( 'recentchangescount' ),
866 'wpRecent', 'wpRecent', 3, $this->mRecent
) .
867 $this->getToggles( array(
869 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
875 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
877 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
878 $wgOut->addHtml( '<br /><br />' );
880 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
881 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
882 $wgOut->addHtml( '<br /><br />' );
884 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
886 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
887 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
888 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
889 if( $wgUser->isAllowed( $action ) )
890 $wgOut->addHtml( $this->getToggle( $toggle ) );
892 $this->mUsedToggles
['watchcreations'] = true;
893 $this->mUsedToggles
['watchdefault'] = true;
894 $this->mUsedToggles
['watchmoves'] = true;
895 $this->mUsedToggles
['watchdeletion'] = true;
897 #$wgOut->addHtml( $this->getToggles( array( 'watchdefault', 'watchcreations', 'watchmoves', 'watchdeletion' ) ) );
899 $wgOut->addHtml( '</fieldset>' );
902 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
904 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
905 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
908 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
909 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
912 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
913 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
915 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
919 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
920 $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ),
921 'wpStubs', 'wpStubs', 6, $this->mStubs
) );
922 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
923 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
924 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
925 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
926 $uopt = $wgUser->getOption("underline");
927 $s0 = $uopt == 0 ?
' selected="selected"' : '';
928 $s1 = $uopt == 1 ?
' selected="selected"' : '';
929 $s2 = $uopt == 2 ?
' selected="selected"' : '';
931 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
932 <select name='wpOpunderline' id='wpOpunderline'>
933 <option value=\"0\"$s0>$msgUnderlinenever</option>
934 <option value=\"1\"$s1>$msgUnderlinealways</option>
935 <option value=\"2\"$s2>$msgUnderlinedefault</option>
936 </select></p></div>");
938 foreach ( $togs as $tname ) {
939 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
940 $wgOut->addHTML( $this->getToggle( $tname ) );
943 $wgOut->addHTML( '</fieldset>' );
945 $token = $wgUser->editToken();
947 <div id='prefsubmit'>
949 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
950 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
951 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
956 <input type='hidden' name='wpEditToken' value='{$token}' />
959 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );