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' ) ?
1 : 0;
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
);
220 $wgUser->setRealName( $this->mRealName
);
222 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
223 $needRedirect = true;
225 $needRedirect = false;
228 $wgUser->setOption( 'language', $this->mUserLanguage
);
229 $wgUser->setOption( 'variant', $this->mUserVariant
);
230 $wgUser->setOption( 'nickname', $this->mNick
);
231 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
232 $wgUser->setOption( 'skin', $this->mSkin
);
235 $wgUser->setOption( 'math', $this->mMath
);
237 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
, 0, 20 ) );
238 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
239 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
240 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
241 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
242 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
243 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
244 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
245 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
246 $wgUser->setOption( 'imagesize', $this->mImageSize
);
247 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
248 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
250 # Set search namespace options
251 foreach( $this->mSearchNs
as $i => $value ) {
252 $wgUser->setOption( "searchNs{$i}", $value );
255 if( $wgEnableEmail && $wgEnableUserEmail ) {
256 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
260 foreach ( $this->mToggles
as $tname => $tvalue ) {
261 $wgUser->setOption( $tname, $tvalue );
263 if (!$wgAuth->updateExternalDB($wgUser)) {
264 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
267 $wgUser->setCookies();
268 $wgUser->saveSettings();
271 if( $wgEnableEmail ) {
272 $newadr = $this->mUserEmail
;
273 $oldadr = $wgUser->getEmail();
274 if( ($newadr != '') && ($newadr != $oldadr) ) {
275 # the user has supplied a new email address on the login page
276 if( $wgUser->isValidEmailAddr( $newadr ) ) {
277 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
278 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
279 $wgUser->saveSettings();
280 if ($wgEmailAuthentication) {
281 # Mail a temporary password to the dirty address.
282 # User can come back through the confirmation URL to re-enable email.
283 $result = $wgUser->sendConfirmationMail();
284 if( WikiError
::isError( $result ) ) {
285 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
287 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
291 $error = wfMsg( 'invalidemailaddress' );
294 $wgUser->setEmail( $this->mUserEmail
);
295 $wgUser->setCookies();
296 $wgUser->saveSettings();
300 if( $needRedirect && $error === false ) {
301 $title =& Title
::makeTitle( NS_SPECIAL
, "Preferences" );
302 $wgOut->redirect($title->getFullURL('success'));
306 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
307 $po = ParserOptions
::newFromUser( $wgUser );
308 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
314 function resetPrefs() {
315 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
317 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
318 $this->mUserEmail
= $wgUser->getEmail();
319 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
320 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
321 $this->mUserLanguage
= $wgUser->getOption( 'language' );
322 if( empty( $this->mUserLanguage
) ) {
323 # Quick hack for conversions, where this value is blank
324 global $wgContLanguageCode;
325 $this->mUserLanguage
= $wgContLanguageCode;
327 $this->mUserVariant
= $wgUser->getOption( 'variant');
328 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
329 $this->mNick
= $wgUser->getOption( 'nickname' );
331 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
332 $this->mSkin
= $wgUser->getOption( 'skin' );
333 $this->mMath
= $wgUser->getOption( 'math' );
334 $this->mDate
= $wgUser->getOption( 'date' );
335 $this->mRows
= $wgUser->getOption( 'rows' );
336 $this->mCols
= $wgUser->getOption( 'cols' );
337 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
338 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
339 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
340 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
341 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
342 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
343 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
344 $this->mRecent
= $wgUser->getOption( 'rclimit' );
345 $this->mUnderline
= $wgUser->getOption( 'underline' );
347 $togs = $wgLang->getUserToggles();
348 foreach ( $togs as $tname ) {
349 $ttext = wfMsg('tog-'.$tname);
350 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
353 $namespaces = $wgContLang->getNamespaces();
354 foreach ( $namespaces as $i => $namespace ) {
355 if ( $i >= NS_MAIN
) {
356 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
364 function namespacesCheckboxes() {
365 global $wgContLang, $wgUser;
367 # Determine namespace checkboxes
368 $namespaces = $wgContLang->getNamespaces();
371 foreach ( $namespaces as $i => $name ) {
374 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
375 $name = str_replace( '_', ' ', $namespaces[$i] );
378 $name = wfMsg( 'blanknamespace' );
380 $r1 .= "<label><input type='checkbox' value='1' name='wpNs$i' {$checked}/>{$name}</label>\n";
386 function getToggle( $tname, $trailer = false) {
387 global $wgUser, $wgLang;
389 $this->mUsedToggles
[$tname] = true;
390 $ttext = $wgLang->getUserToggle( $tname );
392 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
393 $trailer = $trailer ?
$trailer : '';
394 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
395 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
398 function getToggles( $items ) {
400 foreach( $items as $item ) {
401 if( $item === false )
403 if( is_array( $item ) ) {
404 list( $key, $trailer ) = $item;
409 $out .= $this->getToggle( $key, $trailer );
414 function addRow($td1, $td2) {
415 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
421 function mainPrefsForm( $status , $message = '' ) {
422 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
423 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
424 global $wgDisableLangConversion;
425 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
426 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
427 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
428 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
430 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
431 $wgOut->setArticleRelated( false );
432 $wgOut->setRobotpolicy( 'noindex,nofollow' );
434 if ( $this->mSuccess ||
'success' == $status ) {
435 $wgOut->addWikitext( '<span class="preferences-save-success">'. wfMsg( 'savedprefs' ) . "</span>\n----" );
436 } else if ( 'error' == $status ) {
437 $wgOut->addWikitext( "<span class='error'>" . $message . "</span>\n----" );
438 } else if ( '' != $status ) {
439 $wgOut->addWikitext( $message . "\n----" );
441 $uname = $wgUser->getName();
442 $uid = $wgUser->getID();
444 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
445 $wgOut->addWikiText( wfMsg('clearyourcache'));
447 $qbs = $wgLang->getQuickbarSettings();
448 $skinNames = $wgLang->getSkinNames();
449 $mathopts = $wgLang->getMathNames();
450 $dateopts = $wgLang->getDateFormats();
451 $togs = $wgLang->getUserToggles();
453 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
454 $action = $titleObj->escapeLocalURL();
456 # Pre-expire some toggles so they won't show if disabled
457 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
458 $this->mUsedToggles
[ 'showupdated' ] = true;
459 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
460 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
461 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
462 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
466 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
467 $this->mRealName
= htmlspecialchars( $this->mRealName
);
468 $this->mNick
= htmlspecialchars( $this->mNick
);
469 if ( $this->mEmailFlag
) { $emfc = 'checked="checked"'; }
472 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
473 if( $wgUser->getEmailAuthenticationTimestamp() ) {
474 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
476 $skin = $wgUser->getSkin();
477 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
478 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
479 wfMsg( 'emailconfirmlink' ) );
482 $emailauthenticated = '';
485 if ($this->mUserEmail
== '') {
486 $emailauthenticated = wfMsg( 'noemailprefs' );
489 $ps = $this->namespacesCheckboxes();
491 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages' ) : '';
492 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages' ) : '';
493 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits' ) : '';
494 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr' ) : '';
495 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
496 $prefs_help_realname = '';
500 $wgOut->addHTML( "<form id='preferences' name='preferences' action=\"$action\" method='post'>" );
505 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
507 if ($wgAllowRealName) {
510 wfMsg('yourrealname'),
511 "<input type='text' name='wpRealName' value=\"{$this->mRealName}\" size='25' />"
515 if ($wgEnableEmail) {
518 wfMsg( 'youremail' ),
519 "<input type='text' name='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
527 "<input type='text' name='wpNick' value=\"{$this->mNick}\" size='25' />"
529 # FIXME: The <input> part should be where the is, getToggle() needs
530 # to be changed to out return its output in two parts. -ævar
533 $this->getToggle( 'fancysig' )
538 * If a bogus value is set, default to the content language.
539 * Otherwise, no default is selected and the user ends up
540 * with an Afrikaans interface since it's first in the list.
542 $languages = $wgLang->getLanguageNames();
543 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
545 foreach($languages as $code => $name) {
547 /* only add languages that have a file */
548 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
549 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
550 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
551 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
554 $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "<select name='wpUserLanguage'>$selbox</select>" ));
556 /* see if there are multiple language variants to choose from*/
557 if(!$wgDisableLangConversion) {
558 $variants = $wgContLang->getVariants();
560 foreach($variants as $v) {
561 $v = str_replace( '_', '-', strtolower($v));
562 if($name = $languages[$v]) {
563 $variantArray[$v] = $name;
568 foreach($variantArray as $code => $name) {
569 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
570 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
573 if(count($variantArray) > 1) {
575 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
579 $wgOut->addHTML('</table>');
582 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
583 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
584 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
586 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
588 $this->addRow( wfMsg( 'oldpassword' ), "<input type='password' name='wpOldpass' value=\"{$this->mOldpass}\" size='20' />" ) .
589 $this->addRow( wfMsg( 'newpassword' ), "<input type='password' name='wpNewpass' value=\"{$this->mNewpass}\" size='20' />" ) .
590 $this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
592 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
596 if ($wgEnableEmail) {
597 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
601 $enotifwatchlistpages.
602 $enotifusertalkpages.
604 if ($wgEnableUserEmail) {
605 $emf = wfMsg( 'emailflag' );
607 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
610 $wgOut->addHTML( '</fieldset>' );
614 if ($wgAllowRealName ||
$wgEnableEmail) {
615 $wgOut->addHTML("<div class='prefsectiontip'>");
616 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
617 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
618 $wgOut->addHTML( $rn . $em . '</div>');
621 $wgOut->addHTML( '</fieldset>' );
625 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
626 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
627 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
628 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
629 else { $checked = ""; }
630 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
632 $wgOut->addHtml( "</fieldset>\n\n" );
634 # Need to output a hidden option even if the relevant skin is not in use,
635 # otherwise the preference will get reset to 0 on submit
636 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
641 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
642 $mptitle = Title
::newMainPage();
643 $previewtext = wfMsg('skinpreview');
644 # Only show members of $wgValidSkinNames rather than
645 # $skinNames (skins is all skin names from Language.php)
646 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
647 if ( in_array( $skinkey, $wgSkipSkins ) ) {
650 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
651 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
653 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
654 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
655 if( $skinkey == $wgDefaultSkin )
656 $sn .= ' (' . wfMsg( 'default' ) . ')';
657 $wgOut->addHTML( "<input type='radio' name='wpSkin' value=\"$skinkey\"$checked /> {$sn} $previewlink<br/>\n" );
659 $wgOut->addHTML( "</fieldset>\n\n" );
665 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
666 foreach ( $mathopts as $k => $v ) {
667 $checked = $k == $this->mMath ?
' checked="checked"' : '';
668 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
670 $wgOut->addHTML( "</fieldset>\n\n" );
675 $wgOut->addHTML("<fieldset>
676 <legend>" . wfMsg( 'files' ) . "</legend>
677 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
679 $imageLimitOptions = null;
680 foreach ( $wgImageLimits as $index => $limits ) {
681 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
682 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}×{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
685 $imageThumbOptions = null;
686 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
687 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
688 foreach ( $wgThumbLimits as $index => $size ) {
689 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
690 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
692 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
697 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n" );
698 foreach($dateopts as $key => $option) {
699 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
700 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
701 "value=\"$key\"$checked />$option</label></div>\n" );
703 $wgOut->addHTML( "</fieldset>\n\n");
709 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
710 $nowserver = $wgLang->time( $now, false );
712 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ) . '</legend><table>' .
713 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
714 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
716 wfMsg( 'timezoneoffset' ),
717 "<input type='text' name='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
718 ) . "<tr><td colspan='2'>
719 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
720 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
722 <div class='prefsectiontip'>¹" . wfMsg( 'timezonetext' ) . "</div>
727 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
729 <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
730 <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
732 $this->getToggles( array(
734 'editsectiononrightclick',
747 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
750 wfMsg ( 'stubthreshold' ),
751 "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
754 wfMsg( 'recentchangescount' ),
755 "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
758 $this->getToggles( array(
760 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
765 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
766 $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
767 $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
768 $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
769 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
773 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
775 $msgUnderline = htmlspecialchars(wfMsg("tog-underline"));
776 $msgUnderlinenever = htmlspecialchars(wfMsg("underline-never"));
777 $msgUnderlinealways = htmlspecialchars(wfMsg("underline-always"));
778 $msgUnderlinedefault = htmlspecialchars(wfMsg("underline-default"));
779 $uopt = $wgUser->getOption("underline");
780 $s0 = $uopt == 0 ?
" selected=\"selected\"" : "";
781 $s1 = $uopt == 1 ?
" selected=\"selected\"" : "";
782 $s2 = $uopt == 2 ?
" selected=\"selected\"" : "";
784 <div class='toggle'><label>$msgUnderline
785 <select name=\"wpOpunderline\">
786 <option value=\"0\"$s0>$msgUnderlinenever</option>
787 <option value=\"1\"$s1>$msgUnderlinealways</option>
788 <option value=\"2\"$s2>$msgUnderlinedefault</option>
793 foreach ( $togs as $tname ) {
794 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
795 $wgOut->addHTML( $this->getToggle( $tname ) );
798 $wgOut->addHTML( '</fieldset>' );
800 $token = $wgUser->editToken();
802 <div id='prefsubmit'>
804 <input type='submit' name='wpSaveprefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
805 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
806 <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
811 <input type='hidden' name='wpEditToken' value='{$token}' />