3 * Hold things related to displaying and saving user preferences.
4 * @addtogroup SpecialPage
8 * Entry point that create the "Preferences" object
10 function wfSpecialPreferences() {
13 $form = new PreferencesForm( $wgRequest );
18 * Preferences form handling
19 * This object will show the preferences form and can save it as well.
20 * @addtogroup SpecialPage
22 class PreferencesForm
{
23 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
24 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
25 var $mUserLanguage, $mUserVariant;
26 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
27 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
28 var $mUnderline, $mWatchlistEdits;
34 function PreferencesForm( &$request ) {
35 global $wgContLang, $wgUser, $wgAllowRealName;
37 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
38 $this->mOldpass
= $request->getVal( 'wpOldpass' );
39 $this->mNewpass
= $request->getVal( 'wpNewpass' );
40 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
41 $this->mStubs
= $request->getVal( 'wpStubs' );
42 $this->mRows
= $request->getVal( 'wpRows' );
43 $this->mCols
= $request->getVal( 'wpCols' );
44 $this->mSkin
= $request->getVal( 'wpSkin' );
45 $this->mMath
= $request->getVal( 'wpMath' );
46 $this->mDate
= $request->getVal( 'wpDate' );
47 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
48 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
49 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
0 : 1;
50 $this->mNick
= $request->getVal( 'wpNick' );
51 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
52 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
53 $this->mSearch
= $request->getVal( 'wpSearch' );
54 $this->mRecent
= $request->getVal( 'wpRecent' );
55 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
56 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
57 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
58 $this->mImageSize
= $request->getVal( 'wpImageSize' );
59 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
60 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
61 $this->mAction
= $request->getVal( 'action' );
62 $this->mReset
= $request->getCheck( 'wpReset' );
63 $this->mPosted
= $request->wasPosted();
64 $this->mSuccess
= $request->getCheck( 'success' );
65 $this->mWatchlistDays
= $request->getVal( 'wpWatchlistDays' );
66 $this->mWatchlistEdits
= $request->getVal( 'wpWatchlistEdits' );
68 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
70 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
72 # User toggles (the big ugly unsorted list of checkboxes)
73 $this->mToggles
= array();
74 if ( $this->mPosted
) {
75 $togs = User
::getToggles();
76 foreach ( $togs as $tname ) {
77 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
81 $this->mUsedToggles
= array();
83 # Search namespace options
84 # Note: namespaces don't necessarily have consecutive keys
85 $this->mSearchNs
= array();
86 if ( $this->mPosted
) {
87 $namespaces = $wgContLang->getNamespaces();
88 foreach ( $namespaces as $i => $namespace ) {
90 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
96 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
97 $this->mUserLanguage
= 'nolanguage';
102 global $wgUser, $wgOut;
104 if ( $wgUser->isAnon() ) {
105 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext' );
108 if ( wfReadOnly() ) {
109 $wgOut->readOnlyPage();
112 if ( $this->mReset
) {
114 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
115 } else if ( $this->mSaveprefs
) {
116 $this->savePreferences();
119 $this->mainPrefsForm( '' );
125 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
127 $val = min($val, $max);
128 $val = max($val, $min);
135 function validateFloat( &$val, $min, $max=0x7fffffff ) {
136 $val = floatval( $val );
137 $val = min( $val, $max );
138 $val = max( $val, $min );
145 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
150 return $this->validateInt( $val, $min, $max );
157 function validateDate( $val ) {
158 global $wgLang, $wgContLang;
159 if ( $val !== false && (
160 in_array( $val, (array)$wgLang->getDatePreferences() ) ||
161 in_array( $val, (array)$wgContLang->getDatePreferences() ) ) )
165 return $wgLang->getDefaultDateFormat();
170 * Used to validate the user inputed timezone before saving it as
171 * 'timeciorrection', will return '00:00' if fed bogus data.
172 * Note: It's not a 100% correct implementation timezone-wise, it will
173 * accept stuff like '14:30',
175 * @param string $s the user input
178 function validateTimeZone( $s ) {
180 if ( strpos( $s, ':' ) ) {
182 $array = explode( ':' , $s );
183 $hour = intval( $array[0] );
184 $minute = intval( $array[1] );
186 $minute = intval( $s * 60 );
187 $hour = intval( $minute / 60 );
188 $minute = abs( $minute ) %
60;
190 # Max is +14:00 and min is -12:00, see:
191 # http://en.wikipedia.org/wiki/Timezone
192 $hour = min( $hour, 14 );
193 $hour = max( $hour, -12 );
194 $minute = min( $minute, 59 );
195 $minute = max( $minute, 0 );
196 $s = sprintf( "%02d:%02d", $hour, $minute );
204 function savePreferences() {
205 global $wgUser, $wgOut, $wgParser;
206 global $wgEnableUserEmail, $wgEnableEmail;
207 global $wgEmailAuthentication;
211 if ( '' != $this->mNewpass
&& $wgAuth->allowPasswordChange() ) {
212 if ( $this->mNewpass
!= $this->mRetypePass
) {
213 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
217 if (!$wgUser->checkPassword( $this->mOldpass
)) {
218 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
223 $wgUser->setPassword( $this->mNewpass
);
224 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
225 } catch( PasswordError
$e ) {
226 $this->mainPrefsForm( 'error', $e->getMessage() );
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' ) );
246 // When no fancy sig used, make sure ~{3,5} get removed.
247 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
250 $wgUser->setOption( 'language', $this->mUserLanguage
);
251 $wgUser->setOption( 'variant', $this->mUserVariant
);
252 $wgUser->setOption( 'nickname', $this->mNick
);
253 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
254 $wgUser->setOption( 'skin', $this->mSkin
);
257 $wgUser->setOption( 'math', $this->mMath
);
259 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
) );
260 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
261 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
262 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
263 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
264 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
265 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
266 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
267 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
268 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
269 $wgUser->setOption( 'imagesize', $this->mImageSize
);
270 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
271 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
272 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
274 # Set search namespace options
275 foreach( $this->mSearchNs
as $i => $value ) {
276 $wgUser->setOption( "searchNs{$i}", $value );
279 if( $wgEnableEmail && $wgEnableUserEmail ) {
280 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
284 foreach ( $this->mToggles
as $tname => $tvalue ) {
285 $wgUser->setOption( $tname, $tvalue );
287 if (!$wgAuth->updateExternalDB($wgUser)) {
288 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
291 $wgUser->setCookies();
292 $wgUser->saveSettings();
295 if( $wgEnableEmail ) {
296 $newadr = $this->mUserEmail
;
297 $oldadr = $wgUser->getEmail();
298 if( ($newadr != '') && ($newadr != $oldadr) ) {
299 # the user has supplied a new email address on the login page
300 if( $wgUser->isValidEmailAddr( $newadr ) ) {
301 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
302 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
303 $wgUser->saveSettings();
304 if ($wgEmailAuthentication) {
305 # Mail a temporary password to the dirty address.
306 # User can come back through the confirmation URL to re-enable email.
307 $result = $wgUser->sendConfirmationMail();
308 if( WikiError
::isError( $result ) ) {
309 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
311 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
315 $error = wfMsg( 'invalidemailaddress' );
318 $wgUser->setEmail( $this->mUserEmail
);
319 $wgUser->setCookies();
320 $wgUser->saveSettings();
324 if( $needRedirect && $error === false ) {
325 $title =& SpecialPage
::getTitleFor( "Preferences" );
326 $wgOut->redirect($title->getFullURL('success'));
330 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
331 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
337 function resetPrefs() {
338 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
340 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
341 $this->mUserEmail
= $wgUser->getEmail();
342 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
343 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
345 # language value might be blank, default to content language
346 $this->mUserLanguage
= $wgUser->getOption( 'language', $wgContLanguageCode );
348 $this->mUserVariant
= $wgUser->getOption( 'variant');
349 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
350 $this->mNick
= $wgUser->getOption( 'nickname' );
352 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
353 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
354 $this->mMath
= $wgUser->getOption( 'math' );
355 $this->mDate
= $wgUser->getDatePreference();
356 $this->mRows
= $wgUser->getOption( 'rows' );
357 $this->mCols
= $wgUser->getOption( 'cols' );
358 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
359 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
360 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
361 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
362 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
363 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
364 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
365 $this->mRecent
= $wgUser->getOption( 'rclimit' );
366 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
367 $this->mUnderline
= $wgUser->getOption( 'underline' );
368 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
370 $togs = User
::getToggles();
371 foreach ( $togs as $tname ) {
372 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
375 $namespaces = $wgContLang->getNamespaces();
376 foreach ( $namespaces as $i => $namespace ) {
377 if ( $i >= NS_MAIN
) {
378 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
386 function namespacesCheckboxes() {
389 # Determine namespace checkboxes
390 $namespaces = $wgContLang->getNamespaces();
393 foreach ( $namespaces as $i => $name ) {
396 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
397 $name = str_replace( '_', ' ', $namespaces[$i] );
400 $name = wfMsg( 'blanknamespace' );
402 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
408 function getToggle( $tname, $trailer = false, $disabled = false ) {
409 global $wgUser, $wgLang;
411 $this->mUsedToggles
[$tname] = true;
412 $ttext = $wgLang->getUserToggle( $tname );
414 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
415 $disabled = $disabled ?
' disabled="disabled"' : '';
416 $trailer = $trailer ?
$trailer : '';
417 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
418 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
421 function getToggles( $items ) {
423 foreach( $items as $item ) {
424 if( $item === false )
426 if( is_array( $item ) ) {
427 list( $key, $trailer ) = $item;
432 $out .= $this->getToggle( $key, $trailer );
437 function addRow($td1, $td2) {
438 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
444 function mainPrefsForm( $status , $message = '' ) {
445 global $wgUser, $wgOut, $wgLang, $wgContLang;
446 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
447 global $wgDisableLangConversion;
448 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
449 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
450 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
451 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
453 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
454 $wgOut->setArticleRelated( false );
455 $wgOut->setRobotpolicy( 'noindex,nofollow' );
457 if ( $this->mSuccess ||
'success' == $status ) {
458 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
459 } else if ( 'error' == $status ) {
460 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
461 } else if ( '' != $status ) {
462 $wgOut->addWikitext( $message . "\n----" );
465 $qbs = $wgLang->getQuickbarSettings();
466 $skinNames = $wgLang->getSkinNames();
467 $mathopts = $wgLang->getMathNames();
468 $dateopts = $wgLang->getDatePreferences();
469 $togs = User
::getToggles();
471 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
472 $action = $titleObj->escapeLocalURL();
474 # Pre-expire some toggles so they won't show if disabled
475 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
476 $this->mUsedToggles
[ 'showupdated' ] = true;
477 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
478 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
479 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
480 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
481 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
482 $this->mUsedToggles
[ 'uselivepreview' ] = true;
486 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
487 $this->mRealName
= htmlspecialchars( $this->mRealName
);
488 $rawNick = $this->mNick
;
489 $this->mNick
= htmlspecialchars( $this->mNick
);
490 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
494 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
495 if( $wgUser->getEmailAuthenticationTimestamp() ) {
496 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
497 $disableEmailPrefs = false;
499 $disableEmailPrefs = true;
500 $skin = $wgUser->getSkin();
501 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
502 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
503 wfMsg( 'emailconfirmlink' ) );
506 $emailauthenticated = '';
507 $disableEmailPrefs = false;
510 if ($this->mUserEmail
== '') {
511 $emailauthenticated = wfMsg( 'noemailprefs' );
514 $ps = $this->namespacesCheckboxes();
516 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
517 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
518 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
519 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
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");
531 $userInformationHtml =
541 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
542 $wgOut->addHtml( $userInformationHtml );
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 = Language
::getLanguageNames( true );
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 ) {
606 $selected = ($code == $selectedLang);
607 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
611 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
612 "<select name='wpUserLanguage' id='wpUserLanguage'>$options</select>"
616 /* see if there are multiple language variants to choose from*/
617 if(!$wgDisableLangConversion) {
618 $variants = $wgContLang->getVariants();
619 $variantArray = array();
621 foreach($variants as $v) {
622 $v = str_replace( '_', '-', strtolower($v));
623 if( array_key_exists( $v, $languages ) ) {
624 // If it doesn't have a name, we'll pretend it doesn't exist
625 $variantArray[$v] = $languages[$v];
630 foreach( $variantArray as $code => $name ) {
631 $selected = ($code == $this->mUserVariant
);
632 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
635 if(count($variantArray) > 1) {
637 $this->addRow( wfMsg( 'yourvariant' ),
638 "<select name='wpUserVariant'>$options</select>" )
642 $wgOut->addHTML('</table>');
645 if( $wgAuth->allowPasswordChange() ) {
646 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
647 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
648 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
650 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
653 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
654 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
657 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
658 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
661 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
662 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
665 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
670 if ($wgEnableEmail) {
671 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
675 $enotifwatchlistpages.
676 $enotifusertalkpages.
678 if ($wgEnableUserEmail) {
679 $emf = wfMsg( 'allowemail' );
680 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
682 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
684 $wgOut->addHtml( $this->getToggle( 'ccmeonemails' ) );
686 $wgOut->addHTML( '</fieldset>' );
690 # Show little "help" tips for the real name and email address options
691 if( $wgAllowRealName ||
$wgEnableEmail ) {
692 if( $wgAllowRealName )
693 $tips[] = wfMsg( 'prefs-help-realname' );
695 $tips[] = wfMsg( 'prefs-help-email' );
696 $wgOut->addHtml( '<div class="prefsectiontip">' . implode( '<br />', $tips ) . '</div>' );
699 $wgOut->addHTML( '</fieldset>' );
703 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
704 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
705 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
706 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
707 else { $checked = ""; }
708 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
710 $wgOut->addHtml( "</fieldset>\n\n" );
712 # Need to output a hidden option even if the relevant skin is not in use,
713 # otherwise the preference will get reset to 0 on submit
714 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
719 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
720 $mptitle = Title
::newMainPage();
721 $previewtext = wfMsg('skinpreview');
722 # Only show members of Skin::getSkinNames() rather than
723 # $skinNames (skins is all skin names from Language.php)
724 $validSkinNames = Skin
::getSkinNames();
725 # Sort by UI skin name. First though need to update validSkinNames as sometimes
726 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
727 foreach ($validSkinNames as $skinkey => & $skinname ) {
728 if ( isset( $skinNames[$skinkey] ) ) {
729 $skinname = $skinNames[$skinkey];
732 asort($validSkinNames);
733 foreach ($validSkinNames as $skinkey => $sn ) {
734 if ( in_array( $skinkey, $wgSkipSkins ) ) {
737 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
739 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
740 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
741 if( $skinkey == $wgDefaultSkin )
742 $sn .= ' (' . wfMsg( 'default' ) . ')';
743 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
745 $wgOut->addHTML( "</fieldset>\n\n" );
751 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
752 foreach ( $mathopts as $k => $v ) {
753 $checked = $k == $this->mMath ?
' checked="checked"' : '';
754 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
756 $wgOut->addHTML( "</fieldset>\n\n" );
762 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
765 $imageLimitOptions = null;
766 foreach ( $wgImageLimits as $index => $limits ) {
767 $selected = ($index == $this->mImageSize
);
768 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
769 wfMsg('unit-pixel'), $index, $selected );
772 $imageSizeId = 'wpImageSize';
774 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
775 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
777 Xml
::closeElement( 'select' ) . "</div>\n"
780 $imageThumbOptions = null;
781 foreach ( $wgThumbLimits as $index => $size ) {
782 $selected = ($index == $this->mThumbSize
);
783 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
787 $thumbSizeId = 'wpThumbSize';
789 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
790 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
792 Xml
::closeElement( 'select' ) . "</div>\n"
795 $wgOut->addHTML( "</fieldset>\n\n" );
802 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
805 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
807 $epoch = '20010115161234'; # Wikipedia day
808 foreach( $dateopts as $key ) {
809 if( $key == 'default' ) {
810 $formatted = wfMsgHtml( 'datedefault' );
812 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
814 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
815 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
816 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
819 $wgOut->addHTML( "</fieldset>\n" );
822 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
823 $nowserver = $wgLang->time( $now, false );
825 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
826 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
827 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
829 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
830 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
831 ) . "<tr><td colspan='2'>
832 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
833 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
834 </td></tr></table><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
839 global $wgLivePreview;
840 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
842 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
844 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
846 $this->getToggles( array(
848 'editsectiononrightclick',
857 $wgLivePreview ?
'uselivepreview' : false,
862 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
863 wfInputLabel( wfMsg( 'recentchangescount' ),
864 'wpRecent', 'wpRecent', 3, $this->mRecent
) .
865 $this->getToggles( array(
867 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
873 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
875 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
876 $wgOut->addHtml( '<br /><br />' );
878 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
879 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
880 $wgOut->addHtml( '<br /><br />' );
882 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
884 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
885 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
886 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
887 if( $wgUser->isAllowed( $action ) )
888 $wgOut->addHtml( $this->getToggle( $toggle ) );
890 $this->mUsedToggles
['watchcreations'] = true;
891 $this->mUsedToggles
['watchdefault'] = true;
892 $this->mUsedToggles
['watchmoves'] = true;
893 $this->mUsedToggles
['watchdeletion'] = true;
895 $wgOut->addHtml( '</fieldset>' );
898 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
900 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
901 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
904 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
905 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
908 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
909 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
911 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
915 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
916 $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ),
917 'wpStubs', 'wpStubs', 6, $this->mStubs
) );
918 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
919 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
920 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
921 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
922 $uopt = $wgUser->getOption("underline");
923 $s0 = $uopt == 0 ?
' selected="selected"' : '';
924 $s1 = $uopt == 1 ?
' selected="selected"' : '';
925 $s2 = $uopt == 2 ?
' selected="selected"' : '';
927 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
928 <select name='wpOpunderline' id='wpOpunderline'>
929 <option value=\"0\"$s0>$msgUnderlinenever</option>
930 <option value=\"1\"$s1>$msgUnderlinealways</option>
931 <option value=\"2\"$s2>$msgUnderlinedefault</option>
932 </select></p></div>");
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();
942 $skin = $wgUser->getSkin();
944 <div id='prefsubmit'>
946 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('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>' );