3 * Hold things related to displaying and saving user preferences.
5 * @subpackage SpecialPage
8 if( !defined( 'MEDIAWIKI' ) )
12 * Entry point that create the "Preferences" object
14 function wfSpecialPreferences() {
17 $form = new PreferencesForm( $wgRequest );
22 * Preferences form handling
23 * This object will show the preferences form and can save it as well.
25 * @subpackage SpecialPage
27 class PreferencesForm
{
28 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
29 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
30 var $mUserLanguage, $mUserVariant;
31 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
32 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
39 function PreferencesForm( &$request ) {
40 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
42 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
43 $this->mOldpass
= $request->getVal( 'wpOldpass' );
44 $this->mNewpass
= $request->getVal( 'wpNewpass' );
45 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
46 $this->mStubs
= $request->getVal( 'wpStubs' );
47 $this->mRows
= $request->getVal( 'wpRows' );
48 $this->mCols
= $request->getVal( 'wpCols' );
49 $this->mSkin
= $request->getVal( 'wpSkin' );
50 $this->mMath
= $request->getVal( 'wpMath' );
51 $this->mDate
= $request->getVal( 'wpDate' );
52 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
53 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
54 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
0 : 1;
55 $this->mNick
= $request->getVal( 'wpNick' );
56 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
57 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
58 $this->mSearch
= $request->getVal( 'wpSearch' );
59 $this->mRecent
= $request->getVal( 'wpRecent' );
60 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
61 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
62 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
63 $this->mImageSize
= $request->getVal( 'wpImageSize' );
64 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
65 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
66 $this->mAction
= $request->getVal( 'action' );
67 $this->mReset
= $request->getCheck( 'wpReset' );
68 $this->mPosted
= $request->wasPosted();
69 $this->mSuccess
= $request->getCheck( 'success' );
71 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
73 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
75 # User toggles (the big ugly unsorted list of checkboxes)
76 $this->mToggles
= array();
77 if ( $this->mPosted
) {
78 $togs = $wgLang->getUserToggles();
79 foreach ( $togs as $tname ) {
80 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
84 $this->mUsedToggles
= array();
86 # Search namespace options
87 # Note: namespaces don't necessarily have consecutive keys
88 $this->mSearchNs
= array();
89 if ( $this->mPosted
) {
90 $namespaces = $wgContLang->getNamespaces();
91 foreach ( $namespaces as $i => $namespace ) {
93 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
99 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
100 $this->mUserLanguage
= 'nolanguage';
105 global $wgUser, $wgOut;
107 if ( $wgUser->isAnon() ) {
108 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
111 if ( wfReadOnly() ) {
112 $wgOut->readOnlyPage();
115 if ( $this->mReset
) {
117 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
118 } else if ( $this->mSaveprefs
) {
119 $this->savePreferences();
122 $this->mainPrefsForm( '' );
128 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
130 $val = min($val, $max);
131 $val = max($val, $min);
138 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
143 return $this->validateInt( $val, $min, $max );
150 function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
151 if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) ||
$val == 'ISO 8601' )
158 * Used to validate the user inputed timezone before saving it as
159 * 'timeciorrection', will return '00:00' if fed bogus data.
160 * Note: It's not a 100% correct implementation timezone-wise, it will
161 * accept stuff like '14:30',
163 * @param string $s the user input
166 function validateTimeZone( $s ) {
168 if ( strpos( $s, ':' ) ) {
170 $array = explode( ':' , $s );
171 $hour = intval( $array[0] );
172 $minute = intval( $array[1] );
174 $minute = intval( $s * 60 );
175 $hour = intval( $minute / 60 );
176 $minute = abs( $minute ) %
60;
178 # Max is +14:00 and min is -12:00, see:
179 # http://en.wikipedia.org/wiki/Timezone
180 $hour = min( $hour, 14 );
181 $hour = max( $hour, -12 );
182 $minute = min( $minute, 59 );
183 $minute = max( $minute, 0 );
184 $s = sprintf( "%02d:%02d", $hour, $minute );
192 function savePreferences() {
193 global $wgUser, $wgLang, $wgOut;
194 global $wgEnableUserEmail, $wgEnableEmail;
195 global $wgEmailAuthentication, $wgMinimalPasswordLength;
199 if ( '' != $this->mNewpass
) {
200 if ( $this->mNewpass
!= $this->mRetypePass
) {
201 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
205 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
206 $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
210 if (!$wgUser->checkPassword( $this->mOldpass
)) {
211 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
214 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
215 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
218 $wgUser->setPassword( $this->mNewpass
);
219 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
222 $wgUser->setRealName( $this->mRealName
);
224 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
225 $needRedirect = true;
227 $needRedirect = false;
230 # Validate the signature and clean it up as needed
231 if( $this->mToggles
['fancysig'] ) {
232 if( Parser
::validateSig( $this->mNick
) !== false ) {
233 $this->mNick
= Parser
::cleanSig( $this->mNick
);
235 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
239 $wgUser->setOption( 'language', $this->mUserLanguage
);
240 $wgUser->setOption( 'variant', $this->mUserVariant
);
241 $wgUser->setOption( 'nickname', $this->mNick
);
242 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
243 $wgUser->setOption( 'skin', $this->mSkin
);
246 $wgUser->setOption( 'math', $this->mMath
);
248 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
249 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
250 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
251 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
252 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
253 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
254 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
255 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
256 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
257 $wgUser->setOption( 'imagesize', $this->mImageSize
);
258 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
259 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
261 # Set search namespace options
262 foreach( $this->mSearchNs
as $i => $value ) {
263 $wgUser->setOption( "searchNs{$i}", $value );
266 if( $wgEnableEmail && $wgEnableUserEmail ) {
267 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
271 foreach ( $this->mToggles
as $tname => $tvalue ) {
272 $wgUser->setOption( $tname, $tvalue );
274 if (!$wgAuth->updateExternalDB($wgUser)) {
275 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
278 $wgUser->setCookies();
279 $wgUser->saveSettings();
282 if( $wgEnableEmail ) {
283 $newadr = $this->mUserEmail
;
284 $oldadr = $wgUser->getEmail();
285 if( ($newadr != '') && ($newadr != $oldadr) ) {
286 # the user has supplied a new email address on the login page
287 if( $wgUser->isValidEmailAddr( $newadr ) ) {
288 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
289 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
290 $wgUser->saveSettings();
291 if ($wgEmailAuthentication) {
292 # Mail a temporary password to the dirty address.
293 # User can come back through the confirmation URL to re-enable email.
294 $result = $wgUser->sendConfirmationMail();
295 if( WikiError
::isError( $result ) ) {
296 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
298 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
302 $error = wfMsg( 'invalidemailaddress' );
305 $wgUser->setEmail( $this->mUserEmail
);
306 $wgUser->setCookies();
307 $wgUser->saveSettings();
311 if( $needRedirect && $error === false ) {
312 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
313 $wgOut->redirect($title->getFullURL('success'));
317 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
318 $po = ParserOptions
::newFromUser( $wgUser );
319 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
325 function resetPrefs() {
326 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
328 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
329 $this->mUserEmail
= $wgUser->getEmail();
330 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
331 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
332 $this->mUserLanguage
= $wgUser->getOption( 'language' );
333 if( empty( $this->mUserLanguage
) ) {
334 # Quick hack for conversions, where this value is blank
335 global $wgContLanguageCode;
336 $this->mUserLanguage
= $wgContLanguageCode;
338 $this->mUserVariant
= $wgUser->getOption( 'variant');
339 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
340 $this->mNick
= $wgUser->getOption( 'nickname' );
342 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
343 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
344 $this->mMath
= $wgUser->getOption( 'math' );
345 $this->mDate
= $wgUser->getOption( 'date' );
346 $this->mRows
= $wgUser->getOption( 'rows' );
347 $this->mCols
= $wgUser->getOption( 'cols' );
348 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
349 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
350 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
351 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
352 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
353 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
354 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
355 $this->mRecent
= $wgUser->getOption( 'rclimit' );
356 $this->mUnderline
= $wgUser->getOption( 'underline' );
358 $togs = $wgLang->getUserToggles();
359 foreach ( $togs as $tname ) {
360 $ttext = wfMsg('tog-'.$tname);
361 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
364 $namespaces = $wgContLang->getNamespaces();
365 foreach ( $namespaces as $i => $namespace ) {
366 if ( $i >= NS_MAIN
) {
367 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
375 function namespacesCheckboxes() {
376 global $wgContLang, $wgUser;
378 # Determine namespace checkboxes
379 $namespaces = $wgContLang->getNamespaces();
382 foreach ( $namespaces as $i => $name ) {
385 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
386 $name = str_replace( '_', ' ', $namespaces[$i] );
389 $name = wfMsg( 'blanknamespace' );
391 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
397 function getToggle( $tname, $trailer = false, $disabled = false ) {
398 global $wgUser, $wgLang;
400 $this->mUsedToggles
[$tname] = true;
401 $ttext = $wgLang->getUserToggle( $tname );
403 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
404 $disabled = $disabled ?
' disabled="disabled"' : '';
405 $trailer = $trailer ?
$trailer : '';
406 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
407 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
410 function getToggles( $items ) {
412 foreach( $items as $item ) {
413 if( $item === false )
415 if( is_array( $item ) ) {
416 list( $key, $trailer ) = $item;
421 $out .= $this->getToggle( $key, $trailer );
426 function addRow($td1, $td2) {
427 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
433 function mainPrefsForm( $status , $message = '' ) {
434 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
435 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
436 global $wgDisableLangConversion;
437 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
438 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
439 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
440 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
442 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
443 $wgOut->setArticleRelated( false );
444 $wgOut->setRobotpolicy( 'noindex,nofollow' );
446 if ( $this->mSuccess ||
'success' == $status ) {
447 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
448 } else if ( 'error' == $status ) {
449 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
450 } else if ( '' != $status ) {
451 $wgOut->addWikitext( $message . "\n----" );
454 $qbs = $wgLang->getQuickbarSettings();
455 $skinNames = $wgLang->getSkinNames();
456 $mathopts = $wgLang->getMathNames();
457 $dateopts = $wgLang->getDateFormats();
458 $togs = $wgLang->getUserToggles();
460 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
461 $action = $titleObj->escapeLocalURL();
463 # Pre-expire some toggles so they won't show if disabled
464 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
465 $this->mUsedToggles
[ 'showupdated' ] = true;
466 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
467 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
468 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
469 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
473 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
474 $this->mRealName
= htmlspecialchars( $this->mRealName
);
475 $rawNick = $this->mNick
;
476 $this->mNick
= htmlspecialchars( $this->mNick
);
477 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
481 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
482 if( $wgUser->getEmailAuthenticationTimestamp() ) {
483 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
484 $disableEmailPrefs = false;
486 $disableEmailPrefs = true;
487 $skin = $wgUser->getSkin();
488 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
489 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
490 wfMsg( 'emailconfirmlink' ) );
493 $emailauthenticated = '';
494 $disableEmailPrefs = false;
497 if ($this->mUserEmail
== '') {
498 $emailauthenticated = wfMsg( 'noemailprefs' );
501 $ps = $this->namespacesCheckboxes();
503 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
504 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
505 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
506 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
507 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
508 $prefs_help_realname = '';
512 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
513 $wgOut->addHTML( "<div id='preferences'>" );
518 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
535 if ($wgAllowRealName) {
538 '<label for="wpRealName">' . wfMsg('yourrealname') . '</label>',
539 "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"
543 if ($wgEnableEmail) {
546 '<label for="wpUserEmail">' . wfMsg( 'youremail' ) . '</label>',
547 "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
553 if( !empty( $this->mToggles
['fancysig'] ) &&
554 false === $wgParser->validateSig( $rawNick ) ) {
555 $invalidSig = $this->addRow(
557 '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
565 '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
566 "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
569 # FIXME: The <input> part should be where the is, getToggle() needs
570 # to be changed to out return its output in two parts. -ævar
573 $this->getToggle( 'fancysig' )
578 * Make sure the site language is in the list; a custom language code
579 * might not have a defined name...
581 $languages = $wgLang->getLanguageNames();
582 if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
583 $languages[$wgContLanguageCode] = $wgContLanguageCode;
588 * If a bogus value is set, default to the content language.
589 * Otherwise, no default is selected and the user ends up
590 * with an Afrikaans interface since it's first in the list.
592 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
594 foreach($languages as $code => $name) {
596 /* only add languages that have a file */
597 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
598 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
599 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
600 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
605 '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
606 "<select name='wpUserLanguage' id='wpUserLanguage'>$selbox</select>"
610 /* see if there are multiple language variants to choose from*/
611 if(!$wgDisableLangConversion) {
612 $variants = $wgContLang->getVariants();
613 $variantArray = array();
615 foreach($variants as $v) {
616 $v = str_replace( '_', '-', strtolower($v));
617 if( array_key_exists( $v, $languages ) ) {
618 // If it doesn't have a name, we'll pretend it doesn't exist
619 $variantArray[$v] = $languages[$v];
624 foreach($variantArray as $code => $name) {
625 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
626 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
629 if(count($variantArray) > 1) {
631 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
635 $wgOut->addHTML('</table>');
638 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
639 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
640 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
642 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
645 '<label for="wpOldpass">' . wfMsg( 'oldpassword' ) . '</label>',
646 "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />"
649 '<label for="wpNewpass">' . wfMsg( 'newpassword' ) . '</label>',
650 "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />"
653 '<label for="wpRetypePass">' . wfMsg( 'retypenew' ) . '</label>',
654 "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />"
657 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
661 if ($wgEnableEmail) {
662 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
666 $enotifwatchlistpages.
667 $enotifusertalkpages.
669 if ($wgEnableUserEmail) {
670 $emf = wfMsg( 'allowemail' );
671 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
673 "<div><input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label></div>" );
676 $wgOut->addHTML( '</fieldset>' );
680 if ($wgAllowRealName ||
$wgEnableEmail) {
681 $wgOut->addHTML("<div class='prefsectiontip'>");
682 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
683 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
684 $wgOut->addHTML( $rn . $em . '</div>');
687 $wgOut->addHTML( '</fieldset>' );
691 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
692 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
693 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
694 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
695 else { $checked = ""; }
696 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
698 $wgOut->addHtml( "</fieldset>\n\n" );
700 # Need to output a hidden option even if the relevant skin is not in use,
701 # otherwise the preference will get reset to 0 on submit
702 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
707 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
708 $mptitle = Title
::newMainPage();
709 $previewtext = wfMsg('skinpreview');
710 # Only show members of $wgValidSkinNames rather than
711 # $skinNames (skins is all skin names from Language.php)
712 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
713 if ( in_array( $skinkey, $wgSkipSkins ) ) {
716 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
717 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
719 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
720 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
721 if( $skinkey == $wgDefaultSkin )
722 $sn .= ' (' . wfMsg( 'default' ) . ')';
723 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br/>\n" );
725 $wgOut->addHTML( "</fieldset>\n\n" );
731 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
732 foreach ( $mathopts as $k => $v ) {
733 $checked = $k == $this->mMath ?
' checked="checked"' : '';
734 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
736 $wgOut->addHTML( "</fieldset>\n\n" );
741 $wgOut->addHTML("<fieldset>
742 <legend>" . wfMsg( 'files' ) . "</legend>
743 <div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
745 $imageLimitOptions = null;
746 foreach ( $wgImageLimits as $index => $limits ) {
747 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
748 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}×{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
751 $imageThumbOptions = null;
752 $wgOut->addHTML( "{$imageLimitOptions}</select></div>
753 <div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
754 foreach ( $wgThumbLimits as $index => $size ) {
755 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
756 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
758 $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
765 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
768 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
770 $epoch = '20010115161234';
771 foreach($dateopts as $key => $option) {
772 if( $key == MW_DATE_DEFAULT
) {
773 $formatted = wfMsgHtml( 'datedefault' );
775 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
777 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
778 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
779 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
782 $wgOut->addHTML( "</fieldset>\n" );
785 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
786 $nowserver = $wgLang->time( $now, false );
788 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
789 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
790 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
792 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
793 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
794 ) . "<tr><td colspan='2'>
795 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
796 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
797 </td></tr></table></fieldset>
798 <div class='prefsectiontip'>¹" . wfMsg( 'timezonetext' ) . "</div>
803 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
805 <label for="wpRows">' . wfMsg( 'rows' ) . "</label> <input type='text' name='wpRows' id='wpRows' value=\"{$this->mRows}\" size='3' />
806 <label for='wpCols'>" . wfMsg( 'columns' ) . "</label> <input type='text' name='wpCols' id='wpCols' value=\"{$this->mCols}\" size='3' />
808 $this->getToggles( array(
810 'editsectiononrightclick',
823 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' .
824 '<label for="wpRecent">' . wfMsg ( 'recentchangescount' ) .
825 "</label> <input type='text' name='wpRecent' id='wpRecent' value=\"$this->mRecent\" size='3' />" .
826 $this->getToggles( array(
828 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
833 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
835 '<label for="wpSearch">' . wfMsg( 'resultsperpage' ) . '</label>',
836 "<input type='text' name='wpSearch' id='wpSearch' value=\"$this->mSearch\" size='4' />"
839 '<label for="wpSearchLines">' . wfMsg( 'contextlines' ) . '</label>',
840 "<input type='text' name='wpSearchLines' id='wpSearchLines' value=\"$this->mSearchLines\" size='4' />"
843 '<label for="wpSearchChars">' . wfMsg( 'contextchars' ) . '</label>',
844 "<input type='text' name='wpSearchChars' id='wpSearchChars' value=\"$this->mSearchChars\" size='4' />"
846 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
850 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
852 '<label for="wpStubs">' . htmlspecialchars ( wfMsg ( 'stubthreshold' ) ) . '</label>' .
853 " <input type='text' name='wpStubs' id='wpStubs' value=\"$this->mStubs\" size='6' />"
855 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
856 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
857 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
858 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
859 $uopt = $wgUser->getOption("underline");
860 $s0 = $uopt == 0 ?
' selected="selected"' : '';
861 $s1 = $uopt == 1 ?
' selected="selected"' : '';
862 $s2 = $uopt == 2 ?
' selected="selected"' : '';
864 <div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
865 <select name='wpOpunderline' id='wpOpunderline'>
866 <option value=\"0\"$s0>$msgUnderlinenever</option>
867 <option value=\"1\"$s1>$msgUnderlinealways</option>
868 <option value=\"2\"$s2>$msgUnderlinedefault</option>
872 foreach ( $togs as $tname ) {
873 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
874 $wgOut->addHTML( $this->getToggle( $tname ) );
877 $wgOut->addHTML( '</fieldset>' );
879 $token = $wgUser->editToken();
881 <div id='prefsubmit'>
883 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
884 wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
885 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
890 <input type='hidden' name='wpEditToken' value='{$token}' />
893 $wgOut->addWikiText( '<div class="prefcache">' . wfMsg('clearyourcache') . '</div>' );