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' );
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 = $wgLang->getUserToggles();
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->errorpage( '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 validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
140 return $this->validateInt( $val, $min, $max );
147 function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
148 if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) ||
$val == 'ISO 8601' )
155 * Used to validate the user inputed timezone before saving it as
156 * 'timeciorrection', will return '00:00' if fed bogus data.
157 * Note: It's not a 100% correct implementation timezone-wise, it will
158 * accept stuff like '14:30',
160 * @param string $s the user input
163 function validateTimeZone( $s ) {
165 if ( strpos( $s, ':' ) ) {
167 $array = explode( ':' , $s );
168 $hour = intval( $array[0] );
169 $minute = intval( $array[1] );
171 $minute = intval( $s * 60 );
172 $hour = intval( $minute / 60 );
173 $minute = abs( $minute ) %
60;
175 # Max is +14:00 and min is -12:00, see:
176 # http://en.wikipedia.org/wiki/Timezone
177 $hour = min( $hour, 14 );
178 $hour = max( $hour, -12 );
179 $minute = min( $minute, 59 );
180 $minute = max( $minute, 0 );
181 $s = sprintf( "%02d:%02d", $hour, $minute );
189 function savePreferences() {
190 global $wgUser, $wgOut, $wgParser;
191 global $wgEnableUserEmail, $wgEnableEmail;
192 global $wgEmailAuthentication, $wgMinimalPasswordLength;
196 if ( '' != $this->mNewpass
) {
197 if ( $this->mNewpass
!= $this->mRetypePass
) {
198 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
202 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
203 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
207 if (!$wgUser->checkPassword( $this->mOldpass
)) {
208 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
211 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
212 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
215 $wgUser->setPassword( $this->mNewpass
);
216 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
219 $wgUser->setRealName( $this->mRealName
);
221 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
222 $needRedirect = true;
224 $needRedirect = false;
227 # Validate the signature and clean it up as needed
228 if( $this->mToggles
['fancysig'] ) {
229 if( Parser
::validateSig( $this->mNick
) !== false ) {
230 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
232 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
236 $wgUser->setOption( 'language', $this->mUserLanguage
);
237 $wgUser->setOption( 'variant', $this->mUserVariant
);
238 $wgUser->setOption( 'nickname', $this->mNick
);
239 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
240 $wgUser->setOption( 'skin', $this->mSkin
);
243 $wgUser->setOption( 'math', $this->mMath
);
245 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
246 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
247 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
248 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
249 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
250 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
251 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
252 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
253 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
254 $wgUser->setOption( 'imagesize', $this->mImageSize
);
255 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
256 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
258 # Set search namespace options
259 foreach( $this->mSearchNs
as $i => $value ) {
260 $wgUser->setOption( "searchNs{$i}", $value );
263 if( $wgEnableEmail && $wgEnableUserEmail ) {
264 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
268 foreach ( $this->mToggles
as $tname => $tvalue ) {
269 $wgUser->setOption( $tname, $tvalue );
271 if (!$wgAuth->updateExternalDB($wgUser)) {
272 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
275 $wgUser->setCookies();
276 $wgUser->saveSettings();
279 if( $wgEnableEmail ) {
280 $newadr = $this->mUserEmail
;
281 $oldadr = $wgUser->getEmail();
282 if( ($newadr != '') && ($newadr != $oldadr) ) {
283 # the user has supplied a new email address on the login page
284 if( $wgUser->isValidEmailAddr( $newadr ) ) {
285 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
286 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
287 $wgUser->saveSettings();
288 if ($wgEmailAuthentication) {
289 # Mail a temporary password to the dirty address.
290 # User can come back through the confirmation URL to re-enable email.
291 $result = $wgUser->sendConfirmationMail();
292 if( WikiError
::isError( $result ) ) {
293 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
295 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
299 $error = wfMsg( 'invalidemailaddress' );
302 $wgUser->setEmail( $this->mUserEmail
);
303 $wgUser->setCookies();
304 $wgUser->saveSettings();
308 if( $needRedirect && $error === false ) {
309 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
310 $wgOut->redirect($title->getFullURL('success'));
314 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
315 $po = ParserOptions
::newFromUser( $wgUser );
316 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
322 function resetPrefs() {
323 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
325 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
326 $this->mUserEmail
= $wgUser->getEmail();
327 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
328 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
329 $this->mUserLanguage
= $wgUser->getOption( 'language' );
330 if( empty( $this->mUserLanguage
) ) {
331 # Quick hack for conversions, where this value is blank
332 global $wgContLanguageCode;
333 $this->mUserLanguage
= $wgContLanguageCode;
335 $this->mUserVariant
= $wgUser->getOption( 'variant');
336 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
337 $this->mNick
= $wgUser->getOption( 'nickname' );
339 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
340 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
341 $this->mMath
= $wgUser->getOption( 'math' );
342 $this->mDate
= $wgUser->getOption( 'date' );
343 $this->mRows
= $wgUser->getOption( 'rows' );
344 $this->mCols
= $wgUser->getOption( 'cols' );
345 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
346 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
347 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
348 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
349 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
350 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
351 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
352 $this->mRecent
= $wgUser->getOption( 'rclimit' );
353 $this->mUnderline
= $wgUser->getOption( 'underline' );
355 $togs = $wgLang->getUserToggles();
356 foreach ( $togs as $tname ) {
357 $ttext = wfMsg('tog-'.$tname);
358 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
361 $namespaces = $wgContLang->getNamespaces();
362 foreach ( $namespaces as $i => $namespace ) {
363 if ( $i >= NS_MAIN
) {
364 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
372 function namespacesCheckboxes() {
375 # Determine namespace checkboxes
376 $namespaces = $wgContLang->getNamespaces();
379 foreach ( $namespaces as $i => $name ) {
382 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
383 $name = str_replace( '_', ' ', $namespaces[$i] );
386 $name = wfMsg( 'blanknamespace' );
388 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
394 function getToggle( $tname, $trailer = false, $disabled = false ) {
395 global $wgUser, $wgLang;
397 $this->mUsedToggles
[$tname] = true;
398 $ttext = $wgLang->getUserToggle( $tname );
400 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
401 $disabled = $disabled ?
' disabled="disabled"' : '';
402 $trailer = $trailer ?
$trailer : '';
403 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
404 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
407 function getToggles( $items ) {
409 foreach( $items as $item ) {
410 if( $item === false )
412 if( is_array( $item ) ) {
413 list( $key, $trailer ) = $item;
418 $out .= $this->getToggle( $key, $trailer );
423 function addRow($td1, $td2) {
424 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
430 function mainPrefsForm( $status , $message = '' ) {
431 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
432 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
433 global $wgDisableLangConversion;
434 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
435 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
436 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
437 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
439 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
440 $wgOut->setArticleRelated( false );
441 $wgOut->setRobotpolicy( 'noindex,nofollow' );
443 if ( $this->mSuccess ||
'success' == $status ) {
444 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
445 } else if ( 'error' == $status ) {
446 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
447 } else if ( '' != $status ) {
448 $wgOut->addWikitext( $message . "\n----" );
451 $qbs = $wgLang->getQuickbarSettings();
452 $skinNames = $wgLang->getSkinNames();
453 $mathopts = $wgLang->getMathNames();
454 $dateopts = $wgLang->getDateFormats();
455 $togs = $wgLang->getUserToggles();
457 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
458 $action = $titleObj->escapeLocalURL();
460 # Pre-expire some toggles so they won't show if disabled
461 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
462 $this->mUsedToggles
[ 'showupdated' ] = true;
463 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
464 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
465 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
466 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
467 $this->mUsedToggles
[ 'uselivepreview' ] = true;
471 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
472 $this->mRealName
= htmlspecialchars( $this->mRealName
);
473 $rawNick = $this->mNick
;
474 $this->mNick
= htmlspecialchars( $this->mNick
);
475 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
479 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
480 if( $wgUser->getEmailAuthenticationTimestamp() ) {
481 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
482 $disableEmailPrefs = false;
484 $disableEmailPrefs = true;
485 $skin = $wgUser->getSkin();
486 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
487 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
488 wfMsg( 'emailconfirmlink' ) );
491 $emailauthenticated = '';
492 $disableEmailPrefs = false;
495 if ($this->mUserEmail
== '') {
496 $emailauthenticated = wfMsg( 'noemailprefs' );
499 $ps = $this->namespacesCheckboxes();
501 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
502 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
503 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
504 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
505 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
506 $prefs_help_realname = '';
510 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
511 $wgOut->addHTML( "<div id='preferences'>" );
516 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
533 if ($wgAllowRealName) {
536 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
537 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
541 if ($wgEnableEmail) {
544 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
545 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
551 if( !empty( $this->mToggles
['fancysig'] ) &&
552 false === $wgParser->validateSig( $rawNick ) ) {
553 $invalidSig = $this->addRow(
555 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
563 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
564 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
567 # FIXME: The <input> part should be where the is, getToggle() needs
568 # to be changed to out return its output in two parts. -ævar
571 $this->getToggle( 'fancysig' )
576 * Make sure the site language is in the list; a custom language code
577 * might not have a defined name...
579 $languages = $wgLang->getLanguageNames();
580 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
581 $languages[$wgContLanguageCode] = $wgContLanguageCode;
586 * If a bogus value is set, default to the content language.
587 * Otherwise, no default is selected and the user ends up
588 * with an Afrikaans interface since it's first in the list.
590 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
592 foreach($languages as $code => $name) {
594 /* only add languages that have a file */
595 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
596 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
597 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
598 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
603 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
604 "<select name='wpUserLanguage' id='wpUserLanguage'>$selbox</select>"
608 /* see if there are multiple language variants to choose from*/
609 if(!$wgDisableLangConversion) {
610 $variants = $wgContLang->getVariants();
611 $variantArray = array();
613 foreach($variants as $v) {
614 $v = str_replace( '_', '-', strtolower($v));
615 if( array_key_exists( $v, $languages ) ) {
616 // If it doesn't have a name, we'll pretend it doesn't exist
617 $variantArray[$v] = $languages[$v];
622 foreach($variantArray as $code => $name) {
623 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
624 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
627 if(count($variantArray) > 1) {
629 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
633 $wgOut->addHTML('</table>');
636 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
637 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
638 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
640 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
643 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
644 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
647 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
648 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
651 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
652 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
655 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
659 if ($wgEnableEmail) {
660 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
664 $enotifwatchlistpages.
665 $enotifusertalkpages.
667 if ($wgEnableUserEmail) {
668 $emf = wfMsg( 'allowemail' );
669 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
671 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
674 $wgOut->addHTML( '</fieldset>' );
678 if ($wgAllowRealName ||
$wgEnableEmail) {
679 $wgOut->addHTML("<div class='prefsectiontip'>");
680 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
681 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
682 $wgOut->addHTML( $rn . $em . '</div>');
685 $wgOut->addHTML( '</fieldset>' );
689 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
690 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
691 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
692 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
693 else { $checked = ""; }
694 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
696 $wgOut->addHtml( "</fieldset>\n\n" );
698 # Need to output a hidden option even if the relevant skin is not in use,
699 # otherwise the preference will get reset to 0 on submit
700 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
705 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
706 $mptitle = Title
::newMainPage();
707 $previewtext = wfMsg('skinpreview');
708 # Only show members of $wgValidSkinNames rather than
709 # $skinNames (skins is all skin names from Language.php)
710 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
711 if ( in_array( $skinkey, $wgSkipSkins ) ) {
714 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
715 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
717 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
718 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
719 if( $skinkey == $wgDefaultSkin )
720 $sn .= ' (' . wfMsg( 'default' ) . ')';
721 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br/>\n" );
723 $wgOut->addHTML( "</fieldset>\n\n" );
729 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
730 foreach ( $mathopts as $k => $v ) {
731 $checked = $k == $this->mMath ?
' checked="checked"' : '';
732 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
734 $wgOut->addHTML( "</fieldset>\n\n" );
739 $wgOut->addHTML("<fieldset>
740 <legend>" . wfMsg( 'files' ) . "</legend>
741 <div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
743 $imageLimitOptions = null;
744 foreach ( $wgImageLimits as $index => $limits ) {
745 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
746 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}×{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
749 $imageThumbOptions = null;
750 $wgOut->addHTML( "{$imageLimitOptions}</select></div>
751 <div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
752 foreach ( $wgThumbLimits as $index => $size ) {
753 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
754 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
756 $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
763 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
766 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
768 $epoch = '20010115161234';
769 foreach($dateopts as $key => $option) {
770 if( $key == MW_DATE_DEFAULT
) {
771 $formatted = wfMsgHtml( 'datedefault' );
773 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
775 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
776 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
777 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
780 $wgOut->addHTML( "</fieldset>\n" );
783 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
784 $nowserver = $wgLang->time( $now, false );
786 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
787 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
788 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
790 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
791 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
792 ) . "<tr><td colspan='2'>
793 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
794 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
795 </td></tr></table></fieldset>
796 <div class='prefsectiontip'>¹" . wfMsg( 'timezonetext' ) . "</div>
801 global $wgLivePreview, $wgUseRCPatrol;
802 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
804 <label for="wpRows">' . wfMsg( 'rows' ) . "</label> <input type='text' name='wpRows' id='wpRows' value=\"{$this->mRows}\" size='3' />
805 <label for='wpCols'>" . wfMsg( 'columns' ) . "</label> <input type='text' name='wpCols' id='wpCols' value=\"{$this->mCols}\" size='3' />
807 $this->getToggles( array(
809 'editsectiononrightclick',
820 $wgLivePreview ?
'uselivepreview' : false,
821 $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ?
'autopatrol' : false,
825 $this->mUsedToggles
['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it
827 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
828 '<label for="wpRecent">' . wfMsg ( 'recentchangescount' ) .
829 "</label> <input type='text' name='wpRecent' id='wpRecent' value=\"$this->mRecent\" size='3' />" .
830 $this->getToggles( array(
832 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
837 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
839 '<label for="wpSearch">' . wfMsg( 'resultsperpage' ) . '</label>',
840 "<input type='text' name='wpSearch' id='wpSearch' value=\"$this->mSearch\" size='4' />"
843 '<label for="wpSearchLines">' . wfMsg( 'contextlines' ) . '</label>',
844 "<input type='text' name='wpSearchLines' id='wpSearchLines' value=\"$this->mSearchLines\" size='4' />"
847 '<label for="wpSearchChars">' . wfMsg( 'contextchars' ) . '</label>',
848 "<input type='text' name='wpSearchChars' id='wpSearchChars' value=\"$this->mSearchChars\" size='4' />"
850 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
854 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
856 '<label for="wpStubs">' . htmlspecialchars ( wfMsg ( 'stubthreshold' ) ) . '</label>' .
857 " <input type='text' name='wpStubs' id='wpStubs' value=\"$this->mStubs\" size='6' />"
859 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
860 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
861 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
862 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
863 $uopt = $wgUser->getOption("underline");
864 $s0 = $uopt == 0 ?
' selected="selected"' : '';
865 $s1 = $uopt == 1 ?
' selected="selected"' : '';
866 $s2 = $uopt == 2 ?
' selected="selected"' : '';
868 <div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
869 <select name='wpOpunderline' id='wpOpunderline'>
870 <option value=\"0\"$s0>$msgUnderlinenever</option>
871 <option value=\"1\"$s1>$msgUnderlinealways</option>
872 <option value=\"2\"$s2>$msgUnderlinedefault</option>
876 foreach ( $togs as $tname ) {
877 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
878 $wgOut->addHTML( $this->getToggle( $tname ) );
881 $wgOut->addHTML( '</fieldset>' );
883 $token = $wgUser->editToken();
885 <div id='prefsubmit'>
887 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
888 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
889 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
894 <input type='hidden' name='wpEditToken' value='{$token}' />
897 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );