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, $wgMinimalPasswordLength;
213 if ( '' != $this->mNewpass
&& $wgAuth->allowPasswordChange() ) {
214 if ( $this->mNewpass
!= $this->mRetypePass
) {
215 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
219 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
220 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
224 if (!$wgUser->checkPassword( $this->mOldpass
)) {
225 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
228 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
229 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
232 $wgUser->setPassword( $this->mNewpass
);
233 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
236 $wgUser->setRealName( $this->mRealName
);
238 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
239 $needRedirect = true;
241 $needRedirect = false;
244 # Validate the signature and clean it up as needed
245 if( $this->mToggles
['fancysig'] ) {
246 if( Parser
::validateSig( $this->mNick
) !== false ) {
247 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
249 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
252 // When no fancy sig used, make sure ~{3,5} get removed.
253 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
256 $wgUser->setOption( 'language', $this->mUserLanguage
);
257 $wgUser->setOption( 'variant', $this->mUserVariant
);
258 $wgUser->setOption( 'nickname', $this->mNick
);
259 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
260 $wgUser->setOption( 'skin', $this->mSkin
);
263 $wgUser->setOption( 'math', $this->mMath
);
265 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
) );
266 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
267 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
268 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
269 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
270 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
271 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
272 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
273 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
274 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
275 $wgUser->setOption( 'imagesize', $this->mImageSize
);
276 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
277 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
278 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
280 # Set search namespace options
281 foreach( $this->mSearchNs
as $i => $value ) {
282 $wgUser->setOption( "searchNs{$i}", $value );
285 if( $wgEnableEmail && $wgEnableUserEmail ) {
286 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
290 foreach ( $this->mToggles
as $tname => $tvalue ) {
291 $wgUser->setOption( $tname, $tvalue );
293 if (!$wgAuth->updateExternalDB($wgUser)) {
294 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
297 $wgUser->setCookies();
298 $wgUser->saveSettings();
301 if( $wgEnableEmail ) {
302 $newadr = $this->mUserEmail
;
303 $oldadr = $wgUser->getEmail();
304 if( ($newadr != '') && ($newadr != $oldadr) ) {
305 # the user has supplied a new email address on the login page
306 if( $wgUser->isValidEmailAddr( $newadr ) ) {
307 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
308 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
309 $wgUser->saveSettings();
310 if ($wgEmailAuthentication) {
311 # Mail a temporary password to the dirty address.
312 # User can come back through the confirmation URL to re-enable email.
313 $result = $wgUser->sendConfirmationMail();
314 if( WikiError
::isError( $result ) ) {
315 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
317 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
321 $error = wfMsg( 'invalidemailaddress' );
324 $wgUser->setEmail( $this->mUserEmail
);
325 $wgUser->setCookies();
326 $wgUser->saveSettings();
330 if( $needRedirect && $error === false ) {
331 $title =& SpecialPage
::getTitleFor( "Preferences" );
332 $wgOut->redirect($title->getFullURL('success'));
336 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
337 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
343 function resetPrefs() {
344 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
346 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
347 $this->mUserEmail
= $wgUser->getEmail();
348 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
349 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
350 $this->mUserLanguage
= $wgUser->getOption( 'language' );
351 if( empty( $this->mUserLanguage
) ) {
352 # Quick hack for conversions, where this value is blank
353 global $wgContLanguageCode;
354 $this->mUserLanguage
= $wgContLanguageCode;
356 $this->mUserVariant
= $wgUser->getOption( 'variant');
357 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
358 $this->mNick
= $wgUser->getOption( 'nickname' );
360 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
361 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
362 $this->mMath
= $wgUser->getOption( 'math' );
363 $this->mDate
= $wgUser->getDatePreference();
364 $this->mRows
= $wgUser->getOption( 'rows' );
365 $this->mCols
= $wgUser->getOption( 'cols' );
366 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
367 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
368 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
369 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
370 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
371 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
372 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
373 $this->mRecent
= $wgUser->getOption( 'rclimit' );
374 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
375 $this->mUnderline
= $wgUser->getOption( 'underline' );
376 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
378 $togs = User
::getToggles();
379 foreach ( $togs as $tname ) {
380 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
383 $namespaces = $wgContLang->getNamespaces();
384 foreach ( $namespaces as $i => $namespace ) {
385 if ( $i >= NS_MAIN
) {
386 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
394 function namespacesCheckboxes() {
397 # Determine namespace checkboxes
398 $namespaces = $wgContLang->getNamespaces();
401 foreach ( $namespaces as $i => $name ) {
404 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
405 $name = str_replace( '_', ' ', $namespaces[$i] );
408 $name = wfMsg( 'blanknamespace' );
410 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
416 function getToggle( $tname, $trailer = false, $disabled = false ) {
417 global $wgUser, $wgLang;
419 $this->mUsedToggles
[$tname] = true;
420 $ttext = $wgLang->getUserToggle( $tname );
422 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
423 $disabled = $disabled ?
' disabled="disabled"' : '';
424 $trailer = $trailer ?
$trailer : '';
425 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
426 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
429 function getToggles( $items ) {
431 foreach( $items as $item ) {
432 if( $item === false )
434 if( is_array( $item ) ) {
435 list( $key, $trailer ) = $item;
440 $out .= $this->getToggle( $key, $trailer );
445 function addRow($td1, $td2) {
446 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
452 function mainPrefsForm( $status , $message = '' ) {
453 global $wgUser, $wgOut, $wgLang, $wgContLang;
454 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
455 global $wgDisableLangConversion;
456 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
457 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
458 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
459 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
461 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
462 $wgOut->setArticleRelated( false );
463 $wgOut->setRobotpolicy( 'noindex,nofollow' );
465 if ( $this->mSuccess ||
'success' == $status ) {
466 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
467 } else if ( 'error' == $status ) {
468 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
469 } else if ( '' != $status ) {
470 $wgOut->addWikitext( $message . "\n----" );
473 $qbs = $wgLang->getQuickbarSettings();
474 $skinNames = $wgLang->getSkinNames();
475 $mathopts = $wgLang->getMathNames();
476 $dateopts = $wgLang->getDatePreferences();
477 $togs = User
::getToggles();
479 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
480 $action = $titleObj->escapeLocalURL();
482 # Pre-expire some toggles so they won't show if disabled
483 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
484 $this->mUsedToggles
[ 'showupdated' ] = true;
485 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
486 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
487 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
488 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
489 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
490 $this->mUsedToggles
[ 'uselivepreview' ] = true;
494 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
495 $this->mRealName
= htmlspecialchars( $this->mRealName
);
496 $rawNick = $this->mNick
;
497 $this->mNick
= htmlspecialchars( $this->mNick
);
498 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
502 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
503 if( $wgUser->getEmailAuthenticationTimestamp() ) {
504 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
505 $disableEmailPrefs = false;
507 $disableEmailPrefs = true;
508 $skin = $wgUser->getSkin();
509 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
510 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
511 wfMsg( 'emailconfirmlink' ) );
514 $emailauthenticated = '';
515 $disableEmailPrefs = false;
518 if ($this->mUserEmail
== '') {
519 $emailauthenticated = wfMsg( 'noemailprefs' );
522 $ps = $this->namespacesCheckboxes();
524 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
525 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
526 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
527 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
531 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
532 $wgOut->addHTML( "<div id='preferences'>" );
537 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
554 if ($wgAllowRealName) {
557 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
558 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
562 if ($wgEnableEmail) {
565 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
566 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
572 if( !empty( $this->mToggles
['fancysig'] ) &&
573 false === $wgParser->validateSig( $rawNick ) ) {
574 $invalidSig = $this->addRow(
576 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
584 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
585 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
588 # FIXME: The <input> part should be where the is, getToggle() needs
589 # to be changed to out return its output in two parts. -รฆvar
592 $this->getToggle( 'fancysig' )
597 * Make sure the site language is in the list; a custom language code
598 * might not have a defined name...
600 $languages = $wgLang->getLanguageNames( true );
601 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
602 $languages[$wgContLanguageCode] = $wgContLanguageCode;
607 * If a bogus value is set, default to the content language.
608 * Otherwise, no default is selected and the user ends up
609 * with an Afrikaans interface since it's first in the list.
611 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
613 foreach( $languages as $code => $name ) {
614 $selected = ($code == $selectedLang);
615 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
619 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
620 "<select name='wpUserLanguage' id='wpUserLanguage'>$options</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 $selected = ($code == $this->mUserVariant
);
640 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
643 if(count($variantArray) > 1) {
645 $this->addRow( wfMsg( 'yourvariant' ),
646 "<select name='wpUserVariant'>$options</select>" )
650 $wgOut->addHTML('</table>');
653 if( $wgAuth->allowPasswordChange() ) {
654 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
655 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
656 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
658 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
661 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
662 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
665 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
666 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
669 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
670 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
673 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
678 if ($wgEnableEmail) {
679 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
683 $enotifwatchlistpages.
684 $enotifusertalkpages.
686 if ($wgEnableUserEmail) {
687 $emf = wfMsg( 'allowemail' );
688 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
690 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
692 $wgOut->addHtml( $this->getToggle( 'ccmeonemails' ) );
694 $wgOut->addHTML( '</fieldset>' );
698 # Show little "help" tips for the real name and email address options
699 if( $wgAllowRealName ||
$wgEnableEmail ) {
700 if( $wgAllowRealName )
701 $tips[] = wfMsg( 'prefs-help-realname' );
703 $tips[] = wfMsg( 'prefs-help-email' );
704 $wgOut->addHtml( '<div class="prefsectiontip">' . implode( '<br />', $tips ) . '</div>' );
707 $wgOut->addHTML( '</fieldset>' );
711 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
712 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
713 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
714 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
715 else { $checked = ""; }
716 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
718 $wgOut->addHtml( "</fieldset>\n\n" );
720 # Need to output a hidden option even if the relevant skin is not in use,
721 # otherwise the preference will get reset to 0 on submit
722 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
727 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
728 $mptitle = Title
::newMainPage();
729 $previewtext = wfMsg('skinpreview');
730 # Only show members of Skin::getSkinNames() rather than
731 # $skinNames (skins is all skin names from Language.php)
732 $validSkinNames = Skin
::getSkinNames();
733 # Sort by UI skin name. First though need to update validSkinNames as sometimes
734 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
735 foreach ($validSkinNames as $skinkey => & $skinname ) {
736 if ( isset( $skinNames[$skinkey] ) ) {
737 $skinname = $skinNames[$skinkey];
740 asort($validSkinNames);
741 foreach ($validSkinNames as $skinkey => $sn ) {
742 if ( in_array( $skinkey, $wgSkipSkins ) ) {
745 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
747 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
748 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
749 if( $skinkey == $wgDefaultSkin )
750 $sn .= ' (' . wfMsg( 'default' ) . ')';
751 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
753 $wgOut->addHTML( "</fieldset>\n\n" );
759 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
760 foreach ( $mathopts as $k => $v ) {
761 $checked = $k == $this->mMath ?
' checked="checked"' : '';
762 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
764 $wgOut->addHTML( "</fieldset>\n\n" );
770 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
773 $imageLimitOptions = null;
774 foreach ( $wgImageLimits as $index => $limits ) {
775 $selected = ($index == $this->mImageSize
);
776 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
777 wfMsg('unit-pixel'), $index, $selected );
780 $imageSizeId = 'wpImageSize';
782 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
783 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
785 Xml
::closeElement( 'select' ) . "</div>\n"
788 $imageThumbOptions = null;
789 foreach ( $wgThumbLimits as $index => $size ) {
790 $selected = ($index == $this->mThumbSize
);
791 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
795 $thumbSizeId = 'wpThumbSize';
797 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
798 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
800 Xml
::closeElement( 'select' ) . "</div>\n"
803 $wgOut->addHTML( "</fieldset>\n\n" );
810 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
813 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
815 $epoch = '20010115161234'; # Wikipedia day
816 foreach( $dateopts as $key ) {
817 if( $key == 'default' ) {
818 $formatted = wfMsgHtml( 'datedefault' );
820 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
822 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
823 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
824 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
827 $wgOut->addHTML( "</fieldset>\n" );
830 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
831 $nowserver = $wgLang->time( $now, false );
833 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
834 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
835 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
837 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
838 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
839 ) . "<tr><td colspan='2'>
840 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
841 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
842 </td></tr></table><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
847 global $wgLivePreview, $wgUseRCPatrol;
848 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
850 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
852 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
854 $this->getToggles( array(
856 'editsectiononrightclick',
867 $wgLivePreview ?
'uselivepreview' : false,
868 $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ?
'autopatrol' : false,
872 $this->mUsedToggles
['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it
874 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
875 wfInputLabel( wfMsg( 'recentchangescount' ),
876 'wpRecent', 'wpRecent', 3, $this->mRecent
) .
877 $this->getToggles( array(
879 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
885 $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
887 $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-days' ),
888 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
889 $wgOut->addHTML( '<br /><br />' ); # Spacing
890 $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'extendwatchlist' ) ) );
891 $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ),
892 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
894 $wgOut->addHTML( '</fieldset>' );
897 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
899 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
900 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
903 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
904 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
907 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
908 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
910 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
914 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
915 $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ),
916 'wpStubs', 'wpStubs', 6, $this->mStubs
) );
917 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
918 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
919 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
920 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
921 $uopt = $wgUser->getOption("underline");
922 $s0 = $uopt == 0 ?
' selected="selected"' : '';
923 $s1 = $uopt == 1 ?
' selected="selected"' : '';
924 $s2 = $uopt == 2 ?
' selected="selected"' : '';
926 <div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
927 <select name='wpOpunderline' id='wpOpunderline'>
928 <option value=\"0\"$s0>$msgUnderlinenever</option>
929 <option value=\"1\"$s1>$msgUnderlinealways</option>
930 <option value=\"2\"$s2>$msgUnderlinedefault</option>
934 foreach ( $togs as $tname ) {
935 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
936 $wgOut->addHTML( $this->getToggle( $tname ) );
939 $wgOut->addHTML( '</fieldset>' );
941 $token = $wgUser->editToken();
943 <div id='prefsubmit'>
945 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
946 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
947 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
952 <input type='hidden' name='wpEditToken' value='{$token}' />
955 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );