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();
70 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
72 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
74 # User toggles (the big ugly unsorted list of checkboxes)
75 $this->mToggles
= array();
76 if ( $this->mPosted
) {
77 $togs = $wgLang->getUserToggles();
78 foreach ( $togs as $tname ) {
79 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
83 $this->mUsedToggles
= array();
85 # Search namespace options
86 # Note: namespaces don't necessarily have consecutive keys
87 $this->mSearchNs
= array();
88 if ( $this->mPosted
) {
89 $namespaces = $wgContLang->getNamespaces();
90 foreach ( $namespaces as $i => $namespace ) {
92 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
98 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
99 $this->mUserLanguage
= 'nolanguage';
104 global $wgUser, $wgOut;
106 if ( $wgUser->isAnon() ) {
107 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
110 if ( wfReadOnly() ) {
111 $wgOut->readOnlyPage();
114 if ( $this->mReset
) {
116 $this->mainPrefsForm( wfMsg( 'prefsreset' ) );
117 } else if ( $this->mSaveprefs
) {
118 $this->savePreferences();
121 $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 );
148 * Used to validate the user inputed timezone before saving it as
149 * 'timeciorrection', will return '00:00' if fed bogus data.
150 * Note: It's not a 100% correct implementation timezone-wise, it will
151 * accept stuff like '14:30',
153 * @param string $s the user input
156 function validateTimeZone( $s ) {
158 if ( strpos( $s, ':' ) ) {
160 $array = explode( ':' , $s );
161 $hour = intval( $array[0] );
162 $minute = intval( $array[1] );
164 $minute = intval( $s * 60 );
165 $hour = intval( $minute / 60 );
166 $minute = abs( $minute ) %
60;
168 # Max is +14:00 and min is -12:00, see:
169 # http://en.wikipedia.org/wiki/Timezone
170 $hour = min( $hour, 14 );
171 $hour = max( $hour, -12 );
172 $minute = min( $minute, 59 );
173 $minute = max( $minute, 0 );
174 $s = sprintf( "%02d:%02d", $hour, $minute );
182 function savePreferences() {
183 global $wgUser, $wgLang, $wgOut;
184 global $wgEnableUserEmail, $wgEnableEmail;
185 global $wgEmailAuthentication, $wgMinimalPasswordLength;
189 if ( '' != $this->mNewpass
) {
190 if ( $this->mNewpass
!= $this->mRetypePass
) {
191 $this->mainPrefsForm( wfMsg( 'badretype' ) );
195 if ( strlen( $this->mNewpass
) < $wgMinimalPasswordLength ) {
196 $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
200 if (!$wgUser->checkPassword( $this->mOldpass
)) {
201 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
204 if (!$wgAuth->setPassword( $wgUser, $this->mNewpass
)) {
205 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
208 $wgUser->setPassword( $this->mNewpass
);
210 $wgUser->setRealName( $this->mRealName
);
211 $wgUser->setOption( 'language', $this->mUserLanguage
);
212 $wgUser->setOption( 'variant', $this->mUserVariant
);
213 $wgUser->setOption( 'nickname', $this->mNick
);
214 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
215 $wgUser->setOption( 'skin', $this->mSkin
);
218 $wgUser->setOption( 'math', $this->mMath
);
220 $wgUser->setOption( 'date', $this->validateInt( $this->mDate
, 0, 10 ) );
221 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
222 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
223 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
224 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
225 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
226 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
227 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
228 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
229 $wgUser->setOption( 'imagesize', $this->mImageSize
);
230 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
231 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
233 # Set search namespace options
234 foreach( $this->mSearchNs
as $i => $value ) {
235 $wgUser->setOption( "searchNs{$i}", $value );
238 if( $wgEnableEmail && $wgEnableUserEmail ) {
239 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
243 foreach ( $this->mToggles
as $tname => $tvalue ) {
244 $wgUser->setOption( $tname, $tvalue );
246 if (!$wgAuth->updateExternalDB($wgUser)) {
247 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
250 $wgUser->setCookies();
251 $wgUser->saveSettings();
253 $error = wfMsg( 'savedprefs' );
254 if( $wgEnableEmail ) {
255 $newadr = $this->mUserEmail
;
256 $oldadr = $wgUser->getEmail();
257 if( ($newadr != '') && ($newadr != $oldadr) ) {
258 # the user has supplied a new email address on the login page
259 if( $wgUser->isValidEmailAddr( $newadr ) ) {
260 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
261 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
262 $wgUser->saveSettings();
263 if ($wgEmailAuthentication) {
264 # Mail a temporary password to the dirty address.
265 # User can come back through the confirmation URL to re-enable email.
266 $result = $wgUser->sendConfirmationMail();
267 if( WikiError
::isError( $result ) ) {
268 $error = wfMsg( 'mailerror', $result->getMessage() );
270 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
274 $error = wfMsg( 'invalidemailaddress' );
277 $wgUser->setEmail( $this->mUserEmail
);
278 $wgUser->setCookies();
279 $wgUser->saveSettings();
283 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
284 $po = ParserOptions
::newFromUser( $wgUser );
285 $this->mainPrefsForm( $error );
291 function resetPrefs() {
292 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
294 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
295 $this->mUserEmail
= $wgUser->getEmail();
296 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
297 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
298 $this->mUserLanguage
= $wgUser->getOption( 'language' );
299 if( empty( $this->mUserLanguage
) ) {
300 # Quick hack for conversions, where this value is blank
301 global $wgContLanguageCode;
302 $this->mUserLanguage
= $wgContLanguageCode;
304 $this->mUserVariant
= $wgUser->getOption( 'variant');
305 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
306 $this->mNick
= $wgUser->getOption( 'nickname' );
308 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
309 $this->mSkin
= $wgUser->getOption( 'skin' );
310 $this->mMath
= $wgUser->getOption( 'math' );
311 $this->mDate
= $wgUser->getOption( 'date' );
312 $this->mRows
= $wgUser->getOption( 'rows' );
313 $this->mCols
= $wgUser->getOption( 'cols' );
314 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
315 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
316 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
317 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
318 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
319 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
320 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
321 $this->mRecent
= $wgUser->getOption( 'rclimit' );
322 $this->mUnderline
= $wgUser->getOption( 'underline' );
324 $togs = $wgLang->getUserToggles();
325 foreach ( $togs as $tname ) {
326 $ttext = wfMsg('tog-'.$tname);
327 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
330 $namespaces = $wgContLang->getNamespaces();
331 foreach ( $namespaces as $i => $namespace ) {
332 if ( $i >= NS_MAIN
) {
333 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
341 function namespacesCheckboxes() {
342 global $wgContLang, $wgUser;
344 # Determine namespace checkboxes
345 $namespaces = $wgContLang->getNamespaces();
348 foreach ( $namespaces as $i => $name ) {
351 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
352 $name = str_replace( '_', ' ', $namespaces[$i] );
355 $name = wfMsg( 'blanknamespace' );
357 $r1 .= "<label><input type='checkbox' value='1' name='wpNs$i' {$checked}/>{$name}</label>\n";
363 function getToggle( $tname, $trailer = false) {
364 global $wgUser, $wgLang;
366 $this->mUsedToggles
[$tname] = true;
367 $ttext = $wgLang->getUserToggle( $tname );
369 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
370 $trailer = $trailer ?
$trailer : '';
371 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
372 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>";
375 function getToggles( $items ) {
377 foreach( $items as $item ) {
378 if( $item === false )
380 if( is_array( $item ) ) {
381 list( $key, $trailer ) = $item;
386 $out .= $this->getToggle( $key, $trailer );
391 function addRow($td1, $td2) {
392 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
398 function mainPrefsForm( $err ) {
399 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
400 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
401 global $wgDisableLangConversion;
402 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
403 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
404 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
405 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
407 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
408 $wgOut->setArticleRelated( false );
409 $wgOut->setRobotpolicy( 'noindex,nofollow' );
412 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
414 $uname = $wgUser->getName();
415 $uid = $wgUser->getID();
417 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
418 $wgOut->addWikiText( wfMsg('clearyourcache'));
420 $qbs = $wgLang->getQuickbarSettings();
421 $skinNames = $wgLang->getSkinNames();
422 $mathopts = $wgLang->getMathNames();
423 $dateopts = $wgLang->getDateFormats();
424 $togs = $wgLang->getUserToggles();
426 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Preferences' );
427 $action = $titleObj->escapeLocalURL();
429 # Pre-expire some toggles so they won't show if disabled
430 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
431 $this->mUsedToggles
[ 'showupdated' ] = true;
432 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
433 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
434 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
435 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
439 $this->mUserEmail
= htmlspecialchars( $this->mUserEmail
);
440 $this->mRealName
= htmlspecialchars( $this->mRealName
);
441 $this->mNick
= htmlspecialchars( $this->mNick
);
442 if ( $this->mEmailFlag
) { $emfc = 'checked="checked"'; }
445 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
446 if( $wgUser->getEmailAuthenticationTimestamp() ) {
447 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
449 $skin = $wgUser->getSkin();
450 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
451 $skin->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' ),
452 wfMsg( 'emailconfirmlink' ) );
455 $emailauthenticated = '';
458 if ($this->mUserEmail
== '') {
459 $emailauthenticated = wfMsg( 'noemailprefs' );
462 $ps = $this->namespacesCheckboxes();
464 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages' ) : '';
465 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages' ) : '';
466 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits' ) : '';
467 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr' ) : '';
468 $prefs_help_email_enotif = ( $wgEnotifWatchlist ||
$wgEnotifUserTalk) ?
' ' . wfMsg('prefs-help-email-enotif') : '';
469 $prefs_help_realname = '';
473 $wgOut->addHTML( "<form id='preferences' name='preferences' action=\"$action\" method='post'>" );
478 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
480 if ($wgAllowRealName) {
483 wfMsg('yourrealname'),
484 "<input type='text' name='wpRealName' value=\"{$this->mRealName}\" size='25' />"
488 if ($wgEnableEmail) {
491 wfMsg( 'youremail' ),
492 "<input type='text' name='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
500 "<input type='text' name='wpNick' value=\"{$this->mNick}\" size='25' />"
502 # FIXME: The <input> part should be where the is, getToggle() needs
503 # to be changed to out return its output in two parts. -รฆvar
506 $this->getToggle( 'fancysig' )
511 * If a bogus value is set, default to the content language.
512 * Otherwise, no default is selected and the user ends up
513 * with an Afrikaans interface since it's first in the list.
515 $languages = $wgLang->getLanguageNames();
516 $selectedLang = isset( $languages[$this->mUserLanguage
] ) ?
$this->mUserLanguage
: $wgContLanguageCode;
518 foreach($languages as $code => $name) {
520 /* only add languages that have a file */
521 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
522 if(file_exists($langfile) ||
$code == $wgContLanguageCode) {
523 $sel = ($code == $selectedLang)?
' selected="selected"' : '';
524 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
527 $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "<select name='wpUserLanguage'>$selbox</select>" ));
529 /* see if there are multiple language variants to choose from*/
530 if(!$wgDisableLangConversion) {
531 $variants = $wgContLang->getVariants();
533 foreach($variants as $v) {
534 $v = str_replace( '_', '-', strtolower($v));
535 if($name = $languages[$v]) {
536 $variantArray[$v] = $name;
541 foreach($variantArray as $code => $name) {
542 $sel = $code == $this->mUserVariant ?
'selected="selected"' : '';
543 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
546 if(count($variantArray) > 1) {
548 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
552 $wgOut->addHTML('</table>');
555 $this->mOldpass
= htmlspecialchars( $this->mOldpass
);
556 $this->mNewpass
= htmlspecialchars( $this->mNewpass
);
557 $this->mRetypePass
= htmlspecialchars( $this->mRetypePass
);
559 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
561 $this->addRow( wfMsg( 'oldpassword' ), "<input type='password' name='wpOldpass' value=\"{$this->mOldpass}\" size='20' />" ) .
562 $this->addRow( wfMsg( 'newpassword' ), "<input type='password' name='wpNewpass' value=\"{$this->mNewpass}\" size='20' />" ) .
563 $this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
565 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
569 if ($wgEnableEmail) {
570 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
574 $enotifwatchlistpages.
575 $enotifusertalkpages.
577 if ($wgEnableUserEmail) {
578 $emf = wfMsg( 'emailflag' );
580 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
583 $wgOut->addHTML( '</fieldset>' );
587 if ($wgAllowRealName ||
$wgEnableEmail) {
588 $wgOut->addHTML("<div class='prefsectiontip'>");
589 $rn = $wgAllowRealName ?
wfMsg('prefs-help-realname') : '';
590 $em = $wgEnableEmail ?
'<br />' . wfMsg('prefs-help-email') : '';
591 $wgOut->addHTML( $rn . $em . '</div>');
594 $wgOut->addHTML( '</fieldset>' );
598 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
599 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
600 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
601 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
602 else { $checked = ""; }
603 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
605 $wgOut->addHtml( "</fieldset>\n\n" );
607 # Need to output a hidden option even if the relevant skin is not in use,
608 # otherwise the preference will get reset to 0 on submit
609 $wgOut->addHTML( "<input type='hidden' name='wpQuickbar' value='{$this->mQuickbar}' />" );
614 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
615 # Only show members of $wgValidSkinNames rather than
616 # $skinNames (skins is all skin names from Language.php)
617 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
618 if ( in_array( $skinkey, $wgSkipSkins ) ) {
621 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
622 $sn = isset( $skinNames[$skinkey] ) ?
$skinNames[$skinkey] : $skinname;
624 if( $skinkey == $wgDefaultSkin )
625 $sn .= ' (' . wfMsg( 'default' ) . ')';
626 $wgOut->addHTML( "<input type='radio' name='wpSkin' value=\"$skinkey\"$checked /> {$sn}<br/>\n" );
628 $wgOut->addHTML( "</fieldset>\n\n" );
634 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
635 foreach ( $mathopts as $k => $v ) {
636 $checked = $k == $this->mMath ?
' checked="checked"' : '';
637 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
639 $wgOut->addHTML( "</fieldset>\n\n" );
644 $wgOut->addHTML("<fieldset>
645 <legend>" . wfMsg( 'files' ) . "</legend>
646 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
648 $imageLimitOptions = null;
649 foreach ( $wgImageLimits as $index => $limits ) {
650 $selected = ($index == $this->mImageSize
) ?
'selected="selected"' : '';
651 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
654 $imageThumbOptions = null;
655 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
656 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
657 foreach ( $wgThumbLimits as $index => $size ) {
658 $selected = ($index == $this->mThumbSize
) ?
'selected="selected"' : '';
659 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
661 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
666 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n" );
667 foreach($dateopts as $key => $option) {
668 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
669 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
670 "value=\"$key\"$checked />$option</label></div>\n" );
672 $wgOut->addHTML( "</fieldset>\n\n");
678 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
679 $nowserver = $wgLang->time( $now, false );
681 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ) . '</legend><table>' .
682 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
683 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
685 wfMsg( 'timezoneoffset' ),
686 "<input type='text' name='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
687 ) . "<tr><td colspan='2'>
688 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
689 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
691 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
696 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
698 <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
699 <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
701 $this->getToggles( array(
703 'editsectiononrightclick',
716 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
719 wfMsg ( 'stubthreshold' ),
720 "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
723 wfMsg( 'recentchangescount' ),
724 "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
727 $this->getToggles( array(
729 $wgRCShowWatchingUsers ?
'shownumberswatching' : false,
734 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
735 $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
736 $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
737 $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
738 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
742 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
744 $msgUnderline = htmlspecialchars(wfMsg("tog-underline"));
745 $msgUnderlinenever = htmlspecialchars(wfMsg("underline-never"));
746 $msgUnderlinealways = htmlspecialchars(wfMsg("underline-always"));
747 $msgUnderlinedefault = htmlspecialchars(wfMsg("underline-default"));
748 $uopt = $wgUser->getOption("underline");
749 $s0 = $uopt == 0 ?
" selected=\"selected\"" : "";
750 $s1 = $uopt == 1 ?
" selected=\"selected\"" : "";
751 $s2 = $uopt == 2 ?
" selected=\"selected\"" : "";
753 <div class='toggle'><label>$msgUnderline
754 <select name=\"wpOpunderline\">
755 <option value=\"0\"$s0>$msgUnderlinenever</option>
756 <option value=\"1\"$s1>$msgUnderlinealways</option>
757 <option value=\"2\"$s2>$msgUnderlinedefault</option>
761 foreach ( $togs as $tname ) {
762 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
763 $wgOut->addHTML( $this->getToggle( $tname ) );
766 $wgOut->addHTML( '</fieldset>' );
768 $token = $wgUser->editToken();
770 <div id='prefsubmit'>
772 <input type='submit' name='wpSaveprefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
773 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
774 <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
779 <input type='hidden' name='wpEditToken' value='{$token}' />