X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FSpecialPreferences.php;h=a3b5617ae2e036ce5b966a23514f904e77e2fc23;hb=e052c4f566ab01d69c3b47dc8e039b721b673709;hp=3470b8a8d415b6e43a4b3c19260dd96e63a8d768;hpb=417a35b80718fa3ca2963d96bca737ebf92e2a3a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 3470b8a8d4..a3b5617ae2 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -5,12 +5,6 @@ * @subpackage SpecialPage */ -if( !defined( 'MEDIAWIKI' ) ) - die(); - -/** to get a list of languages in setting user's language preference */ -require_once('languages/Names.php'); - /** * Entry point that create the "Preferences" object */ @@ -33,14 +27,15 @@ class PreferencesForm { var $mUserLanguage, $mUserVariant; var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction; var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize; + var $mUnderline; /** * Constructor * Load some values */ - function PreferencesForm( &$request ) { + function PreferencesForm( &$request ) { global $wgLang, $wgContLang, $wgUser, $wgAllowRealName; - + $this->mQuickbar = $request->getVal( 'wpQuickbar' ); $this->mOldpass = $request->getVal( 'wpOldpass' ); $this->mNewpass = $request->getVal( 'wpNewpass' ); @@ -53,7 +48,7 @@ class PreferencesForm { $this->mDate = $request->getVal( 'wpDate' ); $this->mUserEmail = $request->getVal( 'wpUserEmail' ); $this->mRealName = $wgAllowRealName ? $request->getVal( 'wpRealName' ) : ''; - $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0; + $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 0 : 1; $this->mNick = $request->getVal( 'wpNick' ); $this->mUserLanguage = $request->getVal( 'wpUserLanguage' ); $this->mUserVariant = $request->getVal( 'wpUserVariant' ); @@ -64,9 +59,12 @@ class PreferencesForm { $this->mSearchChars = $request->getVal( 'wpSearchChars' ); $this->mImageSize = $request->getVal( 'wpImageSize' ); $this->mThumbSize = $request->getInt( 'wpThumbSize' ); + $this->mUnderline = $request->getInt( 'wpOpunderline' ); $this->mAction = $request->getVal( 'action' ); $this->mReset = $request->getCheck( 'wpReset' ); $this->mPosted = $request->wasPosted(); + $this->mSuccess = $request->getCheck( 'success' ); + $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) && $this->mPosted && $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) ); @@ -79,9 +77,9 @@ class PreferencesForm { $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0; } } - + $this->mUsedToggles = array(); - + # Search namespace options # Note: namespaces don't necessarily have consecutive keys $this->mSearchNs = array(); @@ -102,7 +100,7 @@ class PreferencesForm { function execute() { global $wgUser, $wgOut; - + if ( $wgUser->isAnon() ) { $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' ); return; @@ -113,7 +111,7 @@ class PreferencesForm { } if ( $this->mReset ) { $this->resetPrefs(); - $this->mainPrefsForm( wfMsg( 'prefsreset' ) ); + $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) ); } else if ( $this->mSaveprefs ) { $this->savePreferences(); } else { @@ -121,8 +119,7 @@ class PreferencesForm { $this->mainPrefsForm( '' ); } } - - /** + /** * @access private */ function validateInt( &$val, $min=0, $max=0x7fffffff ) { @@ -144,6 +141,16 @@ class PreferencesForm { } } + /** + * @access private + */ + function validateDate( &$val, $min = 0, $max=0x7fffffff ) { + if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) || $val == 'ISO 8601' ) + return $val; + else + return 0; + } + /** * Used to validate the user inputed timezone before saving it as * 'timeciorrection', will return '00:00' if fed bogus data. @@ -180,35 +187,62 @@ class PreferencesForm { * @access private */ function savePreferences() { - global $wgUser, $wgLang, $wgOut; + global $wgUser, $wgOut, $wgParser; global $wgEnableUserEmail, $wgEnableEmail; global $wgEmailAuthentication, $wgMinimalPasswordLength; + global $wgAuth; + if ( '' != $this->mNewpass ) { if ( $this->mNewpass != $this->mRetypePass ) { - $this->mainPrefsForm( wfMsg( 'badretype' ) ); + $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) ); return; } if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) { - $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) ); + $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) ); return; } if (!$wgUser->checkPassword( $this->mOldpass )) { - $this->mainPrefsForm( wfMsg( 'wrongpassword' ) ); + $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) ); + return; + } + if (!$wgAuth->setPassword( $wgUser, $this->mNewpass )) { + $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) ); return; } $wgUser->setPassword( $this->mNewpass ); + $this->mNewpass = $this->mOldpass = $this->mRetypePass = ''; + } $wgUser->setRealName( $this->mRealName ); + + if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage ) { + $needRedirect = true; + } else { + $needRedirect = false; + } + + # Validate the signature and clean it up as needed + if( $this->mToggles['fancysig'] ) { + if( Parser::validateSig( $this->mNick ) !== false ) { + $this->mNick = $wgParser->cleanSig( $this->mNick ); + } else { + $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) ); + } + } + $wgUser->setOption( 'language', $this->mUserLanguage ); $wgUser->setOption( 'variant', $this->mUserVariant ); $wgUser->setOption( 'nickname', $this->mNick ); $wgUser->setOption( 'quickbar', $this->mQuickbar ); $wgUser->setOption( 'skin', $this->mSkin ); - $wgUser->setOption( 'math', $this->mMath ); - $wgUser->setOption( 'date', $this->mDate ); + global $wgUseTeX; + if( $wgUseTeX ) { + $wgUser->setOption( 'math', $this->mMath ); + } + $wgUser->setOption( 'date', $this->validateDate( $this->mDate, 0, 20 ) ); $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) ); $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) ); $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) ); @@ -219,12 +253,13 @@ class PreferencesForm { $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) ); $wgUser->setOption( 'imagesize', $this->mImageSize ); $wgUser->setOption( 'thumbsize', $this->mThumbSize ); + $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) ); # Set search namespace options foreach( $this->mSearchNs as $i => $value ) { $wgUser->setOption( "searchNs{$i}", $value ); } - + if( $wgEnableEmail && $wgEnableUserEmail ) { $wgUser->setOption( 'disablemail', $this->mEmailFlag ); } @@ -233,43 +268,52 @@ class PreferencesForm { foreach ( $this->mToggles as $tname => $tvalue ) { $wgUser->setOption( $tname, $tvalue ); } + if (!$wgAuth->updateExternalDB($wgUser)) { + $this->mainPrefsForm( wfMsg( 'externaldberror' ) ); + return; + } $wgUser->setCookies(); $wgUser->saveSettings(); - + + $error = false; if( $wgEnableEmail ) { - $newadr = strtolower( $this->mUserEmail ); - $oldadr = strtolower($wgUser->getEmail()); - if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page - # prepare for authentication and mail a temporary password to newadr - require_once( 'SpecialUserlogin.php' ); - if ( !$wgUser->isValidEmailAddr( $newadr ) ) { - $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) ); - return; - } - $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record - $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated - $wgUser->saveSettings(); - if ($wgEmailAuthentication) { - # mail a temporary password to the dirty address - # on "save options", this user will be logged-out automatically - $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy ); - if ($error === '') { - return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) ); - } else { - return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) ); + $newadr = $this->mUserEmail; + $oldadr = $wgUser->getEmail(); + if( ($newadr != '') && ($newadr != $oldadr) ) { + # the user has supplied a new email address on the login page + if( $wgUser->isValidEmailAddr( $newadr ) ) { + $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record + $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated + $wgUser->saveSettings(); + if ($wgEmailAuthentication) { + # Mail a temporary password to the dirty address. + # User can come back through the confirmation URL to re-enable email. + $result = $wgUser->sendConfirmationMail(); + if( WikiError::isError( $result ) ) { + $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) ); + } else { + $error = wfMsg( 'eauthentsent', $wgUser->getName() ); + } } - # if user returns, that new email address gets authenticated in checkpassword() + } else { + $error = wfMsg( 'invalidemailaddress' ); } } else { - $wgUser->setEmail( strtolower($this->mUserEmail) ); + $wgUser->setEmail( $this->mUserEmail ); $wgUser->setCookies(); $wgUser->saveSettings(); } } + if( $needRedirect && $error === false ) { + $title =& Title::makeTitle( NS_SPECIAL, "Preferences" ); + $wgOut->redirect($title->getFullURL('success')); + return; + } + $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) ); $po = ParserOptions::newFromUser( $wgUser ); - $this->mainPrefsForm( wfMsg( 'savedprefs' ) ); + $this->mainPrefsForm( $error === false ? 'success' : 'error', $error); } /** @@ -293,7 +337,7 @@ class PreferencesForm { $this->mNick = $wgUser->getOption( 'nickname' ); $this->mQuickbar = $wgUser->getOption( 'quickbar' ); - $this->mSkin = $wgUser->getOption( 'skin' ); + $this->mSkin = Skin::normalizeKey( $wgUser->getOption( 'skin' ) ); $this->mMath = $wgUser->getOption( 'math' ); $this->mDate = $wgUser->getOption( 'date' ); $this->mRows = $wgUser->getOption( 'rows' ); @@ -306,6 +350,7 @@ class PreferencesForm { $this->mImageSize = $wgUser->getOption( 'imagesize' ); $this->mThumbSize = $wgUser->getOption( 'thumbsize' ); $this->mRecent = $wgUser->getOption( 'rclimit' ); + $this->mUnderline = $wgUser->getOption( 'underline' ); $togs = $wgLang->getUserToggles(); foreach ( $togs as $tname ) { @@ -315,7 +360,7 @@ class PreferencesForm { $namespaces = $wgContLang->getNamespaces(); foreach ( $namespaces as $i => $namespace ) { - if ( $i >= 0 ) { + if ( $i >= NS_MAIN ) { $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i ); } } @@ -325,48 +370,40 @@ class PreferencesForm { * @access private */ function namespacesCheckboxes() { - global $wgContLang, $wgUser; - + global $wgContLang; + # Determine namespace checkboxes $namespaces = $wgContLang->getNamespaces(); - $r1 = ''; + $r1 = null; foreach ( $namespaces as $i => $name ) { - # Skip special or anything similar - if ( $i >= 0 ) { - $checked = ''; - if ( $this->mSearchNs[$i] ) { - $checked = ' checked="checked"'; - } - $name = str_replace( '_', ' ', $namespaces[$i] ); - if ( '' == $name ) { - $name = wfMsg( 'blanknamespace' ); - } + if ($i < 0) + continue; + $checked = $this->mSearchNs[$i] ? "checked='checked'" : ''; + $name = str_replace( '_', ' ', $namespaces[$i] ); - if ( 0 != $i ) { - $r1 .= ' '; - } - $r1 .= "\n"; - } + if ( empty($name) ) + $name = wfMsg( 'blanknamespace' ); + + $r1 .= "
\n"; } - return $r1; } - function getToggle( $tname, $trailer = false) { + function getToggle( $tname, $trailer = false, $disabled = false ) { global $wgUser, $wgLang; - + $this->mUsedToggles[$tname] = true; $ttext = $wgLang->getUserToggle( $tname ); - + $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : ''; + $disabled = $disabled ? ' disabled="disabled"' : ''; $trailer = $trailer ? $trailer : ''; - return "
" . - " $trailer
"; + return "
" . + " $trailer
\n"; } - + function getToggles( $items ) { $out = ""; foreach( $items as $item ) { @@ -390,27 +427,26 @@ class PreferencesForm { /** * @access private */ - function mainPrefsForm( $err ) { + function mainPrefsForm( $status , $message = '' ) { global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames; global $wgAllowRealName, $wgImageLimits, $wgThumbLimits; - global $wgLanguageNames, $wgDisableLangConversion; - global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits; - global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress; + global $wgDisableLangConversion; + global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits; + global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress; global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication; - global $wgContLanguageCode; + global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins; $wgOut->setPageTitle( wfMsg( 'preferences' ) ); $wgOut->setArticleRelated( false ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); - if ( '' != $err ) { - $wgOut->addHTML( "

" . htmlspecialchars( $err ) . "

\n" ); + if ( $this->mSuccess || 'success' == $status ) { + $wgOut->addWikitext( '
'. wfMsg( 'savedprefs' ) . '
' ); + } else if ( 'error' == $status ) { + $wgOut->addWikitext( '
' . $message . '
' ); + } else if ( '' != $status ) { + $wgOut->addWikitext( $message . "\n----" ); } - $uname = $wgUser->getName(); - $uid = $wgUser->getID(); - - $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) ); - $wgOut->addWikiText( wfMsg('clearyourcache')); $qbs = $wgLang->getQuickbarSettings(); $skinNames = $wgLang->getSkinNames(); @@ -421,35 +457,113 @@ class PreferencesForm { $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' ); $action = $titleObj->escapeLocalURL(); - $wgOut->addHTML( "
" ); - + # Pre-expire some toggles so they won't show if disabled + $this->mUsedToggles[ 'shownumberswatching' ] = true; + $this->mUsedToggles[ 'showupdated' ] = true; + $this->mUsedToggles[ 'enotifwatchlistpages' ] = true; + $this->mUsedToggles[ 'enotifusertalkpages' ] = true; + $this->mUsedToggles[ 'enotifminoredits' ] = true; + $this->mUsedToggles[ 'enotifrevealaddr' ] = true; + $this->mUsedToggles[ 'uselivepreview' ] = true; + + # Enotif + # + $this->mUserEmail = htmlspecialchars( $this->mUserEmail ); + $this->mRealName = htmlspecialchars( $this->mRealName ); + $rawNick = $this->mNick; + $this->mNick = htmlspecialchars( $this->mNick ); + if ( !$this->mEmailFlag ) { $emfc = 'checked="checked"'; } + else { $emfc = ''; } + + + if ($wgEmailAuthentication && ($this->mUserEmail != '') ) { + if( $wgUser->getEmailAuthenticationTimestamp() ) { + $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'
'; + $disableEmailPrefs = false; + } else { + $disableEmailPrefs = true; + $skin = $wgUser->getSkin(); + $emailauthenticated = wfMsg('emailnotauthenticated').'
' . + $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ), + wfMsg( 'emailconfirmlink' ) ); + } + } else { + $emailauthenticated = ''; + $disableEmailPrefs = false; + } + + if ($this->mUserEmail == '') { + $emailauthenticated = wfMsg( 'noemailprefs' ); + } + + $ps = $this->namespacesCheckboxes(); + + $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : ''; + $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : ''; + $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : ''; + $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : ''; + $prefs_help_email_enotif = ( $wgEnotifWatchlist || $wgEnotifUserTalk) ? ' ' . wfMsg('prefs-help-email-enotif') : ''; + $prefs_help_realname = ''; + + #
+ + $wgOut->addHTML( "" ); + $wgOut->addHTML( "
" ); + # User data # $wgOut->addHTML( "
\n" . wfMsg('prefs-personal') . "\n\n"); + $wgOut->addHTML( + $this->addRow( + wfMsg( 'username'), + $wgUser->getName() + ) + ); + + $wgOut->addHTML( + $this->addRow( + wfMsg( 'uid' ), + $wgUser->getID() + ) + ); + + if ($wgAllowRealName) { $wgOut->addHTML( $this->addRow( - wfMsg('yourrealname'), - "mRealName}\" size='25' />" + '', + "mRealName}\" size='25' />" ) ); } if ($wgEnableEmail) { $wgOut->addHTML( $this->addRow( - wfMsg( 'youremail' ), - "mUserEmail}\" size='25' />" + '', + "mUserEmail}\" size='25' />" ) ); } - + + global $wgParser; + if( !empty( $this->mToggles['fancysig'] ) && + false === $wgParser->validateSig( $rawNick ) ) { + $invalidSig = $this->addRow( + ' ', + '' . wfMsgHtml( 'badsig' ) . '' + ); + } else { + $invalidSig = ''; + } + $wgOut->addHTML( $this->addRow( - wfMsg( 'yournick' ), - "mNick}\" size='25' />" - ) . + '', + "mNick}\" size='25' />" + ) . + $invalidSig . # FIXME: The part should be where the   is, getToggle() needs # to be changed to out return its output in two parts. -ævar $this->addRow( @@ -458,14 +572,24 @@ class PreferencesForm { ) ); + /** + * Make sure the site language is in the list; a custom language code + * might not have a defined name... + */ + $languages = $wgLang->getLanguageNames(); + if( !array_key_exists( $wgContLanguageCode, $languages ) ) { + $languages[$wgContLanguageCode] = $wgContLanguageCode; + } + ksort( $languages ); + /** * If a bogus value is set, default to the content language. * Otherwise, no default is selected and the user ends up * with an Afrikaans interface since it's first in the list. */ - $selectedLang = isset( $wgLanguageNames[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode; + $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode; $selbox = null; - foreach($wgLanguageNames as $code => $name) { + foreach($languages as $code => $name) { global $IP; /* only add languages that have a file */ $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php"; @@ -474,25 +598,32 @@ class PreferencesForm { $selbox .= "\n"; } } - $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "" )); + $wgOut->addHTML( + $this->addRow( + '', + "" + ) + ); /* see if there are multiple language variants to choose from*/ if(!$wgDisableLangConversion) { $variants = $wgContLang->getVariants(); - + $variantArray = array(); + foreach($variants as $v) { $v = str_replace( '_', '-', strtolower($v)); - if($name = $wgLanguageNames[$v]) { - $variantArray[$v] = $name; + if( array_key_exists( $v, $languages ) ) { + // If it doesn't have a name, we'll pretend it doesn't exist + $variantArray[$v] = $languages[$v]; } } - + $selbox = null; foreach($variantArray as $code => $name) { $sel = $code == $this->mUserVariant ? 'selected="selected"' : ''; $selbox .= ""; } - + if(count($variantArray) > 1) { $wgOut->addHtml( $this->addRow( wfMsg( 'yourvariant' ), "" ) @@ -508,61 +639,42 @@ class PreferencesForm { $wgOut->addHTML( '
' . wfMsg( 'changepassword' ) . '
'); $wgOut->addHTML( - $this->addRow( wfMsg( 'oldpassword' ), "mOldpass}\" size='20' />" ) . - $this->addRow( wfMsg( 'newpassword' ), "mNewpass}\" size='20' />" ) . - $this->addRow( wfMsg( 'retypenew' ), "mRetypePass}\" size='20' />" ) . + $this->addRow( + '', + "mOldpass}\" size='20' />" + ) . + $this->addRow( + '', + "mNewpass}\" size='20' />" + ) . + $this->addRow( + '', + "mRetypePass}\" size='20' />" + ) . "
\n" . $this->getToggle( "rememberpassword" ) . "
\n\n" ); + # # Enotif - $this->mUserEmail = htmlspecialchars( $this->mUserEmail ); - $this->mRealName = htmlspecialchars( $this->mRealName ); - $this->mNick = htmlspecialchars( $this->mNick ); - - if ($wgEmailAuthentication && ($this->mUserEmail != '') ) { - if ($wgUser->getEmailAuthenticationtimestamp() != 0) { - $emailauthenticated = wfMsg('emailauthenticated', - $wgLang->timeanddate($wgUser->getEmailAuthenticationtimestamp(), true ) ).'
'; - $disabled = ''; - } else { - $emailauthenticated = wfMsg('emailnotauthenticated').'
'; - $disabled = ' '.wfMsg('disableduntilauthent'); - } - } else { - $emailauthenticated = ''; - } - - if ($this->mUserEmail == '') { - $disabled = ' '.wfMsg('disablednoemail'); - } - - $ps = $this->namespacesCheckboxes(); - - $enotifwatchlistpages = $wgEmailNotificationForWatchlistPages ? $this->getToggle( 'enotifwatchlistpages', $disabled) : ''; - $enotifusertalkpages = $wgEmailNotificationForUserTalkPages ? $this->getToggle( 'enotifusertalkpages', $disabled) : ''; - $enotifminoredits = $wgEmailNotificationForMinorEdits ? $this->getToggle( 'enotifminoredits', $disabled) : ''; - $enotifrevealaddr = $wgEmailNotificationRevealPageEditorAddress ? $this->getToggle( 'enotifrevealaddr', $disabled) : ''; - $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : ''; - if( $wgEnableEmail ) { - $wgOut->addHTML( "
" . wfMsg('email') . ""); + if ($wgEnableEmail) { + $wgOut->addHTML( '
' . wfMsg( 'email' ) . '' ); $wgOut->addHTML( - $emailauthenticated. - $enotifrevealaddr. - $enotifwatchlistpages. - $enotifusertalkpages. - $enotifminoredits ); - if( $wgEnableUserEmail ) { - $emfc = $this->mEmailFlag ? 'checked="checked"' : ''; + $emailauthenticated. + $enotifrevealaddr. + $enotifwatchlistpages. + $enotifusertalkpages. + $enotifminoredits ); + if ($wgEnableUserEmail) { + $emf = wfMsg( 'allowemail' ); + $disabled = $disableEmailPrefs ? ' disabled="disabled"' : ''; $wgOut->addHTML( - "
". - "
\n" ); - $prefs_help_realname = $wgAllowRealName ? wfMsg('prefs-help-realname') : ''; + "
" ); } + $wgOut->addHTML( '
' ); } - + # + if ($wgAllowRealName || $wgEnableEmail) { $wgOut->addHTML("
"); $rn = $wgAllowRealName ? wfMsg('prefs-help-realname') : ''; @@ -571,7 +683,7 @@ class PreferencesForm { } $wgOut->addHTML( '
' ); - + # Quickbar # if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') { @@ -582,131 +694,185 @@ class PreferencesForm { $wgOut->addHTML( "
\n" ); } $wgOut->addHtml( "\n\n" ); + } else { + # Need to output a hidden option even if the relevant skin is not in use, + # otherwise the preference will get reset to 0 on submit + $wgOut->addHTML( "" ); } # Skin # $wgOut->addHTML( "
\n\n" . wfMsg('skin') . "\n" ); + $mptitle = Title::newMainPage(); + $previewtext = wfMsg('skinpreview'); # Only show members of $wgValidSkinNames rather than # $skinNames (skins is all skin names from Language.php) foreach ($wgValidSkinNames as $skinkey => $skinname ) { - global $wgDefaultSkin; - + if ( in_array( $skinkey, $wgSkipSkins ) ) { + continue; + } $checked = $skinkey == $this->mSkin ? ' checked="checked"' : ''; $sn = isset( $skinNames[$skinkey] ) ? $skinNames[$skinkey] : $skinname; - + + $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey")); + $previewlink = "$previewtext"; if( $skinkey == $wgDefaultSkin ) $sn .= ' (' . wfMsg( 'default' ) . ')'; - $wgOut->addHTML( " {$sn}
\n" ); + $wgOut->addHTML( " $previewlink
\n" ); } $wgOut->addHTML( "
\n\n" ); # Math # - $wgOut->addHTML( "
\n" . wfMsg('math') . '' ); - foreach ( $mathopts as $k => $v ) { - $checked = $k == $this->mMath ? ' checked="checked"' : ''; - $wgOut->addHTML( "
\n" ); + global $wgUseTeX; + if( $wgUseTeX ) { + $wgOut->addHTML( "
\n" . wfMsg('math') . '' ); + foreach ( $mathopts as $k => $v ) { + $checked = $k == $this->mMath ? ' checked="checked"' : ''; + $wgOut->addHTML( "
\n" ); + } + $wgOut->addHTML( "
\n\n" ); } - $wgOut->addHTML( "
\n\n" ); # Files # $wgOut->addHTML("
" . wfMsg( 'files' ) . " -
-
+
\n\n"); + $wgOut->addHTML( "{$imageThumbOptions}
\n\n"); + + # Date format + # + # Date/Time + # + + $wgOut->addHTML( "
\n" . wfMsg( 'datetime' ) . "\n" ); - # Date format - # if ($dateopts) { - $wgOut->addHTML( "
\n" . wfMsg('dateformat') . "\n" ); + $wgOut->addHTML( "
\n" . wfMsg( 'dateformat' ) . "\n" ); + $idCnt = 0; + $epoch = '20010115161234'; foreach($dateopts as $key => $option) { + if( $key == MW_DATE_DEFAULT ) { + $formatted = wfMsgHtml( 'datedefault' ); + } else { + $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) ); + } ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = ''; - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( "
\n" ); + $idCnt++; } - $wgOut->addHTML( "
\n\n"); + $wgOut->addHTML( "
\n" ); } - # Time zone - # - $nowlocal = $wgLang->time( $now = wfTimestampNow(), true ); $nowserver = $wgLang->time( $now, false ); - - $wgOut->addHTML( '
' . wfMsg( 'timezonelegend' ) . '' . + + $wgOut->addHTML( '
' . wfMsg( 'timezonelegend' ). '
' . $this->addRow( wfMsg( 'servertime' ), $nowserver ) . $this->addRow( wfMsg( 'localtime' ), $nowlocal ) . $this->addRow( - wfMsg( 'timezoneoffset' ), - "mHourDiff ) . "\" size='6' />" + '', + "mHourDiff ) . "\" size='6' />" ) . "
-
-
*" . wfMsg( 'timezonetext' ) . "
-
\n\n" ); - +
+
¹" . wfMsg( 'timezonetext' ) . "
+ \n\n" ); + # Editing # - $wgOut->addHTML( "
" . wfMsg( 'textboxsize' ) . " \n -
- - -
" . - $this->getToggles( array( - "editsection", - "editsectiononrightclick", - "editondblclick", - "editwidth", - "showtoolbar", - "previewonfirst", - "previewontop", - "watchdefault", - "minordefault", - "externaleditor", - "externaldiff" ) ) . - " -
"); - - $wgOut->addHTML( " -
".htmlspecialchars(wfMsg('prefs-rc'))." -
" . - $this->getToggles( array( - "hideminor", - ($wgRCShowWatchingUsers) ? 'shownumberswatching' : false, - "usenewrc", - "rcusemodstyle", - array( 'showupdated', wfMsg('updatedmarker') ) - ) ) . - "
-
"); - - $wgOut->addHTML( "
" . wfMsg( 'searchresultshead' ) . "" . - $this->addRow( wfMsg( 'resultsperpage' ), "mSearch\" size='4' />" ) . - $this->addRow( wfMsg( 'contextlines' ), "mSearchLines\" size='4' />") . - $this->addRow( wfMsg( 'contextchars' ), "mSearchChars\" size='4' />") . + global $wgLivePreview, $wgUseRCPatrol; + $wgOut->addHTML( '
' . wfMsg( 'textboxsize' ) . ' +
+ mRows}\" size='3' /> + mCols}\" size='3' /> +
" . + $this->getToggles( array( + 'editsection', + 'editsectiononrightclick', + 'editondblclick', + 'editwidth', + 'showtoolbar', + 'previewonfirst', + 'previewontop', + 'watchcreations', + 'watchdefault', + 'minordefault', + 'externaleditor', + 'externaldiff', + $wgLivePreview ? 'uselivepreview' : false, + $wgUser->isAllowed( 'patrol' ) && $wgUseRCPatrol ? 'autopatrol' : false, + 'forceeditsummary', + ) ) . '
' + ); + $this->mUsedToggles['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it + + $wgOut->addHTML( '
' . htmlspecialchars(wfMsg('prefs-rc')) . '' . + ' mRecent\" size='3' />" . + $this->getToggles( array( + 'hideminor', + $wgRCShowWatchingUsers ? 'shownumberswatching' : false, + 'usenewrc' ) + ) . '
' + ); + + $wgOut->addHTML( '
' . wfMsg( 'searchresultshead' ) . '
' . + $this->addRow( + '', + "mSearch\" size='4' />" + ) . + $this->addRow( + '', + "mSearchLines\" size='4' />" + ) . + $this->addRow( + '', + "mSearchChars\" size='4' />" + ) . "
" . wfMsg( 'defaultns' ) . "$ps
" ); - + # Misc # $wgOut->addHTML('
' . wfMsg('prefs-misc') . ''); - + $wgOut->addHTML( + '' . + " mStubs\" size='6' />" + ); + $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) ); + $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) ); + $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) ); + $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) ); + $uopt = $wgUser->getOption("underline"); + $s0 = $uopt == 0 ? ' selected="selected"' : ''; + $s1 = $uopt == 1 ? ' selected="selected"' : ''; + $s2 = $uopt == 2 ? ' selected="selected"' : ''; + $wgOut->addHTML(" +
+ +
+"); foreach ( $togs as $tname ) { if( !array_key_exists( $tname, $this->mUsedToggles ) ) { $wgOut->addHTML( $this->getToggle( $tname ) ); @@ -718,15 +884,18 @@ class PreferencesForm { $wgOut->addHTML( "
- - + +
- +
- + - \n" ); + \n" ); + + $wgOut->addWikiText( '
' . wfMsg('clearyourcache') . '
' ); + } } ?>