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, $mUseAjaxSearch, $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' );
68 $this->mUseAjaxSearch
= $request->getCheck( 'wpUseAjaxSearch' );
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 = User
::getToggles();
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';
102 wfRunHooks( 'InitPreferencesForm', array( $this, $request ) );
106 global $wgUser, $wgOut;
108 if ( $wgUser->isAnon() ) {
109 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext' );
112 if ( wfReadOnly() ) {
113 $wgOut->readOnlyPage();
116 if ( $this->mReset
) {
118 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
119 } else if ( $this->mSaveprefs
) {
120 $this->savePreferences();
123 $this->mainPrefsForm( '' );
129 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
131 $val = min($val, $max);
132 $val = max($val, $min);
139 function validateFloat( &$val, $min, $max=0x7fffffff ) {
140 $val = floatval( $val );
141 $val = min( $val, $max );
142 $val = max( $val, $min );
149 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
154 return $this->validateInt( $val, $min, $max );
161 function validateDate( $val ) {
162 global $wgLang, $wgContLang;
163 if ( $val !== false && (
164 in_array( $val, (array)$wgLang->getDatePreferences() ) ||
165 in_array( $val, (array)$wgContLang->getDatePreferences() ) ) )
169 return $wgLang->getDefaultDateFormat();
174 * Used to validate the user inputed timezone before saving it as
175 * 'timecorrection', will return '00:00' if fed bogus data.
176 * Note: It's not a 100% correct implementation timezone-wise, it will
177 * accept stuff like '14:30',
179 * @param string $s the user input
182 function validateTimeZone( $s ) {
184 if ( strpos( $s, ':' ) ) {
186 $array = explode( ':' , $s );
187 $hour = intval( $array[0] );
188 $minute = intval( $array[1] );
190 $minute = intval( $s * 60 );
191 $hour = intval( $minute / 60 );
192 $minute = abs( $minute ) %
60;
194 # Max is +14:00 and min is -12:00, see:
195 # http://en.wikipedia.org/wiki/Timezone
196 $hour = min( $hour, 14 );
197 $hour = max( $hour, -12 );
198 $minute = min( $minute, 59 );
199 $minute = max( $minute, 0 );
200 $s = sprintf( "%02d:%02d", $hour, $minute );
208 function savePreferences() {
209 global $wgUser, $wgOut, $wgParser;
210 global $wgEnableUserEmail, $wgEnableEmail;
211 global $wgEmailAuthentication, $wgRCMaxAge;
212 global $wgAuth, $wgEmailConfirmToEdit;
215 if ( '' != $this->mNewpass
&& $wgAuth->allowPasswordChange() ) {
216 if ( $this->mNewpass
!= $this->mRetypePass
) {
217 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'badretype' ) );
218 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
222 if (!$wgUser->checkPassword( $this->mOldpass
)) {
223 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'wrongpassword' ) );
224 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
229 $wgUser->setPassword( $this->mNewpass
);
230 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'success' ) );
231 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
232 } catch( PasswordError
$e ) {
233 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'error' ) );
234 $this->mainPrefsForm( 'error', $e->getMessage() );
238 $wgUser->setRealName( $this->mRealName
);
240 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
241 $needRedirect = true;
243 $needRedirect = false;
246 # Validate the signature and clean it up as needed
247 global $wgMaxSigChars;
248 if( mb_strlen( $this->mNick
) > $wgMaxSigChars ) {
250 $this->mainPrefsForm( 'error',
251 wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) );
253 } elseif( $this->mToggles
['fancysig'] ) {
254 if( $wgParser->validateSig( $this->mNick
) !== false ) {
255 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
257 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
261 // When no fancy sig used, make sure ~{3,5} get removed.
262 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
265 $wgUser->setOption( 'language', $this->mUserLanguage
);
266 $wgUser->setOption( 'variant', $this->mUserVariant
);
267 $wgUser->setOption( 'nickname', $this->mNick
);
268 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
269 $wgUser->setOption( 'skin', $this->mSkin
);
272 $wgUser->setOption( 'math', $this->mMath
);
274 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
) );
275 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
276 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
277 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
278 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
279 $wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays
, 1, ceil($wgRCMaxAge / (3600*24))));
280 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
281 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
282 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
283 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
284 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
285 $wgUser->setOption( 'imagesize', $this->mImageSize
);
286 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
287 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
288 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
289 $wgUser->setOption( 'ajaxsearch', $this->mUseAjaxSearch
);
291 # Set search namespace options
292 foreach( $this->mSearchNs
as $i => $value ) {
293 $wgUser->setOption( "searchNs{$i}", $value );
296 if( $wgEnableEmail && $wgEnableUserEmail ) {
297 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
301 foreach ( $this->mToggles
as $tname => $tvalue ) {
302 $wgUser->setOption( $tname, $tvalue );
306 if( $wgEnableEmail ) {
307 $newadr = $this->mUserEmail
;
308 $oldadr = $wgUser->getEmail();
309 if( ($newadr != '') && ($newadr != $oldadr) ) {
310 # the user has supplied a new email address on the login page
311 if( $wgUser->isValidEmailAddr( $newadr ) ) {
312 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
313 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
314 if ($wgEmailAuthentication) {
315 # Mail a temporary password to the dirty address.
316 # User can come back through the confirmation URL to re-enable email.
317 $result = $wgUser->sendConfirmationMail();
318 if( WikiError
::isError( $result ) ) {
319 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
321 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
325 $error = wfMsg( 'invalidemailaddress' );
328 if( $wgEmailConfirmToEdit && empty( $newadr ) ) {
329 $this->mainPrefsForm( 'error', wfMsg( 'noemailtitle' ) );
332 $wgUser->setEmail( $this->mUserEmail
);
334 if( $oldadr != $newadr ) {
335 wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldadr, $newadr ) );
339 if (!$wgAuth->updateExternalDB($wgUser)) {
340 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
345 if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg ) ) ) {
346 $this->mainPrefsForm( 'error', $msg );
350 $wgUser->setCookies();
351 $wgUser->saveSettings();
353 if( $needRedirect && $error === false ) {
354 $title = SpecialPage
::getTitleFor( 'Preferences' );
355 $wgOut->redirect($title->getFullURL('success'));
359 $wgOut->parserOptions( ParserOptions
::newFromUser( $wgUser ) );
360 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
366 function resetPrefs() {
367 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
369 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
370 $this->mUserEmail
= $wgUser->getEmail();
371 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
372 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
374 # language value might be blank, default to content language
375 $this->mUserLanguage
= $wgUser->getOption( 'language', $wgContLanguageCode );
377 $this->mUserVariant
= $wgUser->getOption( 'variant');
378 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
379 $this->mNick
= $wgUser->getOption( 'nickname' );
381 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
382 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
383 $this->mMath
= $wgUser->getOption( 'math' );
384 $this->mDate
= $wgUser->getDatePreference();
385 $this->mRows
= $wgUser->getOption( 'rows' );
386 $this->mCols
= $wgUser->getOption( 'cols' );
387 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
388 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
389 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
390 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
391 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
392 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
393 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
394 $this->mRecent
= $wgUser->getOption( 'rclimit' );
395 $this->mRecentDays
= $wgUser->getOption( 'rcdays' );
396 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
397 $this->mUnderline
= $wgUser->getOption( 'underline' );
398 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
399 $this->mUseAjaxSearch
= $wgUser->getBoolOption( 'ajaxsearch' );
401 $togs = User
::getToggles();
402 foreach ( $togs as $tname ) {
403 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
406 $namespaces = $wgContLang->getNamespaces();
407 foreach ( $namespaces as $i => $namespace ) {
408 if ( $i >= NS_MAIN
) {
409 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
413 wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) );
419 function namespacesCheckboxes() {
422 # Determine namespace checkboxes
423 $namespaces = $wgContLang->getNamespaces();
426 foreach ( $namespaces as $i => $name ) {
429 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
430 $name = str_replace( '_', ' ', $namespaces[$i] );
433 $name = wfMsg( 'blanknamespace' );
435 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
441 function getToggle( $tname, $trailer = false, $disabled = false ) {
442 global $wgUser, $wgLang;
444 $this->mUsedToggles
[$tname] = true;
445 $ttext = $wgLang->getUserToggle( $tname );
447 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
448 $disabled = $disabled ?
' disabled="disabled"' : '';
449 $trailer = $trailer ?
$trailer : '';
450 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
451 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
454 function getToggles( $items ) {
456 foreach( $items as $item ) {
457 if( $item === false )
459 if( is_array( $item ) ) {
460 list( $key, $trailer ) = $item;
465 $out .= $this->getToggle( $key, $trailer );
470 function addRow($td1, $td2) {
471 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
475 * Helper function for user information panel
476 * @param $td1 label for an item
477 * @param $td2 item or null
478 * @param $td3 optional help or null
479 * @return xhtml block
481 function tableRow( $td1, $td2 = null, $td3 = null ) {
484 $align['align'] = $wgContLang->isRtl() ?
'right' : 'left';
486 if ( is_null( $td3 ) ) {
489 $td3 = Xml
::tags( 'tr', null,
490 Xml
::tags( 'td', array( 'colspan' => '2' ), $td3 )
494 if ( is_null( $td2 ) ) {
495 $td1 = Xml
::tags( 'td', $align +
array( 'colspan' => '2' ), $td1 );
498 $td1 = Xml
::tags( 'td', $align, $td1 );
499 $td2 = Xml
::tags( 'td', $align, $td2 );
502 return Xml
::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
509 function mainPrefsForm( $status , $message = '' ) {
510 global $wgUser, $wgOut, $wgLang, $wgContLang;
511 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
512 global $wgDisableLangConversion;
513 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
514 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
515 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
516 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
517 global $wgEmailConfirmToEdit, $wgAjaxSearch;
519 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
520 $wgOut->setArticleRelated( false );
521 $wgOut->setRobotpolicy( 'noindex,nofollow' );
523 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
525 if ( $this->mSuccess ||
'success' == $status ) {
526 $wgOut->wrapWikiMsg( '<div class="successbox"><strong>$1</strong></div>', 'savedprefs' );
527 } else if ( 'error' == $status ) {
528 $wgOut->addWikiText( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
529 } else if ( '' != $status ) {
530 $wgOut->addWikiText( $message . "\n----" );
533 $qbs = $wgLang->getQuickbarSettings();
534 $skinNames = $wgLang->getSkinNames();
535 $mathopts = $wgLang->getMathNames();
536 $dateopts = $wgLang->getDatePreferences();
537 $togs = User
::getToggles();
539 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
540 $action = $titleObj->escapeLocalURL();
542 # Pre-expire some toggles so they won't show if disabled
543 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
544 $this->mUsedToggles
[ 'showupdated' ] = true;
545 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
546 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
547 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
548 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
549 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
550 $this->mUsedToggles
[ 'uselivepreview' ] = true;
553 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
557 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
558 if( $wgUser->getEmailAuthenticationTimestamp() ) {
559 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
560 $disableEmailPrefs = false;
562 $disableEmailPrefs = true;
563 $skin = $wgUser->getSkin();
564 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
565 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
566 wfMsg( 'emailconfirmlink' ) ) . '<br />';
569 $emailauthenticated = '';
570 $disableEmailPrefs = false;
573 if ($this->mUserEmail
== '') {
574 $emailauthenticated = wfMsg( 'noemailprefs' ) . '<br />';
577 $ps = $this->namespacesCheckboxes();
579 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
580 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
581 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
582 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
586 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
587 $wgOut->addHTML( "<div id='preferences'>" );
592 Xml
::openElement( 'fieldset ' ) .
593 Xml
::element( 'legend', null, wfMsg('prefs-personal') ) .
594 Xml
::openElement( 'table' ) .
595 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'prefs-personal' ) ) )
598 $userInformationHtml =
599 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
600 $this->tableRow( wfMsgHtml( 'uid' ), htmlspecialchars( $wgUser->getID() ) ) .
602 wfMsgHtml( 'prefs-edits' ),
603 $wgLang->formatNum( User
::edits( $wgUser->getId() ) )
606 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
607 $wgOut->addHtml( $userInformationHtml );
610 if ( $wgAllowRealName ) {
613 Xml
::label( wfMsg('yourrealname'), 'wpRealName' ),
614 Xml
::input( 'wpRealName', 25, $this->mRealName
, array( 'id' => 'wpRealName' ) ),
615 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
616 wfMsgExt( 'prefs-help-realname', 'parseinline' )
621 if ( $wgEnableEmail ) {
624 Xml
::label( wfMsg('youremail'), 'wpUserEmail' ),
625 Xml
::input( 'wpUserEmail', 25, $this->mUserEmail
, array( 'id' => 'wpUserEmail' ) ),
626 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
627 wfMsgExt( $wgEmailConfirmToEdit ?
'prefs-help-email-required' : 'prefs-help-email', 'parseinline' )
633 global $wgParser, $wgMaxSigChars;
634 if( mb_strlen( $this->mNick
) > $wgMaxSigChars ) {
635 $invalidSig = $this->tableRow(
637 Xml
::element( 'span', array( 'class' => 'error' ),
638 wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) )
640 } elseif( !empty( $this->mToggles
['fancysig'] ) &&
641 false === $wgParser->validateSig( $this->mNick
) ) {
642 $invalidSig = $this->tableRow(
644 Xml
::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
652 Xml
::label( wfMsg( 'yournick' ), 'wpNick' ),
653 Xml
::input( 'wpNick', 25, $this->mNick
,
656 // Note: $wgMaxSigChars is enforced in Unicode characters,
657 // both on the backend and now in the browser.
658 // Badly-behaved requests may still try to submit
659 // an overlong string, however.
660 'maxlength' => $wgMaxSigChars ) )
663 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
666 list( $lsLabel, $lsSelect) = Xml
::languageSelector( $this->mUserLanguage
);
668 $this->tableRow( $lsLabel, $lsSelect )
671 /* see if there are multiple language variants to choose from*/
672 if(!$wgDisableLangConversion) {
673 $variants = $wgContLang->getVariants();
674 $variantArray = array();
676 $languages = Language
::getLanguageNames( true );
677 foreach($variants as $v) {
678 $v = str_replace( '_', '-', strtolower($v));
679 if( array_key_exists( $v, $languages ) ) {
680 // If it doesn't have a name, we'll pretend it doesn't exist
681 $variantArray[$v] = $languages[$v];
686 foreach( $variantArray as $code => $name ) {
687 $selected = ($code == $this->mUserVariant
);
688 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
691 if(count($variantArray) > 1) {
694 Xml
::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
696 array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
705 if( $wgAuth->allowPasswordChange() ) {
707 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'changepassword' ) ) ) .
709 Xml
::label( wfMsg( 'oldpassword' ), 'wpOldpass' ),
710 Xml
::password( 'wpOldpass', 25, $this->mOldpass
, array( 'id' => 'wpOldpass' ) )
713 Xml
::label( wfMsg( 'newpassword' ), 'wpNewpass' ),
714 Xml
::password( 'wpNewpass', 25, $this->mNewpass
, array( 'id' => 'wpNewpass' ) )
717 Xml
::label( wfMsg( 'retypenew' ), 'wpRetypePass' ),
718 Xml
::password( 'wpRetypePass', 25, $this->mRetypePass
, array( 'id' => 'wpRetypePass' ) )
720 Xml
::tags( 'tr', null,
721 Xml
::tags( 'td', array( 'colspan' => '2' ),
722 $this->getToggle( "rememberpassword" )
730 if ( $wgEnableEmail ) {
733 if ($wgEnableUserEmail) {
734 $emf = wfMsg( 'allowemail' );
735 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
737 "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>";
742 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'email' ) ) ) .
746 $enotifwatchlistpages.
747 $enotifusertalkpages.
750 $this->getToggle( 'ccmeonemails' )
757 Xml
::closeElement( 'table' ) .
758 Xml
::closeElement( 'fieldset' )
764 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
765 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
766 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
767 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
768 else { $checked = ""; }
769 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
771 $wgOut->addHtml( "</fieldset>\n\n" );
773 # Need to output a hidden option even if the relevant skin is not in use,
774 # otherwise the preference will get reset to 0 on submit
775 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
780 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
781 $mptitle = Title
::newMainPage();
782 $previewtext = wfMsg('skinpreview');
783 # Only show members of Skin::getSkinNames() rather than
784 # $skinNames (skins is all skin names from Language.php)
785 $validSkinNames = Skin
::getSkinNames();
786 # Sort by UI skin name. First though need to update validSkinNames as sometimes
787 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
788 foreach ($validSkinNames as $skinkey => & $skinname ) {
789 if ( isset( $skinNames[$skinkey] ) ) {
790 $skinname = $skinNames[$skinkey];
793 asort($validSkinNames);
794 foreach ($validSkinNames as $skinkey => $sn ) {
795 if ( in_array( $skinkey, $wgSkipSkins ) ) {
798 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
800 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
801 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
802 if( $skinkey == $wgDefaultSkin )
803 $sn .= ' (' . wfMsg( 'default' ) . ')';
804 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
806 $wgOut->addHTML( "</fieldset>\n\n" );
812 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
813 foreach ( $mathopts as $k => $v ) {
814 $checked = ($k == $this->mMath
);
816 Xml
::openElement( 'div' ) .
817 Xml
::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
818 Xml
::closeElement( 'div' ) . "\n"
821 $wgOut->addHTML( "</fieldset>\n\n" );
827 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
830 $imageLimitOptions = null;
831 foreach ( $wgImageLimits as $index => $limits ) {
832 $selected = ($index == $this->mImageSize
);
833 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
834 wfMsg('unit-pixel'), $index, $selected );
837 $imageSizeId = 'wpImageSize';
839 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
840 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
842 Xml
::closeElement( 'select' ) . "</div>\n"
845 $imageThumbOptions = null;
846 foreach ( $wgThumbLimits as $index => $size ) {
847 $selected = ($index == $this->mThumbSize
);
848 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
852 $thumbSizeId = 'wpThumbSize';
854 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
855 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
857 Xml
::closeElement( 'select' ) . "</div>\n"
860 $wgOut->addHTML( "</fieldset>\n\n" );
867 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
870 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
872 $epoch = '20010115161234'; # Wikipedia day
873 foreach( $dateopts as $key ) {
874 if( $key == 'default' ) {
875 $formatted = wfMsgHtml( 'datedefault' );
877 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
879 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
880 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
881 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
884 $wgOut->addHTML( "</fieldset>\n" );
887 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
888 $nowserver = $wgLang->time( $now, false );
890 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
891 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
892 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
894 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
895 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
896 ) . "<tr><td colspan='2'>
897 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
898 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
899 </td></tr></table><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
904 global $wgLivePreview;
905 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
907 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
909 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
911 $this->getToggles( array(
913 'editsectiononrightclick',
922 $wgLivePreview ?
'uselivepreview' : false,
928 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
931 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
932 $rc .= '<td>' . Xml
::input( 'wpRecentDays', 3, $this->mRecentDays
, array( 'id' => 'wpRecentDays' ) ) . '</td>';
934 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
935 $rc .= '<td>' . Xml
::input( 'wpRecent', 3, $this->mRecent
, array( 'id' => 'wpRecent' ) ) . '</td>';
936 $rc .= '</tr></table>';
937 $wgOut->addHtml( $rc );
939 $wgOut->addHtml( '<br />' );
941 $toggles[] = 'hideminor';
942 if( $wgRCShowWatchingUsers )
943 $toggles[] = 'shownumberswatching';
944 $toggles[] = 'usenewrc';
945 $wgOut->addHtml( $this->getToggles( $toggles ) );
947 $wgOut->addHtml( '</fieldset>' );
950 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
952 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
953 $wgOut->addHtml( '<br /><br />' );
955 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
956 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
957 $wgOut->addHtml( '<br /><br />' );
959 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
961 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
962 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
963 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
964 if( $wgUser->isAllowed( $action ) )
965 $wgOut->addHtml( $this->getToggle( $toggle ) );
967 $this->mUsedToggles
['watchcreations'] = true;
968 $this->mUsedToggles
['watchdefault'] = true;
969 $this->mUsedToggles
['watchmoves'] = true;
970 $this->mUsedToggles
['watchdeletion'] = true;
972 $wgOut->addHtml( '</fieldset>' );
975 $ajaxsearch = $wgAjaxSearch ?
977 wfLabel( wfMsg( 'useajaxsearch' ), 'wpUseAjaxSearch' ),
978 wfCheck( 'wpUseAjaxSearch', $this->mUseAjaxSearch
, array( 'id' => 'wpUseAjaxSearch' ) )
980 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
983 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
984 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
987 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
988 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
991 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
992 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
994 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
998 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
999 $wgOut->addHtml( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label> ' );
1000 $wgOut->addHtml( Xml
::input( 'wpStubs', 6, $this->mStubs
, array( 'id' => 'wpStubs' ) ) );
1001 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
1002 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
1003 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
1004 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
1005 $uopt = $wgUser->getOption("underline");
1006 $s0 = $uopt == 0 ?
' selected="selected"' : '';
1007 $s1 = $uopt == 1 ?
' selected="selected"' : '';
1008 $s2 = $uopt == 2 ?
' selected="selected"' : '';
1010 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
1011 <select name='wpOpunderline' id='wpOpunderline'>
1012 <option value=\"0\"$s0>$msgUnderlinenever</option>
1013 <option value=\"1\"$s1>$msgUnderlinealways</option>
1014 <option value=\"2\"$s2>$msgUnderlinedefault</option>
1015 </select></p></div>");
1017 foreach ( $togs as $tname ) {
1018 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
1019 $wgOut->addHTML( $this->getToggle( $tname ) );
1022 $wgOut->addHTML( '</fieldset>' );
1024 wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
1026 $token = htmlspecialchars( $wgUser->editToken() );
1027 $skin = $wgUser->getSkin();
1029 <div id='prefsubmit'>
1031 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
1032 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
1037 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
1040 $wgOut->addHtml( Xml
::tags( 'div', array( 'class' => "prefcache" ),
1041 wfMsgExt( 'clearyourcache', 'parseinline' ) )