3 * Hold things related to displaying and saving user preferences.
9 * Entry point that create the "Preferences" object
11 function wfSpecialPreferences() {
14 $form = new PreferencesForm( $wgRequest );
19 * Preferences form handling
20 * This object will show the preferences form and can save it as well.
21 * @ingroup SpecialPage
23 class PreferencesForm
{
24 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
25 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
26 var $mUserLanguage, $mUserVariant;
27 var $mSearch, $mRecent, $mRecentDays, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
28 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
29 var $mUnderline, $mWatchlistEdits;
35 function PreferencesForm( &$request ) {
36 global $wgContLang, $wgUser, $wgAllowRealName;
38 $this->mQuickbar
= $request->getVal( 'wpQuickbar' );
39 $this->mOldpass
= $request->getVal( 'wpOldpass' );
40 $this->mNewpass
= $request->getVal( 'wpNewpass' );
41 $this->mRetypePass
=$request->getVal( 'wpRetypePass' );
42 $this->mStubs
= $request->getVal( 'wpStubs' );
43 $this->mRows
= $request->getVal( 'wpRows' );
44 $this->mCols
= $request->getVal( 'wpCols' );
45 $this->mSkin
= $request->getVal( 'wpSkin' );
46 $this->mMath
= $request->getVal( 'wpMath' );
47 $this->mDate
= $request->getVal( 'wpDate' );
48 $this->mUserEmail
= $request->getVal( 'wpUserEmail' );
49 $this->mRealName
= $wgAllowRealName ?
$request->getVal( 'wpRealName' ) : '';
50 $this->mEmailFlag
= $request->getCheck( 'wpEmailFlag' ) ?
0 : 1;
51 $this->mNick
= $request->getVal( 'wpNick' );
52 $this->mUserLanguage
= $request->getVal( 'wpUserLanguage' );
53 $this->mUserVariant
= $request->getVal( 'wpUserVariant' );
54 $this->mSearch
= $request->getVal( 'wpSearch' );
55 $this->mRecent
= $request->getVal( 'wpRecent' );
56 $this->mRecentDays
= $request->getVal( 'wpRecentDays' );
57 $this->mHourDiff
= $request->getVal( 'wpHourDiff' );
58 $this->mSearchLines
= $request->getVal( 'wpSearchLines' );
59 $this->mSearchChars
= $request->getVal( 'wpSearchChars' );
60 $this->mImageSize
= $request->getVal( 'wpImageSize' );
61 $this->mThumbSize
= $request->getInt( 'wpThumbSize' );
62 $this->mUnderline
= $request->getInt( 'wpOpunderline' );
63 $this->mAction
= $request->getVal( 'action' );
64 $this->mReset
= $request->getCheck( 'wpReset' );
65 $this->mPosted
= $request->wasPosted();
66 $this->mSuccess
= $request->getCheck( 'success' );
67 $this->mWatchlistDays
= $request->getVal( 'wpWatchlistDays' );
68 $this->mWatchlistEdits
= $request->getVal( 'wpWatchlistEdits' );
69 $this->mDisableMWSuggest
= $request->getCheck( 'wpDisableMWSuggest' );
71 $this->mSaveprefs
= $request->getCheck( 'wpSaveprefs' ) &&
73 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
75 # User toggles (the big ugly unsorted list of checkboxes)
76 $this->mToggles
= array();
77 if ( $this->mPosted
) {
78 $togs = User
::getToggles();
79 foreach ( $togs as $tname ) {
80 $this->mToggles
[$tname] = $request->getCheck( "wpOp$tname" ) ?
1 : 0;
84 $this->mUsedToggles
= array();
86 # Search namespace options
87 # Note: namespaces don't necessarily have consecutive keys
88 $this->mSearchNs
= array();
89 if ( $this->mPosted
) {
90 $namespaces = $wgContLang->getNamespaces();
91 foreach ( $namespaces as $i => $namespace ) {
93 $this->mSearchNs
[$i] = $request->getCheck( "wpNs$i" ) ?
1 : 0;
99 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage
) ) {
100 $this->mUserLanguage
= 'nolanguage';
103 wfRunHooks( 'InitPreferencesForm', array( $this, $request ) );
107 global $wgUser, $wgOut, $wgTitle;
109 if ( $wgUser->isAnon() ) {
110 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array($wgTitle->getPrefixedDBkey()) );
113 if ( wfReadOnly() ) {
114 $wgOut->readOnlyPage();
117 if ( $this->mReset
) {
119 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
120 } else if ( $this->mSaveprefs
) {
121 $this->savePreferences();
124 $this->mainPrefsForm( '' );
131 function savePreferences() {
132 global $wgUser, $wgOut, $wgParser;
133 global $wgEnableUserEmail, $wgEnableEmail;
134 global $wgEmailAuthentication, $wgRCMaxAge;
135 global $wgAuth, $wgEmailConfirmToEdit;
138 if ( '' != $this->mNewpass
&& $wgAuth->allowPasswordChange() ) {
139 if ( $this->mNewpass
!= $this->mRetypePass
) {
140 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'badretype' ) );
141 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
145 if (!$wgUser->checkPassword( $this->mOldpass
)) {
146 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'wrongpassword' ) );
147 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
152 $wgUser->setPassword( $this->mNewpass
);
153 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'success' ) );
154 $this->mNewpass
= $this->mOldpass
= $this->mRetypePass
= '';
155 } catch( PasswordError
$e ) {
156 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass
, 'error' ) );
157 $this->mainPrefsForm( 'error', $e->getMessage() );
161 $wgUser->setRealName( $this->mRealName
);
162 $oldOptions = $wgUser->mOptions
;
164 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage
) {
165 $needRedirect = true;
167 $needRedirect = false;
170 # Validate the signature and clean it up as needed
171 global $wgMaxSigChars;
172 if( mb_strlen( $this->mNick
) > $wgMaxSigChars ) {
174 $this->mainPrefsForm( 'error',
175 wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) );
177 } elseif( $this->mToggles
['fancysig'] ) {
178 if( $wgParser->validateSig( $this->mNick
) !== false ) {
179 $this->mNick
= $wgParser->cleanSig( $this->mNick
);
181 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
185 // When no fancy sig used, make sure ~{3,5} get removed.
186 $this->mNick
= $wgParser->cleanSigInSig( $this->mNick
);
189 $wgUser->setOption( 'language', $this->mUserLanguage
);
190 $wgUser->setOption( 'variant', $this->mUserVariant
);
191 $wgUser->setOption( 'nickname', $this->mNick
);
192 $wgUser->setOption( 'quickbar', $this->mQuickbar
);
193 $wgUser->setOption( 'skin', $this->mSkin
);
196 $wgUser->setOption( 'math', $this->mMath
);
198 $wgUser->setOption( 'date', Validate
::dateFormat( $this->mDate
) );
199 $wgUser->setOption( 'searchlimit', Validate
::intOrNull( $this->mSearch
) );
200 $wgUser->setOption( 'contextlines', Validate
::intOrNull( $this->mSearchLines
) );
201 $wgUser->setOption( 'contextchars', Validate
::intOrNull( $this->mSearchChars
) );
202 $wgUser->setOption( 'rclimit', Validate
::intOrNull( $this->mRecent
) );
203 $wgUser->setOption( 'rcdays', Validate
::int($this->mRecentDays
, 1, ceil($wgRCMaxAge / (3600*24))));
204 $wgUser->setOption( 'wllimit', Validate
::intOrNull( $this->mWatchlistEdits
, 0, 1000 ) );
205 $wgUser->setOption( 'rows', Validate
::int( $this->mRows
, 4, 1000 ) );
206 $wgUser->setOption( 'cols', Validate
::int( $this->mCols
, 4, 1000 ) );
207 $wgUser->setOption( 'stubthreshold', Validate
::intOrNull( $this->mStubs
) );
208 $wgUser->setOption( 'timecorrection', Validate
::timeZone( $this->mHourDiff
, -12, 14 ) );
209 $wgUser->setOption( 'imagesize', $this->mImageSize
);
210 $wgUser->setOption( 'thumbsize', $this->mThumbSize
);
211 $wgUser->setOption( 'underline', Validate
::int($this->mUnderline
, 0, 2) );
212 $wgUser->setOption( 'watchlistdays', Validate
::float( $this->mWatchlistDays
, 0, 7 ) );
213 $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest
);
215 # Set search namespace options
216 foreach( $this->mSearchNs
as $i => $value ) {
217 $wgUser->setOption( "searchNs{$i}", $value );
220 if( $wgEnableEmail && $wgEnableUserEmail ) {
221 $wgUser->setOption( 'disablemail', $this->mEmailFlag
);
225 foreach ( $this->mToggles
as $tname => $tvalue ) {
226 $wgUser->setOption( $tname, $tvalue );
230 if( $wgEnableEmail ) {
231 $newadr = $this->mUserEmail
;
232 $oldadr = $wgUser->getEmail();
233 if( ($newadr != '') && ($newadr != $oldadr) ) {
234 # the user has supplied a new email address on the login page
235 if( $wgUser->isValidEmailAddr( $newadr ) ) {
236 # new behaviour: set this new emailaddr from login-page into user database record
237 $wgUser->setEmail( $newadr );
238 # but flag as "dirty" = unauthenticated
239 $wgUser->invalidateEmail();
240 if ($wgEmailAuthentication) {
241 # Mail a temporary password to the dirty address.
242 # User can come back through the confirmation URL to re-enable email.
243 $result = $wgUser->sendConfirmationMail();
244 if( WikiError
::isError( $result ) ) {
245 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
247 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
251 $error = wfMsg( 'invalidemailaddress' );
254 if( $wgEmailConfirmToEdit && empty( $newadr ) ) {
255 $this->mainPrefsForm( 'error', wfMsg( 'noemailtitle' ) );
258 $wgUser->setEmail( $this->mUserEmail
);
260 if( $oldadr != $newadr ) {
261 wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldadr, $newadr ) );
265 if( !$wgAuth->updateExternalDB( $wgUser ) ){
266 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
271 if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg, $oldOptions ) ) ) {
272 $this->mainPrefsForm( 'error', $msg );
276 $wgUser->setCookies();
277 $wgUser->saveSettings();
279 if( $needRedirect && $error === false ) {
280 $title = SpecialPage
::getTitleFor( 'Preferences' );
281 $wgOut->redirect( $title->getFullURL( 'success' ) );
285 $wgOut->parserOptions( ParserOptions
::newFromUser( $wgUser ) );
286 $this->mainPrefsForm( $error === false ?
'success' : 'error', $error);
292 function resetPrefs() {
293 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
295 $this->mOldpass
= $this->mNewpass
= $this->mRetypePass
= '';
296 $this->mUserEmail
= $wgUser->getEmail();
297 $this->mUserEmailAuthenticationtimestamp
= $wgUser->getEmailAuthenticationtimestamp();
298 $this->mRealName
= ($wgAllowRealName) ?
$wgUser->getRealName() : '';
300 # language value might be blank, default to content language
301 $this->mUserLanguage
= $wgUser->getOption( 'language', $wgContLanguageCode );
303 $this->mUserVariant
= $wgUser->getOption( 'variant');
304 $this->mEmailFlag
= $wgUser->getOption( 'disablemail' ) == 1 ?
1 : 0;
305 $this->mNick
= $wgUser->getOption( 'nickname' );
307 $this->mQuickbar
= $wgUser->getOption( 'quickbar' );
308 $this->mSkin
= Skin
::normalizeKey( $wgUser->getOption( 'skin' ) );
309 $this->mMath
= $wgUser->getOption( 'math' );
310 $this->mDate
= $wgUser->getDatePreference();
311 $this->mRows
= $wgUser->getOption( 'rows' );
312 $this->mCols
= $wgUser->getOption( 'cols' );
313 $this->mStubs
= $wgUser->getOption( 'stubthreshold' );
314 $this->mHourDiff
= $wgUser->getOption( 'timecorrection' );
315 $this->mSearch
= $wgUser->getOption( 'searchlimit' );
316 $this->mSearchLines
= $wgUser->getOption( 'contextlines' );
317 $this->mSearchChars
= $wgUser->getOption( 'contextchars' );
318 $this->mImageSize
= $wgUser->getOption( 'imagesize' );
319 $this->mThumbSize
= $wgUser->getOption( 'thumbsize' );
320 $this->mRecent
= $wgUser->getOption( 'rclimit' );
321 $this->mRecentDays
= $wgUser->getOption( 'rcdays' );
322 $this->mWatchlistEdits
= $wgUser->getOption( 'wllimit' );
323 $this->mUnderline
= $wgUser->getOption( 'underline' );
324 $this->mWatchlistDays
= $wgUser->getOption( 'watchlistdays' );
325 $this->mDisableMWSuggest
= $wgUser->getBoolOption( 'disablesuggest' );
327 $togs = User
::getToggles();
328 foreach ( $togs as $tname ) {
329 $this->mToggles
[$tname] = $wgUser->getOption( $tname );
332 $namespaces = $wgContLang->getNamespaces();
333 foreach ( $namespaces as $i => $namespace ) {
334 if ( $i >= NS_MAIN
) {
335 $this->mSearchNs
[$i] = $wgUser->getOption( 'searchNs'.$i );
339 wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) );
345 function namespacesCheckboxes() {
348 # Determine namespace checkboxes
349 $namespaces = $wgContLang->getNamespaces();
352 foreach ( $namespaces as $i => $name ) {
355 $checked = $this->mSearchNs
[$i] ?
"checked='checked'" : '';
356 $name = str_replace( '_', ' ', $namespaces[$i] );
359 $name = wfMsg( 'blanknamespace' );
361 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
367 function getToggle( $tname, $trailer = false, $disabled = false ) {
368 global $wgUser, $wgLang;
370 $this->mUsedToggles
[$tname] = true;
371 $ttext = $wgLang->getUserToggle( $tname );
373 $checked = $wgUser->getOption( $tname ) == 1 ?
' checked="checked"' : '';
374 $disabled = $disabled ?
' disabled="disabled"' : '';
375 $trailer = $trailer ?
$trailer : '';
376 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
377 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
380 function getToggles( $items ) {
382 foreach( $items as $item ) {
383 if( $item === false )
385 if( is_array( $item ) ) {
386 list( $key, $trailer ) = $item;
391 $out .= $this->getToggle( $key, $trailer );
396 function addRow($td1, $td2) {
397 return "<tr><td class='mw-label'>$td1</td><td class='mw-input'>$td2</td></tr>";
401 * Helper function for user information panel
402 * @param $td1 label for an item
403 * @param $td2 item or null
404 * @param $td3 optional help or null
405 * @return xhtml block
407 function tableRow( $td1, $td2 = null, $td3 = null ) {
409 if ( is_null( $td3 ) ) {
412 $td3 = Xml
::tags( 'tr', null,
413 Xml
::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td3 )
417 if ( is_null( $td2 ) ) {
418 $td1 = Xml
::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td1 );
421 $td1 = Xml
::tags( 'td', array( 'class' => 'pref-label' ), $td1 );
422 $td2 = Xml
::tags( 'td', array( 'class' => 'pref-input' ), $td2 );
425 return Xml
::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
432 function mainPrefsForm( $status , $message = '' ) {
433 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgAuth;
434 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
435 global $wgDisableLangConversion, $wgDisableTitleConversion;
436 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
437 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
438 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
439 global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration;
440 global $wgEmailConfirmToEdit, $wgEnableMWSuggest;
442 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
443 $wgOut->setArticleRelated( false );
444 $wgOut->setRobotPolicy( 'noindex,nofollow' );
445 $wgOut->addScriptFile( 'prefs.js' );
447 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
449 if ( $this->mSuccess ||
'success' == $status ) {
450 $wgOut->wrapWikiMsg( '<div class="successbox"><strong>$1</strong></div>', 'savedprefs' );
451 } else if ( 'error' == $status ) {
452 $wgOut->addWikiText( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
453 } else if ( '' != $status ) {
454 $wgOut->addWikiText( $message . "\n----" );
457 $qbs = $wgLang->getQuickbarSettings();
458 $skinNames = $wgLang->getSkinNames();
459 $mathopts = $wgLang->getMathNames();
460 $dateopts = $wgLang->getDatePreferences();
461 $togs = User
::getToggles();
463 $titleObj = SpecialPage
::getTitleFor( 'Preferences' );
465 # Pre-expire some toggles so they won't show if disabled
466 $this->mUsedToggles
[ 'shownumberswatching' ] = true;
467 $this->mUsedToggles
[ 'showupdated' ] = true;
468 $this->mUsedToggles
[ 'enotifwatchlistpages' ] = true;
469 $this->mUsedToggles
[ 'enotifusertalkpages' ] = true;
470 $this->mUsedToggles
[ 'enotifminoredits' ] = true;
471 $this->mUsedToggles
[ 'enotifrevealaddr' ] = true;
472 $this->mUsedToggles
[ 'ccmeonemails' ] = true;
473 $this->mUsedToggles
[ 'uselivepreview' ] = true;
474 $this->mUsedToggles
[ 'noconvertlink' ] = true;
477 if ( !$this->mEmailFlag
) { $emfc = 'checked="checked"'; }
481 if ($wgEmailAuthentication && ($this->mUserEmail
!= '') ) {
482 if( $wgUser->getEmailAuthenticationTimestamp() ) {
483 // date and time are separate parameters to facilitate localisation.
484 // $time is kept for backward compat reasons.
485 // 'emailauthenticated' is also used in SpecialConfirmemail.php
486 $time = $wgLang->timeAndDate( $wgUser->getEmailAuthenticationTimestamp(), true );
487 $d = $wgLang->date( $wgUser->getEmailAuthenticationTimestamp(), true );
488 $t = $wgLang->time( $wgUser->getEmailAuthenticationTimestamp(), true );
489 $emailauthenticated = wfMsg('emailauthenticated', $time, $d, $t ).'<br />';
490 $disableEmailPrefs = false;
492 $disableEmailPrefs = true;
493 $skin = $wgUser->getSkin();
494 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
495 $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Confirmemail' ),
496 wfMsg( 'emailconfirmlink' ) ) . '<br />';
499 $emailauthenticated = '';
500 $disableEmailPrefs = false;
503 if ($this->mUserEmail
== '') {
504 $emailauthenticated = wfMsg( 'noemailprefs' ) . '<br />';
507 $ps = $this->namespacesCheckboxes();
509 $enotifwatchlistpages = ($wgEnotifWatchlist) ?
$this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
510 $enotifusertalkpages = ($wgEnotifUserTalk) ?
$this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
511 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ?
$this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
512 $enotifrevealaddr = (($wgEnotifWatchlist ||
$wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ?
$this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
517 Xml
::openElement( 'form', array(
518 'action' => $titleObj->getLocalUrl(),
520 'id' => 'mw-preferences-form',
522 Xml
::openElement( 'div', array( 'id' => 'preferences' ) )
528 Xml
::fieldset( wfMsg('prefs-personal') ) .
529 Xml
::openElement( 'table' ) .
530 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'prefs-personal' ) ) )
533 # Get groups to which the user belongs
534 $userEffectiveGroups = $wgUser->getEffectiveGroups();
535 $userEffectiveGroupsArray = array();
536 foreach( $userEffectiveGroups as $ueg ) {
538 // Skip the default * group, seems useless here
541 $userEffectiveGroupsArray[] = User
::makeGroupLinkHTML( $ueg );
543 asort( $userEffectiveGroupsArray );
545 $sk = $wgUser->getSkin();
546 $toolLinks = array();
547 $toolLinks[] = $sk->makeKnownLinkObj( SpecialPage
::getTitleFor( 'ListGroupRights' ), wfMsg( 'listgrouprights' ) );
548 # At the moment one tool link only but be prepared for the future...
549 # FIXME: Add a link to Special:Userrights for users who are allowed to use it.
550 # $wgUser->isAllowed( 'userrights' ) seems to strict in some cases
552 $userInformationHtml =
553 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
554 $this->tableRow( wfMsgHtml( 'uid' ), $wgLang->formatNum( htmlspecialchars( $wgUser->getId() ) ) ).
557 wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ),
558 $wgLang->commaList( $userEffectiveGroupsArray ) .
559 '<br />(' . implode( ' | ', $toolLinks ) . ')'
563 wfMsgHtml( 'prefs-edits' ),
564 $wgLang->formatNum( $wgUser->getEditCount() )
567 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
568 $wgOut->addHtml( $userInformationHtml );
571 if ( $wgAllowRealName ) {
574 Xml
::label( wfMsg('yourrealname'), 'wpRealName' ),
575 Xml
::input( 'wpRealName', 25, $this->mRealName
, array( 'id' => 'wpRealName' ) ),
576 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
577 wfMsgExt( 'prefs-help-realname', 'parseinline' )
582 if ( $wgEnableEmail ) {
585 Xml
::label( wfMsg('youremail'), 'wpUserEmail' ),
586 Xml
::input( 'wpUserEmail', 25, $this->mUserEmail
, array( 'id' => 'wpUserEmail' ) ),
587 Xml
::tags('div', array( 'class' => 'prefsectiontip' ),
588 wfMsgExt( $wgEmailConfirmToEdit ?
'prefs-help-email-required' : 'prefs-help-email', 'parseinline' )
594 global $wgParser, $wgMaxSigChars;
595 if( mb_strlen( $this->mNick
) > $wgMaxSigChars ) {
596 $invalidSig = $this->tableRow(
598 Xml
::element( 'span', array( 'class' => 'error' ),
599 wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) )
601 } elseif( !empty( $this->mToggles
['fancysig'] ) &&
602 false === $wgParser->validateSig( $this->mNick
) ) {
603 $invalidSig = $this->tableRow(
605 Xml
::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
613 Xml
::label( wfMsg( 'yournick' ), 'wpNick' ),
614 Xml
::input( 'wpNick', 25, $this->mNick
,
617 // Note: $wgMaxSigChars is enforced in Unicode characters,
618 // both on the backend and now in the browser.
619 // Badly-behaved requests may still try to submit
620 // an overlong string, however.
621 'maxlength' => $wgMaxSigChars ) )
624 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
627 list( $lsLabel, $lsSelect) = Xml
::languageSelector( $this->mUserLanguage
);
629 $this->tableRow( $lsLabel, $lsSelect )
632 /* see if there are multiple language variants to choose from*/
633 if(!$wgDisableLangConversion) {
634 $variants = $wgContLang->getVariants();
635 $variantArray = array();
637 $languages = Language
::getLanguageNames( true );
638 foreach($variants as $v) {
639 $v = str_replace( '_', '-', strtolower($v));
640 if( array_key_exists( $v, $languages ) ) {
641 // If it doesn't have a name, we'll pretend it doesn't exist
642 $variantArray[$v] = $languages[$v];
647 foreach( $variantArray as $code => $name ) {
648 $selected = ($code == $this->mUserVariant
);
649 $options .= Xml
::option( "$code - $name", $code, $selected ) . "\n";
652 if(count($variantArray) > 1) {
655 Xml
::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
657 array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
664 if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
666 Xml
::tags( 'tr', null,
667 Xml
::tags( 'td', array( 'colspan' => '2' ),
668 $this->getToggle( "noconvertlink" )
676 if( $wgAuth->allowPasswordChange() ) {
678 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'changepassword' ) ) ) .
680 Xml
::label( wfMsg( 'oldpassword' ), 'wpOldpass' ),
681 Xml
::password( 'wpOldpass', 25, $this->mOldpass
, array( 'id' => 'wpOldpass' ) )
684 Xml
::label( wfMsg( 'newpassword' ), 'wpNewpass' ),
685 Xml
::password( 'wpNewpass', 25, $this->mNewpass
, array( 'id' => 'wpNewpass' ) )
688 Xml
::label( wfMsg( 'retypenew' ), 'wpRetypePass' ),
689 Xml
::password( 'wpRetypePass', 25, $this->mRetypePass
, array( 'id' => 'wpRetypePass' ) )
692 if( $wgCookieExpiration > 0 ){
694 Xml
::tags( 'tr', null,
695 Xml
::tags( 'td', array( 'colspan' => '2' ),
696 $this->getToggle( "rememberpassword" )
701 $this->mUsedToggles
['rememberpassword'] = true;
707 if ( $wgEnableEmail ) {
710 if ($wgEnableUserEmail) {
711 // fixme -- the "allowemail" pseudotoggle is a hacked-together
712 // inversion for the "disableemail" preference.
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>" .
717 $this->getToggle( 'ccmeonemails', '', $disableEmailPrefs );
722 $this->tableRow( Xml
::element( 'h2', null, wfMsg( 'email' ) ) ) .
726 $enotifwatchlistpages.
727 $enotifusertalkpages.
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('skin-preview');
762 # Only show members of Skin::getSkinNames() rather than
763 # $skinNames (skins is all skin names from Language.php)
764 $validSkinNames = Skin
::getUsableSkins();
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 $checked = $skinkey == $this->mSkin ?
' checked="checked"' : '';
776 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
777 $previewlink = "(<a target='_blank' href=\"$mplink\">$previewtext</a>)";
778 if( $skinkey == $wgDefaultSkin )
779 $sn .= ' (' . wfMsg( 'default' ) . ')';
780 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
782 $wgOut->addHTML( "</fieldset>\n\n" );
788 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
789 foreach ( $mathopts as $k => $v ) {
790 $checked = ($k == $this->mMath
);
792 Xml
::openElement( 'div' ) .
793 Xml
::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
794 Xml
::closeElement( 'div' ) . "\n"
797 $wgOut->addHTML( "</fieldset>\n\n" );
803 "<fieldset>\n" . Xml
::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
806 $imageLimitOptions = null;
807 foreach ( $wgImageLimits as $index => $limits ) {
808 $selected = ($index == $this->mImageSize
);
809 $imageLimitOptions .= Xml
::option( "{$limits[0]}×{$limits[1]}" .
810 wfMsg('unit-pixel'), $index, $selected );
813 $imageSizeId = 'wpImageSize';
815 "<div>" . Xml
::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
816 Xml
::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
818 Xml
::closeElement( 'select' ) . "</div>\n"
821 $imageThumbOptions = null;
822 foreach ( $wgThumbLimits as $index => $size ) {
823 $selected = ($index == $this->mThumbSize
);
824 $imageThumbOptions .= Xml
::option($size . wfMsg('unit-pixel'), $index,
828 $thumbSizeId = 'wpThumbSize';
830 "<div>" . Xml
::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
831 Xml
::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
833 Xml
::closeElement( 'select' ) . "</div>\n"
836 $wgOut->addHTML( "</fieldset>\n\n" );
844 Xml
::openElement( 'fieldset' ) .
845 Xml
::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n"
850 Xml
::openElement( 'fieldset' ) .
851 Xml
::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n"
854 $epoch = '20010115161234'; # Wikipedia day
855 foreach( $dateopts as $key ) {
856 if( $key == 'default' ) {
857 $formatted = wfMsg( 'datedefault' );
859 $formatted = $wgLang->timeanddate( $epoch, false, $key );
862 Xml
::tags( 'div', null,
863 Xml
::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $key == $this->mDate
)
868 $wgOut->addHTML( Xml
::closeElement( 'fieldset' ) . "\n" );
871 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
872 $nowserver = $wgLang->time( $now, false );
875 Xml
::openElement( 'fieldset' ) .
876 Xml
::element( 'legend', null, wfMsg( 'timezonelegend' ) ) .
877 Xml
::openElement( 'table' ) .
878 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
879 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
881 Xml
::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff' ),
882 Xml
::input( 'wpHourDiff', 6, $this->mHourDiff
, array( 'id' => 'wpHourDiff' ) ) ) .
885 <td class='mw-submit'>" .
886 Xml
::element( 'input',
887 array( 'type' => 'button',
888 'value' => wfMsg( 'guesstimezone' ),
889 'onclick' => 'javascript:guessTimezone()',
890 'id' => 'guesstimezonebutton',
891 'style' => 'display:none;' ) ) .
894 Xml
::closeElement( 'table' ) .
895 Xml
::tags( 'div', array( 'class' => 'prefsectiontip' ), wfMsgExt( 'timezonetext', 'parseinline' ) ).
896 Xml
::closeElement( 'fieldset' ) .
897 Xml
::closeElement( 'fieldset' ) . "\n\n"
902 global $wgLivePreview;
903 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
905 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows
) .
907 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols
) .
909 $this->getToggles( array(
911 'editsectiononrightclick',
920 $wgLivePreview ?
'uselivepreview' : false,
926 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
929 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
930 $rc .= '<td>' . Xml
::input( 'wpRecentDays', 3, $this->mRecentDays
, array( 'id' => 'wpRecentDays' ) ) . '</td>';
932 $rc .= '<td>' . Xml
::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
933 $rc .= '<td>' . Xml
::input( 'wpRecent', 3, $this->mRecent
, array( 'id' => 'wpRecent' ) ) . '</td>';
934 $rc .= '</tr></table>';
935 $wgOut->addHtml( $rc );
937 $wgOut->addHtml( '<br />' );
939 $toggles[] = 'hideminor';
940 if( $wgRCShowWatchingUsers )
941 $toggles[] = 'shownumberswatching';
942 $toggles[] = 'usenewrc';
943 $wgOut->addHtml( $this->getToggles( $toggles ) );
945 $wgOut->addHtml( '</fieldset>' );
948 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
950 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays
) );
951 $wgOut->addHtml( '<br /><br />' );
953 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
954 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits
) );
955 $wgOut->addHtml( '<br /><br />' );
957 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) );
959 if( $wgUser->isAllowed( 'createpage' ) ||
$wgUser->isAllowed( 'createtalk' ) )
960 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
961 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
962 if( $wgUser->isAllowed( $action ) )
963 $wgOut->addHtml( $this->getToggle( $toggle ) );
965 $this->mUsedToggles
['watchcreations'] = true;
966 $this->mUsedToggles
['watchdefault'] = true;
967 $this->mUsedToggles
['watchmoves'] = true;
968 $this->mUsedToggles
['watchdeletion'] = true;
970 $wgOut->addHtml( '</fieldset>' );
973 $mwsuggest = $wgEnableMWSuggest ?
975 Xml
::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
976 Xml
::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest
, array( 'id' => 'wpDisableMWSuggest' ) )
979 // Elements for the search tab itself
980 Xml
::openElement( 'fieldset' ) .
981 Xml
::element( 'legend', null, wfMsg( 'searchresultshead' ) ) .
982 // Elements for the search options in the search tab
983 Xml
::openElement( 'fieldset' ) .
984 Xml
::element( 'legend', null, wfMsg( 'prefs-searchoptions' ) ) .
985 Xml
::openElement( 'table' ) .
987 Xml
::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
988 Xml
::input( 'wpSearch', 4, $this->mSearch
, array( 'id' => 'wpSearch' ) )
991 Xml
::label( wfMsg( 'contextlines' ), 'wpSearchLines' ),
992 Xml
::input( 'wpSearchLines', 4, $this->mSearchLines
, array( 'id' => 'wpSearchLines' ) )
995 Xml
::label( wfMsg( 'contextchars' ), 'wpSearchChars' ),
996 Xml
::input( 'wpSearchChars', 4, $this->mSearchChars
, array( 'id' => 'wpSearchChars' ) )
999 Xml
::closeElement( 'table' ) .
1000 Xml
::closeElement( 'fieldset' ) .
1001 // Elements for the namespace options in the search tab
1002 Xml
::openElement( 'fieldset' ) .
1003 Xml
::element( 'legend', null, wfMsg( 'prefs-namespaces' ) ) .
1004 wfMsgExt( 'defaultns', array( 'parse' ) ) .
1006 Xml
::closeElement( 'fieldset' ) .
1007 // End of the search tab
1008 Xml
::closeElement( 'fieldset' )
1013 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
1014 $wgOut->addHtml( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label> ' );
1015 $wgOut->addHtml( Xml
::input( 'wpStubs', 6, $this->mStubs
, array( 'id' => 'wpStubs' ) ) );
1016 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
1017 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
1018 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
1019 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
1020 $uopt = $wgUser->getOption("underline");
1021 $s0 = $uopt == 0 ?
' selected="selected"' : '';
1022 $s1 = $uopt == 1 ?
' selected="selected"' : '';
1023 $s2 = $uopt == 2 ?
' selected="selected"' : '';
1025 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
1026 <select name='wpOpunderline' id='wpOpunderline'>
1027 <option value=\"0\"$s0>$msgUnderlinenever</option>
1028 <option value=\"1\"$s1>$msgUnderlinealways</option>
1029 <option value=\"2\"$s2>$msgUnderlinedefault</option>
1030 </select></p></div>");
1032 foreach ( $togs as $tname ) {
1033 if( !array_key_exists( $tname, $this->mUsedToggles
) ) {
1034 $wgOut->addHTML( $this->getToggle( $tname ) );
1037 $wgOut->addHTML( '</fieldset>' );
1039 wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
1041 $token = htmlspecialchars( $wgUser->editToken() );
1042 $skin = $wgUser->getSkin();
1044 <div id='prefsubmit'>
1046 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
1047 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
1052 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
1055 $wgOut->addHtml( Xml
::tags( 'div', array( 'class' => "prefcache" ),
1056 wfMsgExt( 'clearyourcache', 'parseinline' ) )