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 wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass
, 'badretype' ) );
215 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
219 if (!$wgUser->checkPassword( $this->mOldpass
)) {
220 wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass
, 'wrongpassword' ) );
221 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
226 $wgUser->setPassword( $this->mNewpass
);
227 wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass
, 'success' ) );
228 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
229 } catch( PasswordError
$e ) {
230 wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass
, 'error' ) );
231 $this->mainPrefsForm( 'error', $e->getMessage() );
235 $wgUser->setRealName( $this->mRealName
);
237 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
238 $needRedirect = true;
240 $needRedirect = false;
243 # Validate the signature and clean it up as needed
244 global $wgMaxSigChars;
245 if( mb_strlen( $this->mNick
) > $wgMaxSigChars ) {
247 $this->mainPrefsForm( 'error',
248 wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) );
250 } elseif( $this->mToggles
['fancysig'] ) {
251 if( Parser
::validateSig( $this->mNick
) !== false ) {
252 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
254 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
258 // When no fancy sig used, make sure ~{3,5} get removed.
259 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
262 $wgUser->setOption( 'language', $this->mUserLanguage
);
263 $wgUser->setOption( 'variant', $this->mUserVariant
);
264 $wgUser->setOption( 'nickname', $this->mNick
);
265 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
266 $wgUser->setOption( 'skin', $this->mSkin
);
269 $wgUser->setOption( 'math', $this->mMath
);
271 $wgUser->setOption( 'date', $this->validateDate( $this->mDate
) );
272 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch
) );
273 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines
) );
274 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars
) );
275 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent
) );
276 $wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays
, 1, 7 ) );
277 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
278 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows
, 4, 1000 ) );
279 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols
, 4, 1000 ) );
280 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs
) );
281 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff
, -12, 14 ) );
282 $wgUser->setOption( 'imagesize', $this->mImageSize
);
283 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
284 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline
, 0, 2) );
285 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays
, 0, 7 ) );
287 # Set search namespace options
288 foreach( $this->mSearchNs
as $i => $value ) {
289 $wgUser->setOption( "searchNs{$i}", $value );
292 if( $wgEnableEmail && $wgEnableUserEmail ) {
293 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
297 foreach ( $this->mToggles
as $tname => $tvalue ) {
298 $wgUser->setOption( $tname, $tvalue );
300 if (!$wgAuth->updateExternalDB($wgUser)) {
301 $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
304 $wgUser->setCookies();
305 $wgUser->saveSettings();
308 if( $wgEnableEmail ) {
309 $newadr = $this->mUserEmail
;
310 $oldadr = $wgUser->getEmail();
311 if( ($newadr != '') && ($newadr != $oldadr) ) {
312 # the user has supplied a new email address on the login page
313 if( $wgUser->isValidEmailAddr( $newadr ) ) {
314 $wgUser->mEmail
= $newadr; # new behaviour: set this new emailaddr from login-page into user database record
315 $wgUser->mEmailAuthenticated
= null; # but flag as "dirty" = unauthenticated
316 $wgUser->saveSettings();
317 if ($wgEmailAuthentication) {
318 # Mail a temporary password to the dirty address.
319 # User can come back through the confirmation URL to re-enable email.
320 $result = $wgUser->sendConfirmationMail();
321 if( WikiError
::isError( $result ) ) {
322 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
324 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
328 $error = wfMsg( 'invalidemailaddress' );
331 $wgUser->setEmail( $this->mUserEmail
);
332 $wgUser->setCookies();
333 $wgUser->saveSettings();
335 if( $oldadr != $newadr ) {
336 wfRunHooks( "PrefsEmailAudit", array( $wgUser, $oldadr, $newadr ) );
340 if( $needRedirect && $error === false ) {
341 $title =& SpecialPage
::getTitleFor( "Preferences" );
342 $wgOut->redirect($title->getFullURL('success'));
346 $wgOut->setParserOptions( ParserOptions
::newFromUser( $wgUser ) );
347 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
353 function resetPrefs() {
354 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
356 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
357 $this->mUserEmail
= $wgUser->getEmail();
358 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
359 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
361 # language value might be blank, default to content language
362 $this->mUserLanguage
= $wgUser->getOption( 'language', $wgContLanguageCode );
364 $this->mUserVariant
= $wgUser->getOption( 'variant');
365 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
366 $this->mNick
= $wgUser->getOption( 'nickname' );
368 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
369 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
370 $this->mMath
= $wgUser->getOption( 'math' );
371 $this->mDate
= $wgUser->getDatePreference();
372 $this->mRows
= $wgUser->getOption( 'rows' );
373 $this->mCols
= $wgUser->getOption( 'cols' );
374 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
375 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
376 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
377 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
378 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
379 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
380 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
381 $this->mRecent
= $wgUser->getOption( 'rclimit' );
382 $this->mRecentDays
= $wgUser->getOption( 'rcdays' );
383 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
384 $this->mUnderline
= $wgUser->getOption( 'underline' );
385 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
387 $togs = User
::getToggles();
388 foreach ( $togs as $tname ) {
389 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
392 $namespaces = $wgContLang->getNamespaces();
393 foreach ( $namespaces as $i => $namespace ) {
394 if ( $i >= NS_MAIN
) {
395 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
403 function namespacesCheckboxes() {
406 # Determine namespace checkboxes
407 $namespaces = $wgContLang->getNamespaces();
410 foreach ( $namespaces as $i => $name ) {
413 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
414 $name = str_replace( '_', ' ', $namespaces[$i] );
417 $name = wfMsg( 'blanknamespace' );
419 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
425 function getToggle( $tname, $trailer = false, $disabled = false ) {
426 global $wgUser, $wgLang;
428 $this->mUsedToggles
[$tname] = true;
429 $ttext = $wgLang->getUserToggle( $tname );
431 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
432 $disabled = $disabled ?
' disabled="disabled"' : '';
433 $trailer = $trailer ?
$trailer : '';
434 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
435 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
438 function getToggles( $items ) {
440 foreach( $items as $item ) {
441 if( $item === false )
443 if( is_array( $item ) ) {
444 list( $key, $trailer ) = $item;
449 $out .= $this->getToggle( $key, $trailer );
454 function addRow($td1, $td2) {
455 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
459 * Helper function for user information panel
460 * @param $td1 label for an item
461 * @param $td2 item or null
462 * @param $td3 optional help or null
463 * @return xhtml block
465 function tableRow( $td1, $td2 = null, $td3 = null ) {
468 $align['align'] = $wgContLang->isRtl() ?
'right' : 'left';
470 if ( is_null( $td3 ) ) {
473 $td3 = Xml
::tags( 'tr', null,
474 Xml
::tags( 'td', array( 'colspan' => '2' ), $td3 )
478 if ( is_null( $td2 ) ) {
479 $td1 = Xml
::tags( 'td', $align +
array( 'colspan' => '2' ), $td1 );
482 $td1 = Xml
::tags( 'td', $align, $td1 );
483 $td2 = Xml
::tags( 'td', $align, $td2 );
486 return Xml
::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
493 function mainPrefsForm( $status , $message = '' ) {
494 global $wgUser, $wgOut, $wgLang, $wgContLang;
495 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
496 global $wgDisableLangConversion;
497 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
498 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
499 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
500 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
502 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
503 $wgOut->setArticleRelated( false );
504 $wgOut->setRobotpolicy( 'noindex,nofollow' );
506 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
508 if ( $this->mSuccess ||
'success' == $status ) {
509 $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
510 } else if ( 'error' == $status ) {
511 $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
512 } else if ( '' != $status ) {
513 $wgOut->addWikitext( $message . "\n----" );
516 $qbs = $wgLang->getQuickbarSettings();
517 $skinNames = $wgLang->getSkinNames();
518 $mathopts = $wgLang->getMathNames();
519 $dateopts = $wgLang->getDatePreferences();
520 $togs = User
::getToggles();
522 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
523 $action = $titleObj->escapeLocalURL();
525 # Pre-expire some toggles so they won't show if disabled
526 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
527 $this->mUsedToggles
[ 'showupdated' ] = true;
528 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
529 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
530 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
531 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
532 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
533 $this->mUsedToggles
[ 'uselivepreview' ] = true;
536 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
540 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
541 if( $wgUser->getEmailAuthenticationTimestamp() ) {
542 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
543 $disableEmailPrefs = false;
545 $disableEmailPrefs = true;
546 $skin = $wgUser->getSkin();
547 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
548 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
549 wfMsg( 'emailconfirmlink' ) );
552 $emailauthenticated = '';
553 $disableEmailPrefs = false;
556 if ($this->mUserEmail
== '') {
557 $emailauthenticated = wfMsg( 'noemailprefs' );
560 $ps = $this->namespacesCheckboxes();
562 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
563 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
564 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
565 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
569 $wgOut->addHTML( "<form action=\"$action\" method='post'>" );
570 $wgOut->addHTML( "<div id='preferences'>" );
575 Xml
::openElement( 'fieldset ' ) .
576 Xml
::element( 'legend', null, wfMsg('prefs-personal') ) .
577 Xml
::openElement( 'table' ) .
578 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'prefs-personal' ) ) )
581 $userInformationHtml =
582 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
583 $this->tableRow( wfMsgHtml( 'uid' ), htmlspecialchars( $wgUser->getID() ) );
585 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
586 $wgOut->addHtml( $userInformationHtml );
589 if ( $wgAllowRealName ) {
592 Xml
::label( wfMsg('yourrealname'), 'wpRealName' ),
593 Xml
::input( 'wpRealName', 25, $this->mRealName
, array( 'id' => 'wpRealName' ) ),
594 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
595 wfMsgExt( 'prefs-help-realname', 'parseinline' )
600 if ( $wgEnableEmail ) {
603 Xml
::label( wfMsg('youremail'), 'wpUserEmail' ),
604 Xml
::input( 'wpUserEmail', 25, $this->mUserEmail
, array( 'id' => 'wpUserEmail' ) ),
605 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
606 wfMsgExt( 'prefs-help-email', 'parseinline' )
612 global $wgParser, $wgMaxSigChars;
613 if( mb_strlen( $this->mNick
) > $wgMaxSigChars ) {
614 $invalidSig = $this->tableRow(
616 Xml
::element( 'span', array( 'class' => 'error' ),
617 wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) )
619 } elseif( !empty( $this->mToggles
['fancysig'] ) &&
620 false === $wgParser->validateSig( $this->mNick
) ) {
621 $invalidSig = $this->tableRow(
623 Xml
::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
631 Xml
::label( wfMsg( 'yournick' ), 'wpNick' ),
632 Xml
::input( 'wpNick', 25, $this->mNick
,
635 // Note: $wgMaxSigChars is enforced in Unicode characters,
636 // both on the backend and now in the browser.
637 // Badly-behaved requests may still try to submit
638 // an overlong string, however.
639 'maxlength' => $wgMaxSigChars ) )
642 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
645 list( $lsLabel, $lsSelect) = Xml
::languageSelector( $this->mUserLanguage
);
647 $this->tableRow( $lsLabel, $lsSelect )
650 /* see if there are multiple language variants to choose from*/
651 if(!$wgDisableLangConversion) {
652 $variants = $wgContLang->getVariants();
653 $variantArray = array();
655 $languages = Language
::getLanguageNames( true );
656 foreach($variants as $v) {
657 $v = str_replace( '_', '-', strtolower($v));
658 if( array_key_exists( $v, $languages ) ) {
659 // If it doesn't have a name, we'll pretend it doesn't exist
660 $variantArray[$v] = $languages[$v];
665 foreach( $variantArray as $code => $name ) {
666 $selected = ($code == $this->mUserVariant
);
667 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
670 if(count($variantArray) > 1) {
673 Xml
::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
675 array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
684 if( $wgAuth->allowPasswordChange() ) {
686 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'changepassword' ) ) ) .
688 Xml
::label( wfMsg( 'oldpassword' ), 'wpOldpass' ),
689 Xml
::password( 'wpOldpass', 25, $this->mOldpass
, array( 'id' => 'wpOldpass' ) )
692 Xml
::label( wfMsg( 'newpassword' ), 'wpNewpass' ),
693 Xml
::password( 'wpNewpass', 25, $this->mNewpass
, array( 'id' => 'wpNewpass' ) )
696 Xml
::label( wfMsg( 'retypenew' ), 'wpRetypePass' ),
697 Xml
::password( 'wpRetypePass', 25, $this->mRetypePass
, array( 'id' => 'wpRetypePass' ) )
699 Xml
::tags( 'tr', null,
700 Xml
::tags( 'td', array( 'colspan' => '2' ),
701 $this->getToggle( "rememberpassword" )
709 if ( $wgEnableEmail ) {
712 if ($wgEnableUserEmail) {
713 $emf = wfMsg( 'allowemail' );
714 $disabled = $disableEmailPrefs ?
' disabled="disabled"' : '';
716 "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>";
721 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'email' ) ) ) .
725 $enotifwatchlistpages.
726 $enotifusertalkpages.
729 $this->getToggle( 'ccmeonemails' )
736 Xml
::closeElement( 'table' ) .
737 Xml
::closeElement( 'fieldset' )
743 if ($this->mSkin
== 'cologneblue' ||
$this->mSkin
== 'standard') {
744 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
745 for ( $i = 0; $i < count( $qbs ); ++
$i ) {
746 if ( $i == $this->mQuickbar
) { $checked = ' checked="checked"'; }
747 else { $checked = ""; }
748 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
750 $wgOut->addHtml( "</fieldset>\n\n" );
752 # Need to output a hidden option even if the relevant skin is not in use,
753 # otherwise the preference will get reset to 0 on submit
754 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar
) );
759 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
760 $mptitle = Title
::newMainPage();
761 $previewtext = wfMsg('skinpreview');
762 # Only show members of Skin::getSkinNames() rather than
763 # $skinNames (skins is all skin names from Language.php)
764 $validSkinNames = Skin
::getSkinNames();
765 # Sort by UI skin name. First though need to update validSkinNames as sometimes
766 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
767 foreach ($validSkinNames as $skinkey => & $skinname ) {
768 if ( isset( $skinNames[$skinkey] ) ) {
769 $skinname = $skinNames[$skinkey];
772 asort($validSkinNames);
773 foreach ($validSkinNames as $skinkey => $sn ) {
774 if ( in_array( $skinkey, $wgSkipSkins ) ) {
777 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
779 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
780 $previewlink = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
781 if( $skinkey == $wgDefaultSkin )
782 $sn .= ' (' . wfMsg( 'default' ) . ')';
783 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
785 $wgOut->addHTML( "</fieldset>\n\n" );
791 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
792 foreach ( $mathopts as $k => $v ) {
793 $checked = ($k == $this->mMath
);
795 Xml
::openElement( 'div' ) .
796 Xml
::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
797 Xml
::closeElement( 'div' ) . "\n"
800 $wgOut->addHTML( "</fieldset>\n\n" );
806 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
809 $imageLimitOptions = null;
810 foreach ( $wgImageLimits as $index => $limits ) {
811 $selected = ($index == $this->mImageSize
);
812 $imageLimitOptions .= Xml
::option( "{$limits[0]}ร{$limits[1]}" .
813 wfMsg('unit-pixel'), $index, $selected );
816 $imageSizeId = 'wpImageSize';
818 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
819 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
821 Xml
::closeElement( 'select' ) . "</div>\n"
824 $imageThumbOptions = null;
825 foreach ( $wgThumbLimits as $index => $size ) {
826 $selected = ($index == $this->mThumbSize
);
827 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
831 $thumbSizeId = 'wpThumbSize';
833 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
834 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
836 Xml
::closeElement( 'select' ) . "</div>\n"
839 $wgOut->addHTML( "</fieldset>\n\n" );
846 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
849 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
851 $epoch = '20010115161234'; # Wikipedia day
852 foreach( $dateopts as $key ) {
853 if( $key == 'default' ) {
854 $formatted = wfMsgHtml( 'datedefault' );
856 $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
858 ($key == $this->mDate
) ?
$checked = ' checked="checked"' : $checked = '';
859 $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
860 "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
863 $wgOut->addHTML( "</fieldset>\n" );
866 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
867 $nowserver = $wgLang->time( $now, false );
869 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
870 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
871 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
873 '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
874 "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff
) . "\" size='6' />"
875 ) . "<tr><td colspan='2'>
876 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
877 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
878 </td></tr></table><div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div></fieldset>
883 global $wgLivePreview;
884 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
886 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
888 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
890 $this->getToggles( array(
892 'editsectiononrightclick',
901 $wgLivePreview ?
'uselivepreview' : false,
907 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
910 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
911 $rc .= '<td>' . Xml
::input( 'wpRecentDays', 3, $this->mRecentDays
, array( 'id' => 'wpRecentDays' ) ) . '</td>';
913 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
914 $rc .= '<td>' . Xml
::input( 'wpRecent', 3, $this->mRecent
, array( 'id' => 'wpRecent' ) ) . '</td>';
915 $rc .= '</tr></table>';
916 $wgOut->addHtml( $rc );
918 $wgOut->addHtml( '<br />' );
920 $toggles[] = 'hideminor';
921 if( $wgRCShowWatchingUsers )
922 $toggles[] = 'shownumberswatching';
923 $toggles[] = 'usenewrc';
924 $wgOut->addHtml( $this->getToggles( $toggles ) );
926 $wgOut->addHtml( '</fieldset>' );
929 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
931 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
932 $wgOut->addHtml( '<br /><br />' );
934 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
935 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
936 $wgOut->addHtml( '<br /><br />' );
938 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
940 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
941 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
942 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
943 if( $wgUser->isAllowed( $action ) )
944 $wgOut->addHtml( $this->getToggle( $toggle ) );
946 $this->mUsedToggles
['watchcreations'] = true;
947 $this->mUsedToggles
['watchdefault'] = true;
948 $this->mUsedToggles
['watchmoves'] = true;
949 $this->mUsedToggles
['watchdeletion'] = true;
951 $wgOut->addHtml( '</fieldset>' );
954 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
956 wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
957 wfInput( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
960 wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
961 wfInput( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
964 wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
965 wfInput( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
967 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
971 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
972 $wgOut->addHtml( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label> ' );
973 $wgOut->addHtml( Xml
::input( 'wpStubs', 6, $this->mStubs
, array( 'id' => 'wpStubs' ) ) );
974 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
975 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
976 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
977 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
978 $uopt = $wgUser->getOption("underline");
979 $s0 = $uopt == 0 ?
' selected="selected"' : '';
980 $s1 = $uopt == 1 ?
' selected="selected"' : '';
981 $s2 = $uopt == 2 ?
' selected="selected"' : '';
983 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
984 <select name='wpOpunderline' id='wpOpunderline'>
985 <option value=\"0\"$s0>$msgUnderlinenever</option>
986 <option value=\"1\"$s1>$msgUnderlinealways</option>
987 <option value=\"2\"$s2>$msgUnderlinedefault</option>
988 </select></p></div>");
990 foreach ( $togs as $tname ) {
991 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
992 $wgOut->addHTML( $this->getToggle( $tname ) );
995 $wgOut->addHTML( '</fieldset>' );
997 $token = htmlspecialchars( $wgUser->editToken() );
998 $skin = $wgUser->getSkin();
1000 <div id='prefsubmit'>
1002 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
1003 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
1008 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
1011 $wgOut->addHtml( Xml
::tags( 'div', array( 'class' => "prefcache" ),
1012 wfMsgExt( 'clearyourcache', 'parseinline' ) )