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>";
444 function tableRow( $td1, $td2, $td3 = null ) {
448 $a1['align'] = $wgLang->isRtl() ?
'left' : 'right';
449 $a2['align'] = $wgLang->isRtl() ?
'right' : 'left';
451 if ( is_null( $td3 ) ) {
454 $td3 = Xml
::tags( 'tr', null,
455 Xml
::tags( 'td', array( 'colspan' => '2' ), $td3 )
459 $td1 = Xml
::tags( 'td', $a2, $td1 );
460 $td2 = Xml
::tags( 'td', $a2, $td2 );
462 return Xml
::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
469 function mainPrefsForm( $status , $message = '' ) {
470 global $wgUser, $wgOut, $wgLang, $wgContLang;
471 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
472 global $wgDisableLangConversion;
473 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
474 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
475 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
476 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
478 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
479 $wgOut->setArticleRelated( false );
480 $wgOut->setRobotpolicy( 'noindex,nofollow' );
482 if ( $this->mSuccess ||
'success' == $status ) {
483 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
484 } else if ( 'error' == $status ) {
485 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
486 } else if ( '' != $status ) {
487 $wgOut->addWikitext( $message . "\n----" );
490 $qbs = $wgLang->getQuickbarSettings();
491 $skinNames = $wgLang->getSkinNames();
492 $mathopts = $wgLang->getMathNames();
493 $dateopts = $wgLang->getDatePreferences();
494 $togs = User
::getToggles();
496 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
497 $action = $titleObj->escapeLocalURL();
499 # Pre-expire some toggles so they won't show if disabled
500 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
501 $this->mUsedToggles
[ 'showupdated' ] = true;
502 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
503 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
504 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
505 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
506 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
507 $this->mUsedToggles
[ 'uselivepreview' ] = true;
510 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
514 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
515 if( $wgUser->getEmailAuthenticationTimestamp() ) {
516 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
517 $disableEmailPrefs = false;
519 $disableEmailPrefs = true;
520 $skin = $wgUser->getSkin();
521 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
522 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
523 wfMsg( 'emailconfirmlink' ) );
526 $emailauthenticated = '';
527 $disableEmailPrefs = false;
530 if ($this->mUserEmail
== '') {
531 $emailauthenticated = wfMsg( 'noemailprefs' );
534 $ps = $this->namespacesCheckboxes();
536 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
537 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
538 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
539 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
543 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
544 $wgOut->addHTML( "<div id='preferences'>" );
550 Xml
::openElement( 'fieldset ' ) .
551 Xml
::element( 'legend', null, wfMsg('prefs-personal') ) .
552 Xml
::openElement( 'table' ) .
553 Xml
::tags( 'tr', null,
554 Xml
::tags( 'td', array( 'colspan' => '2' ),
555 Xml
::element( 'h1', null, wfMsg( 'prefs-personal' ) )
560 $userInformationHtml =
561 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
562 $this->tableRow( wfMsgHtml( 'uid' ), htmlspecialchars( $wgUser->getID() ) );
564 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
565 $wgOut->addHtml( $userInformationHtml );
568 if ( $wgAllowRealName ) {
571 Xml
::label( wfMsg('yourrealname'), 'wpRealName' ),
572 Xml
::input( 'wpRealName', 25, $this->mRealName
, array( 'id' => 'wpRealName' ) ),
573 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
574 wfMsgExt( 'prefs-help-realname', 'parseinline' )
579 if ( $wgEnableEmail ) {
582 Xml
::label( wfMsg('youremail'), 'wpUserEmail' ),
583 Xml
::input( 'wpUserEmail', 25, $this->mUserEmail
, array( 'id' => 'wpUserEmail' ) ),
584 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
585 wfMsgExt( 'prefs-help-email', 'parseinline' )
592 if( !empty( $this->mToggles
['fancysig'] ) &&
593 false === $wgParser->validateSig( $this->mNick
) ) {
594 $invalidSig = $this->tableRow(
596 Xml
::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
604 Xml
::label( wfMsg( 'yournick' ), 'wpNick' ),
605 Xml
::input( 'wpNick', 25, $this->mNick
, array( 'id' => 'wpNick' ) )
608 # FIXME: The <input> part should be where the is, getToggle() needs
609 # to be changed to out return its output in two parts. -รฆvar
612 $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 Xml
::tags( 'tr', null,
658 Xml
::tags( 'td', array( 'colspan' => '2' ),
659 Xml
::element( 'h1', null, wfMsg( 'changepassword' ) )
663 Xml
::label( wfMsg( 'oldpassword' ), 'wpOldpass' ),
664 Xml
::input( 'wpOldpass', 25, $this->mOldpass
, array( 'id' => 'wpOldpass' ) )
667 Xml
::label( wfMsg( 'newpassword' ), 'wpNewpass' ),
668 Xml
::input( 'wpNewpass', 25, $this->mNewpass
, array( 'id' => 'wpNewpass' ) )
671 Xml
::label( wfMsg( 'retypenew' ), 'wpRetypePass' ),
672 Xml
::input( 'wpRetypePass', 25, $this->mRetypePass
, array( 'id' => 'wpRetypePass' ) )
674 Xml
::tags( 'tr', null,
675 Xml
::tags( 'td', array( 'colspan' => '2' ),
676 $this->getToggle( "rememberpassword" )
684 if ( $wgEnableEmail ) {
687 if ($wgEnableUserEmail) {
688 $emf = wfMsg( 'allowemail' );
689 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
691 "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>";
696 Xml
::tags( 'tr', null,
697 Xml
::tags( 'td', array( 'colspan' => '2' ),
698 Xml
::element( 'h1', null, wfMsg( 'email' ) )
701 Xml
::tags( 'tr', null,
702 Xml
::tags( 'td', array( 'colspan' => '2' ),
705 $enotifwatchlistpages.
706 $enotifusertalkpages.
709 $this->getToggle( 'ccmeonemails' )
716 Xml
::closeElement( 'table' ) .
717 Xml
::closeElement( 'fieldset' )
724 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
725 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
726 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
727 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
728 else { $checked = ""; }
729 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
731 $wgOut->addHtml( "</fieldset>\n\n" );
733 # Need to output a hidden option even if the relevant skin is not in use,
734 # otherwise the preference will get reset to 0 on submit
735 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
740 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
741 $mptitle = Title
::newMainPage();
742 $previewtext = wfMsg('skinpreview');
743 # Only show members of Skin::getSkinNames() rather than
744 # $skinNames (skins is all skin names from Language.php)
745 $validSkinNames = Skin
::getSkinNames();
746 # Sort by UI skin name. First though need to update validSkinNames as sometimes
747 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
748 foreach ($validSkinNames as $skinkey => & $skinname ) {
749 if ( isset( $skinNames[$skinkey] ) ) {
750 $skinname = $skinNames[$skinkey];
753 asort($validSkinNames);
754 foreach ($validSkinNames as $skinkey => $sn ) {
755 if ( in_array( $skinkey, $wgSkipSkins ) ) {
758 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
760 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
761 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
762 if( $skinkey == $wgDefaultSkin )
763 $sn .= ' (' . wfMsg( 'default' ) . ')';
764 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
766 $wgOut->addHTML( "</fieldset>\n\n" );
772 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
773 foreach ( $mathopts as $k => $v ) {
774 $checked = ($k == $this->mMath
);
776 Xml
::openElement( 'div' ) .
777 Xml
::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
778 Xml
::closeElement( 'div' ) . "\n"
781 $wgOut->addHTML( "</fieldset>\n\n" );
787 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
790 $imageLimitOptions = null;
791 foreach ( $wgImageLimits as $index => $limits ) {
792 $selected = ($index == $this->mImageSize
);
793 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
794 wfMsg('unit-pixel'), $index, $selected );
797 $imageSizeId = 'wpImageSize';
799 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
800 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
802 Xml
::closeElement( 'select' ) . "</div>\n"
805 $imageThumbOptions = null;
806 foreach ( $wgThumbLimits as $index => $size ) {
807 $selected = ($index == $this->mThumbSize
);
808 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
812 $thumbSizeId = 'wpThumbSize';
814 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
815 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
817 Xml
::closeElement( 'select' ) . "</div>\n"
820 $wgOut->addHTML( "</fieldset>\n\n" );
827 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
830 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
832 $epoch = '20010115161234'; # Wikipedia day
833 foreach( $dateopts as $key ) {
834 if( $key == 'default' ) {
835 $formatted = wfMsgHtml( 'datedefault' );
837 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
839 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
840 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
841 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
844 $wgOut->addHTML( "</fieldset>\n" );
847 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
848 $nowserver = $wgLang->time( $now, false );
850 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
851 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
852 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
854 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
855 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
856 ) . "<tr><td colspan='2'>
857 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
858 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
859 </td></tr></table><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
864 global $wgLivePreview;
865 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
867 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
869 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
871 $this->getToggles( array(
873 'editsectiononrightclick',
882 $wgLivePreview ?
'uselivepreview' : false,
888 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
891 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
892 $rc .= '<td>' . Xml
::input( 'wpRecentDays', 3, $this->mRecentDays
, array( 'id' => 'wpRecentDays' ) ) . '</td>';
894 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
895 $rc .= '<td>' . Xml
::input( 'wpRecent', 3, $this->mRecent
, array( 'id' => 'wpRecent' ) ) . '</td>';
896 $rc .= '</tr></table>';
897 $wgOut->addHtml( $rc );
899 $wgOut->addHtml( '<br />' );
901 $toggles[] = 'hideminor';
902 if( $wgRCShowWatchingUsers )
903 $toggles[] = 'shownumberswatching';
904 $toggles[] = 'usenewrc';
905 $wgOut->addHtml( $this->getToggles( $toggles ) );
907 $wgOut->addHtml( '</fieldset>' );
910 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
912 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
913 $wgOut->addHtml( '<br /><br />' );
915 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
916 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
917 $wgOut->addHtml( '<br /><br />' );
919 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
921 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
922 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
923 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
924 if( $wgUser->isAllowed( $action ) )
925 $wgOut->addHtml( $this->getToggle( $toggle ) );
927 $this->mUsedToggles
['watchcreations'] = true;
928 $this->mUsedToggles
['watchdefault'] = true;
929 $this->mUsedToggles
['watchmoves'] = true;
930 $this->mUsedToggles
['watchdeletion'] = true;
932 $wgOut->addHtml( '</fieldset>' );
935 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
937 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
938 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
941 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
942 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
945 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
946 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
948 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
952 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
953 $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ),
954 'wpStubs', 'wpStubs', 6, $this->mStubs
) );
955 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
956 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
957 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
958 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
959 $uopt = $wgUser->getOption("underline");
960 $s0 = $uopt == 0 ?
' selected="selected"' : '';
961 $s1 = $uopt == 1 ?
' selected="selected"' : '';
962 $s2 = $uopt == 2 ?
' selected="selected"' : '';
964 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
965 <select name='wpOpunderline' id='wpOpunderline'>
966 <option value=\"0\"$s0>$msgUnderlinenever</option>
967 <option value=\"1\"$s1>$msgUnderlinealways</option>
968 <option value=\"2\"$s2>$msgUnderlinedefault</option>
969 </select></p></div>");
971 foreach ( $togs as $tname ) {
972 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
973 $wgOut->addHTML( $this->getToggle( $tname ) );
976 $wgOut->addHTML( '</fieldset>' );
978 $token = $wgUser->editToken();
979 $skin = $wgUser->getSkin();
981 <div id='prefsubmit'>
983 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
984 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
989 <input type='hidden' name='wpEditToken' value='{$token}' />
992 $wgOut->addHtml( Xml
::tags( 'div', array( 'class' => "prefcache" ),
993 wfMsgExt( 'clearyourcache', 'parseinline' ) )