3 * Hold things related to displaying and saving user preferences.
4 * @addtogroup SpecialPage
8 * Entry point that create the "Preferences" object
10 function wfSpecialPreferences() {
13 $form = new PreferencesForm( $wgRequest );
18 * Preferences form handling
19 * This object will show the preferences form and can save it as well.
20 * @addtogroup SpecialPage
22 class PreferencesForm
{
23 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
24 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
25 var $mUserLanguage, $mUserVariant;
26 var $mSearch, $mRecent, $mRecentDays, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
27 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
28 var $mUnderline, $mWatchlistEdits;
34 function PreferencesForm( &$request ) {
35 global $wgContLang, $wgUser, $wgAllowRealName;
37 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
38 $this->mOldpass
= $request->getVal( 'wpOldpass' );
39 $this->mNewpass
= $request->getVal( 'wpNewpass' );
40 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
41 $this->mStubs
= $request->getVal( 'wpStubs' );
42 $this->mRows
= $request->getVal( 'wpRows' );
43 $this->mCols
= $request->getVal( 'wpCols' );
44 $this->mSkin
= $request->getVal( 'wpSkin' );
45 $this->mMath
= $request->getVal( 'wpMath' );
46 $this->mDate
= $request->getVal( 'wpDate' );
47 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
48 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
49 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
0 : 1;
50 $this->mNick
= $request->getVal( 'wpNick' );
51 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
52 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
53 $this->mSearch
= $request->getVal( 'wpSearch' );
54 $this->mRecent
= $request->getVal( 'wpRecent' );
55 $this->mRecentDays
= $request->getVal( 'wpRecentDays' );
56 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
57 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
58 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
59 $this->mImageSize
= $request->getVal( 'wpImageSize' );
60 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
61 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
62 $this->mAction
= $request->getVal( 'action' );
63 $this->mReset
= $request->getCheck( 'wpReset' );
64 $this->mPosted
= $request->wasPosted();
65 $this->mSuccess
= $request->getCheck( 'success' );
66 $this->mWatchlistDays
= $request->getVal( 'wpWatchlistDays' );
67 $this->mWatchlistEdits
= $request->getVal( 'wpWatchlistEdits' );
69 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
71 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
73 # User toggles (the big ugly unsorted list of checkboxes)
74 $this->mToggles
= array();
75 if ( $this->mPosted
) {
76 $togs = User
::getToggles();
77 foreach ( $togs as $tname ) {
78 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
82 $this->mUsedToggles
= array();
84 # Search namespace options
85 # Note: namespaces don't necessarily have consecutive keys
86 $this->mSearchNs
= array();
87 if ( $this->mPosted
) {
88 $namespaces = $wgContLang->getNamespaces();
89 foreach ( $namespaces as $i => $namespace ) {
91 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
97 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
98 $this->mUserLanguage
= 'nolanguage';
103 global $wgUser, $wgOut;
105 if ( $wgUser->isAnon() ) {
106 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext' );
109 if ( wfReadOnly() ) {
110 $wgOut->readOnlyPage();
113 if ( $this->mReset
) {
115 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
116 } else if ( $this->mSaveprefs
) {
117 $this->savePreferences();
120 $this->mainPrefsForm( '' );
126 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
128 $val = min($val, $max);
129 $val = max($val, $min);
136 function validateFloat( &$val, $min, $max=0x7fffffff ) {
137 $val = floatval( $val );
138 $val = min( $val, $max );
139 $val = max( $val, $min );
146 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
151 return $this->validateInt( $val, $min, $max );
158 function validateDate( $val ) {
159 global $wgLang, $wgContLang;
160 if ( $val !== false && (
161 in_array( $val, (array)$wgLang->getDatePreferences() ) ||
162 in_array( $val, (array)$wgContLang->getDatePreferences() ) ) )
166 return $wgLang->getDefaultDateFormat();
171 * Used to validate the user inputed timezone before saving it as
172 * 'timecorrection', will return '00:00' if fed bogus data.
173 * Note: It's not a 100% correct implementation timezone-wise, it will
174 * accept stuff like '14:30',
176 * @param string $s the user input
179 function validateTimeZone( $s ) {
181 if ( strpos( $s, ':' ) ) {
183 $array = explode( ':' , $s );
184 $hour = intval( $array[0] );
185 $minute = intval( $array[1] );
187 $minute = intval( $s * 60 );
188 $hour = intval( $minute / 60 );
189 $minute = abs( $minute ) %
60;
191 # Max is +14:00 and min is -12:00, see:
192 # http://en.wikipedia.org/wiki/Timezone
193 $hour = min( $hour, 14 );
194 $hour = max( $hour, -12 );
195 $minute = min( $minute, 59 );
196 $minute = max( $minute, 0 );
197 $s = sprintf( "%02d:%02d", $hour, $minute );
205 function savePreferences() {
206 global $wgUser, $wgOut, $wgParser;
207 global $wgEnableUserEmail, $wgEnableEmail;
208 global $wgEmailAuthentication;
212 if ( '' != $this->mNewpass
&& $wgAuth->allowPasswordChange() ) {
213 if ( $this->mNewpass
!= $this->mRetypePass
) {
214 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
218 if (!$wgUser->checkPassword( $this->mOldpass
)) {
219 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
224 $wgUser->setPassword( $this->mNewpass
);
225 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
226 } catch( PasswordError
$e ) {
227 $this->mainPrefsForm( 'error', $e->getMessage() );
231 $wgUser->setRealName( $this->mRealName
);
233 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
234 $needRedirect = true;
236 $needRedirect = false;
239 # Validate the signature and clean it up as needed
240 if( $this->mToggles
['fancysig'] ) {
241 if( Parser
::validateSig( $this->mNick
) !== false ) {
242 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
244 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
247 // When no fancy sig used, make sure ~{3,5} get removed.
248 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
251 $wgUser->setOption( 'language', $this->mUserLanguage
);
252 $wgUser->setOption( 'variant', $this->mUserVariant
);
253 $wgUser->setOption( 'nickname', $this->mNick
);
254 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
255 $wgUser->setOption( 'skin', $this->mSkin
);
258 $wgUser->setOption( 'math', $this->mMath
);
260 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
) );
261 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
262 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
263 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
264 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
265 $wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays
, 1, 7 ) );
266 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
267 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
268 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
269 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
270 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
271 $wgUser->setOption( 'imagesize', $this->mImageSize
);
272 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
273 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
274 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
276 # Set search namespace options
277 foreach( $this->mSearchNs
as $i => $value ) {
278 $wgUser->setOption( "searchNs{$i}", $value );
281 if( $wgEnableEmail && $wgEnableUserEmail ) {
282 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
286 foreach ( $this->mToggles
as $tname => $tvalue ) {
287 $wgUser->setOption( $tname, $tvalue );
289 if (!$wgAuth->updateExternalDB($wgUser)) {
290 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
293 $wgUser->setCookies();
294 $wgUser->saveSettings();
297 if( $wgEnableEmail ) {
298 $newadr = $this->mUserEmail
;
299 $oldadr = $wgUser->getEmail();
300 if( ($newadr != '') && ($newadr != $oldadr) ) {
301 # the user has supplied a new email address on the login page
302 if( $wgUser->isValidEmailAddr( $newadr ) ) {
303 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
304 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
305 $wgUser->saveSettings();
306 if ($wgEmailAuthentication) {
307 # Mail a temporary password to the dirty address.
308 # User can come back through the confirmation URL to re-enable email.
309 $result = $wgUser->sendConfirmationMail();
310 if( WikiError
::isError( $result ) ) {
311 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
313 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
317 $error = wfMsg( 'invalidemailaddress' );
320 $wgUser->setEmail( $this->mUserEmail
);
321 $wgUser->setCookies();
322 $wgUser->saveSettings();
326 if( $needRedirect && $error === false ) {
327 $title =& SpecialPage
::getTitleFor( "Preferences" );
328 $wgOut->redirect($title->getFullURL('success'));
332 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
333 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
339 function resetPrefs() {
340 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
342 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
343 $this->mUserEmail
= $wgUser->getEmail();
344 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
345 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
347 # language value might be blank, default to content language
348 $this->mUserLanguage
= $wgUser->getOption( 'language', $wgContLanguageCode );
350 $this->mUserVariant
= $wgUser->getOption( 'variant');
351 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
352 $this->mNick
= $wgUser->getOption( 'nickname' );
354 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
355 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
356 $this->mMath
= $wgUser->getOption( 'math' );
357 $this->mDate
= $wgUser->getDatePreference();
358 $this->mRows
= $wgUser->getOption( 'rows' );
359 $this->mCols
= $wgUser->getOption( 'cols' );
360 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
361 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
362 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
363 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
364 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
365 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
366 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
367 $this->mRecent
= $wgUser->getOption( 'rclimit' );
368 $this->mRecentDays
= $wgUser->getOption( 'rcdays' );
369 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
370 $this->mUnderline
= $wgUser->getOption( 'underline' );
371 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
373 $togs = User
::getToggles();
374 foreach ( $togs as $tname ) {
375 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
378 $namespaces = $wgContLang->getNamespaces();
379 foreach ( $namespaces as $i => $namespace ) {
380 if ( $i >= NS_MAIN
) {
381 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
389 function namespacesCheckboxes() {
392 # Determine namespace checkboxes
393 $namespaces = $wgContLang->getNamespaces();
396 foreach ( $namespaces as $i => $name ) {
399 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
400 $name = str_replace( '_', ' ', $namespaces[$i] );
403 $name = wfMsg( 'blanknamespace' );
405 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
411 function getToggle( $tname, $trailer = false, $disabled = false ) {
412 global $wgUser, $wgLang;
414 $this->mUsedToggles
[$tname] = true;
415 $ttext = $wgLang->getUserToggle( $tname );
417 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
418 $disabled = $disabled ?
' disabled="disabled"' : '';
419 $trailer = $trailer ?
$trailer : '';
420 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
421 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
424 function getToggles( $items ) {
426 foreach( $items as $item ) {
427 if( $item === false )
429 if( is_array( $item ) ) {
430 list( $key, $trailer ) = $item;
435 $out .= $this->getToggle( $key, $trailer );
440 function addRow($td1, $td2) {
441 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
445 * Helper function for user information panel
446 * @param $td1 label for an item
447 * @param $td2 item or null
448 * @param $td3 optional help or null
449 * @return xhtml block
451 function tableRow( $td1, $td2 = null, $td3 = null ) {
454 $align['align'] = $wgContLang->isRtl() ?
'right' : 'left';
456 if ( is_null( $td3 ) ) {
459 $td3 = Xml
::tags( 'tr', null,
460 Xml
::tags( 'td', array( 'colspan' => '2' ), $td3 )
464 if ( is_null( $td2 ) ) {
465 $td1 = Xml
::tags( 'td', $align +
array( 'colspan' => '2' ), $td1 );
468 $td1 = Xml
::tags( 'td', $align, $td1 );
469 $td2 = Xml
::tags( 'td', $align, $td2 );
472 return Xml
::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
479 function mainPrefsForm( $status , $message = '' ) {
480 global $wgUser, $wgOut, $wgLang, $wgContLang;
481 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
482 global $wgDisableLangConversion;
483 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
484 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
485 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
486 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
488 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
489 $wgOut->setArticleRelated( false );
490 $wgOut->setRobotpolicy( 'noindex,nofollow' );
492 if ( $this->mSuccess ||
'success' == $status ) {
493 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
494 } else if ( 'error' == $status ) {
495 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
496 } else if ( '' != $status ) {
497 $wgOut->addWikitext( $message . "\n----" );
500 $qbs = $wgLang->getQuickbarSettings();
501 $skinNames = $wgLang->getSkinNames();
502 $mathopts = $wgLang->getMathNames();
503 $dateopts = $wgLang->getDatePreferences();
504 $togs = User
::getToggles();
506 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
507 $action = $titleObj->escapeLocalURL();
509 # Pre-expire some toggles so they won't show if disabled
510 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
511 $this->mUsedToggles
[ 'showupdated' ] = true;
512 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
513 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
514 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
515 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
516 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
517 $this->mUsedToggles
[ 'uselivepreview' ] = true;
520 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
524 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
525 if( $wgUser->getEmailAuthenticationTimestamp() ) {
526 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
527 $disableEmailPrefs = false;
529 $disableEmailPrefs = true;
530 $skin = $wgUser->getSkin();
531 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
532 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
533 wfMsg( 'emailconfirmlink' ) );
536 $emailauthenticated = '';
537 $disableEmailPrefs = false;
540 if ($this->mUserEmail
== '') {
541 $emailauthenticated = wfMsg( 'noemailprefs' );
544 $ps = $this->namespacesCheckboxes();
546 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
547 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
548 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
549 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
553 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
554 $wgOut->addHTML( "<div id='preferences'>" );
559 Xml
::openElement( 'fieldset ' ) .
560 Xml
::element( 'legend', null, wfMsg('prefs-personal') ) .
561 Xml
::openElement( 'table' ) .
562 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'prefs-personal' ) ) )
565 $userInformationHtml =
566 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
567 $this->tableRow( wfMsgHtml( 'uid' ), htmlspecialchars( $wgUser->getID() ) );
569 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
570 $wgOut->addHtml( $userInformationHtml );
573 if ( $wgAllowRealName ) {
576 Xml
::label( wfMsg('yourrealname'), 'wpRealName' ),
577 Xml
::input( 'wpRealName', 25, $this->mRealName
, array( 'id' => 'wpRealName' ) ),
578 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
579 wfMsgExt( 'prefs-help-realname', 'parseinline' )
584 if ( $wgEnableEmail ) {
587 Xml
::label( wfMsg('youremail'), 'wpUserEmail' ),
588 Xml
::input( 'wpUserEmail', 25, $this->mUserEmail
, array( 'id' => 'wpUserEmail' ) ),
589 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
590 wfMsgExt( 'prefs-help-email', 'parseinline' )
597 if( !empty( $this->mToggles
['fancysig'] ) &&
598 false === $wgParser->validateSig( $this->mNick
) ) {
599 $invalidSig = $this->tableRow(
601 Xml
::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
609 Xml
::label( wfMsg( 'yournick' ), 'wpNick' ),
610 Xml
::input( 'wpNick', 25, $this->mNick
, array( 'id' => 'wpNick' ) )
613 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
616 list( $lsLabel, $lsSelect) = Xml
::languageSelector( $this->mUserLanguage
);
618 $this->tableRow( $lsLabel, $lsSelect )
621 /* see if there are multiple language variants to choose from*/
622 if(!$wgDisableLangConversion) {
623 $variants = $wgContLang->getVariants();
624 $variantArray = array();
626 $languages = Language
::getLanguageNames( true );
627 foreach($variants as $v) {
628 $v = str_replace( '_', '-', strtolower($v));
629 if( array_key_exists( $v, $languages ) ) {
630 // If it doesn't have a name, we'll pretend it doesn't exist
631 $variantArray[$v] = $languages[$v];
636 foreach( $variantArray as $code => $name ) {
637 $selected = ($code == $this->mUserVariant
);
638 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
641 if(count($variantArray) > 1) {
644 Xml
::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
646 array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
655 if( $wgAuth->allowPasswordChange() ) {
657 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'changepassword' ) ) ) .
659 Xml
::label( wfMsg( 'oldpassword' ), 'wpOldpass' ),
660 Xml
::input( 'wpOldpass', 25, $this->mOldpass
, array( 'id' => 'wpOldpass' ) )
663 Xml
::label( wfMsg( 'newpassword' ), 'wpNewpass' ),
664 Xml
::input( 'wpNewpass', 25, $this->mNewpass
, array( 'id' => 'wpNewpass' ) )
667 Xml
::label( wfMsg( 'retypenew' ), 'wpRetypePass' ),
668 Xml
::input( 'wpRetypePass', 25, $this->mRetypePass
, array( 'id' => 'wpRetypePass' ) )
670 Xml
::tags( 'tr', null,
671 Xml
::tags( 'td', array( 'colspan' => '2' ),
672 $this->getToggle( "rememberpassword" )
680 if ( $wgEnableEmail ) {
683 if ($wgEnableUserEmail) {
684 $emf = wfMsg( 'allowemail' );
685 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
687 "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>";
692 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'email' ) ) ) .
696 $enotifwatchlistpages.
697 $enotifusertalkpages.
700 $this->getToggle( 'ccmeonemails' )
707 Xml
::closeElement( 'table' ) .
708 Xml
::closeElement( 'fieldset' )
714 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
715 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
716 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
717 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
718 else { $checked = ""; }
719 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
721 $wgOut->addHtml( "</fieldset>\n\n" );
723 # Need to output a hidden option even if the relevant skin is not in use,
724 # otherwise the preference will get reset to 0 on submit
725 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
730 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
731 $mptitle = Title
::newMainPage();
732 $previewtext = wfMsg('skinpreview');
733 # Only show members of Skin::getSkinNames() rather than
734 # $skinNames (skins is all skin names from Language.php)
735 $validSkinNames = Skin
::getSkinNames();
736 # Sort by UI skin name. First though need to update validSkinNames as sometimes
737 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
738 foreach ($validSkinNames as $skinkey => & $skinname ) {
739 if ( isset( $skinNames[$skinkey] ) ) {
740 $skinname = $skinNames[$skinkey];
743 asort($validSkinNames);
744 foreach ($validSkinNames as $skinkey => $sn ) {
745 if ( in_array( $skinkey, $wgSkipSkins ) ) {
748 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
750 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
751 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
752 if( $skinkey == $wgDefaultSkin )
753 $sn .= ' (' . wfMsg( 'default' ) . ')';
754 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
756 $wgOut->addHTML( "</fieldset>\n\n" );
762 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
763 foreach ( $mathopts as $k => $v ) {
764 $checked = ($k == $this->mMath
);
766 Xml
::openElement( 'div' ) .
767 Xml
::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
768 Xml
::closeElement( 'div' ) . "\n"
771 $wgOut->addHTML( "</fieldset>\n\n" );
777 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
780 $imageLimitOptions = null;
781 foreach ( $wgImageLimits as $index => $limits ) {
782 $selected = ($index == $this->mImageSize
);
783 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
784 wfMsg('unit-pixel'), $index, $selected );
787 $imageSizeId = 'wpImageSize';
789 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
790 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
792 Xml
::closeElement( 'select' ) . "</div>\n"
795 $imageThumbOptions = null;
796 foreach ( $wgThumbLimits as $index => $size ) {
797 $selected = ($index == $this->mThumbSize
);
798 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
802 $thumbSizeId = 'wpThumbSize';
804 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
805 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
807 Xml
::closeElement( 'select' ) . "</div>\n"
810 $wgOut->addHTML( "</fieldset>\n\n" );
817 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
820 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
822 $epoch = '20010115161234'; # Wikipedia day
823 foreach( $dateopts as $key ) {
824 if( $key == 'default' ) {
825 $formatted = wfMsgHtml( 'datedefault' );
827 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
829 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
830 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
831 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
834 $wgOut->addHTML( "</fieldset>\n" );
837 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
838 $nowserver = $wgLang->time( $now, false );
840 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
841 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
842 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
844 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
845 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
846 ) . "<tr><td colspan='2'>
847 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
848 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
849 </td></tr></table><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
854 global $wgLivePreview;
855 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
857 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
859 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
861 $this->getToggles( array(
863 'editsectiononrightclick',
872 $wgLivePreview ?
'uselivepreview' : false,
878 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
881 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
882 $rc .= '<td>' . Xml
::input( 'wpRecentDays', 3, $this->mRecentDays
, array( 'id' => 'wpRecentDays' ) ) . '</td>';
884 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
885 $rc .= '<td>' . Xml
::input( 'wpRecent', 3, $this->mRecent
, array( 'id' => 'wpRecent' ) ) . '</td>';
886 $rc .= '</tr></table>';
887 $wgOut->addHtml( $rc );
889 $wgOut->addHtml( '<br />' );
891 $toggles[] = 'hideminor';
892 if( $wgRCShowWatchingUsers )
893 $toggles[] = 'shownumberswatching';
894 $toggles[] = 'usenewrc';
895 $wgOut->addHtml( $this->getToggles( $toggles ) );
897 $wgOut->addHtml( '</fieldset>' );
900 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
902 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
903 $wgOut->addHtml( '<br /><br />' );
905 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
906 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
907 $wgOut->addHtml( '<br /><br />' );
909 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
911 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
912 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
913 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
914 if( $wgUser->isAllowed( $action ) )
915 $wgOut->addHtml( $this->getToggle( $toggle ) );
917 $this->mUsedToggles
['watchcreations'] = true;
918 $this->mUsedToggles
['watchdefault'] = true;
919 $this->mUsedToggles
['watchmoves'] = true;
920 $this->mUsedToggles
['watchdeletion'] = true;
922 $wgOut->addHtml( '</fieldset>' );
925 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
927 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
928 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
931 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
932 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
935 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
936 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
938 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
942 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
943 $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ),
944 'wpStubs', 'wpStubs', 6, $this->mStubs
) );
945 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
946 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
947 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
948 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
949 $uopt = $wgUser->getOption("underline");
950 $s0 = $uopt == 0 ?
' selected="selected"' : '';
951 $s1 = $uopt == 1 ?
' selected="selected"' : '';
952 $s2 = $uopt == 2 ?
' selected="selected"' : '';
954 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
955 <select name='wpOpunderline' id='wpOpunderline'>
956 <option value=\"0\"$s0>$msgUnderlinenever</option>
957 <option value=\"1\"$s1>$msgUnderlinealways</option>
958 <option value=\"2\"$s2>$msgUnderlinedefault</option>
959 </select></p></div>");
961 foreach ( $togs as $tname ) {
962 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
963 $wgOut->addHTML( $this->getToggle( $tname ) );
966 $wgOut->addHTML( '</fieldset>' );
968 $token = $wgUser->editToken();
969 $skin = $wgUser->getSkin();
971 <div id='prefsubmit'>
973 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
974 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
979 <input type='hidden' name='wpEditToken' value='{$token}' />
982 $wgOut->addHtml( Xml
::tags( 'div', array( 'class' => "prefcache" ),
983 wfMsgExt( 'clearyourcache', 'parseinline' ) )