From a58285fd06c8113c45377c655dd43cef6337e815 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 11 Jan 2007 19:06:07 +0000 Subject: Aktualisierung auf MediaWiki 1.9.0 --- includes/SpecialPreferences.php | 174 +++++++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 75 deletions(-) (limited to 'includes/SpecialPreferences.php') diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 5eadf3d6..643932c4 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -34,7 +34,7 @@ class PreferencesForm { * Load some values */ function PreferencesForm( &$request ) { - global $wgLang, $wgContLang, $wgUser, $wgAllowRealName; + global $wgContLang, $wgUser, $wgAllowRealName; $this->mQuickbar = $request->getVal( 'wpQuickbar' ); $this->mOldpass = $request->getVal( 'wpOldpass' ); @@ -206,7 +206,7 @@ class PreferencesForm { function savePreferences() { global $wgUser, $wgOut, $wgParser; global $wgEnableUserEmail, $wgEnableEmail; - global $wgEmailAuthentication, $wgMinimalPasswordLength; + global $wgEmailAuthentication; global $wgAuth; @@ -216,22 +216,18 @@ class PreferencesForm { return; } - if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) { - $this->mainPrefsForm( 'error', wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) ); - return; - } - if (!$wgUser->checkPassword( $this->mOldpass )) { $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) ); return; } - if (!$wgAuth->setPassword( $wgUser, $this->mNewpass )) { - $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) ); + + try { + $wgUser->setPassword( $this->mNewpass ); + $this->mNewpass = $this->mOldpass = $this->mRetypePass = ''; + } catch( PasswordError $e ) { + $this->mainPrefsForm( 'error', $e->getMessage() ); return; } - $wgUser->setPassword( $this->mNewpass ); - $this->mNewpass = $this->mOldpass = $this->mRetypePass = ''; - } $wgUser->setRealName( $this->mRealName ); @@ -328,13 +324,12 @@ class PreferencesForm { } if( $needRedirect && $error === false ) { - $title =& Title::makeTitle( NS_SPECIAL, "Preferences" ); + $title =& SpecialPage::getTitleFor( "Preferences" ); $wgOut->redirect($title->getFullURL('success')); return; } $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) ); - $po = ParserOptions::newFromUser( $wgUser ); $this->mainPrefsForm( $error === false ? 'success' : 'error', $error); } @@ -342,18 +337,16 @@ class PreferencesForm { * @access private */ function resetPrefs() { - global $wgUser, $wgLang, $wgContLang, $wgAllowRealName; + global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName; $this->mOldpass = $this->mNewpass = $this->mRetypePass = ''; $this->mUserEmail = $wgUser->getEmail(); $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : ''; - $this->mUserLanguage = $wgUser->getOption( 'language' ); - if( empty( $this->mUserLanguage ) ) { - # Quick hack for conversions, where this value is blank - global $wgContLanguageCode; - $this->mUserLanguage = $wgContLanguageCode; - } + + # language value might be blank, default to content language + $this->mUserLanguage = $wgUser->getOption( 'language', $wgContLanguageCode ); + $this->mUserVariant = $wgUser->getOption( 'variant'); $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0; $this->mNick = $wgUser->getOption( 'nickname' ); @@ -378,7 +371,6 @@ class PreferencesForm { $togs = User::getToggles(); foreach ( $togs as $tname ) { - $ttext = wfMsg('tog-'.$tname); $this->mToggles[$tname] = $wgUser->getOption( $tname ); } @@ -478,7 +470,7 @@ class PreferencesForm { $dateopts = $wgLang->getDatePreferences(); $togs = User::getToggles(); - $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' ); + $titleObj = SpecialPage::getTitleFor( 'Preferences' ); $action = $titleObj->escapeLocalURL(); # Pre-expire some toggles so they won't show if disabled @@ -488,6 +480,7 @@ class PreferencesForm { $this->mUsedToggles[ 'enotifusertalkpages' ] = true; $this->mUsedToggles[ 'enotifminoredits' ] = true; $this->mUsedToggles[ 'enotifrevealaddr' ] = true; + $this->mUsedToggles[ 'ccmeonemails' ] = true; $this->mUsedToggles[ 'uselivepreview' ] = true; # Enotif @@ -508,7 +501,7 @@ class PreferencesForm { $disableEmailPrefs = true; $skin = $wgUser->getSkin(); $emailauthenticated = wfMsg('emailnotauthenticated').'
' . - $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ), + $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ), wfMsg( 'emailconfirmlink' ) ); } } else { @@ -526,8 +519,6 @@ class PreferencesForm { $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 = ''; # @@ -539,19 +530,19 @@ class PreferencesForm { $wgOut->addHTML( "
\n" . wfMsg('prefs-personal') . "\n\n"); - $wgOut->addHTML( + $userInformationHtml = $this->addRow( wfMsg( 'username'), $wgUser->getName() - ) - ); - - $wgOut->addHTML( + ) . $this->addRow( wfMsg( 'uid' ), $wgUser->getID() - ) - ); + ); + + if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) { + $wgOut->addHtml( $userInformationHtml ); + } if ($wgAllowRealName) { @@ -600,7 +591,7 @@ class PreferencesForm { * Make sure the site language is in the list; a custom language code * might not have a defined name... */ - $languages = $wgLang->getLanguageNames( true ); + $languages = Language::getLanguageNames( true ); if( !array_key_exists( $wgContLanguageCode, $languages ) ) { $languages[$wgContLanguageCode] = $wgContLanguageCode; } @@ -612,16 +603,15 @@ class PreferencesForm { * with an Afrikaans interface since it's first in the list. */ $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode; - $selbox = null; - foreach($languages as $code => $name) { - global $IP; - $sel = ($code == $selectedLang)? ' selected="selected"' : ''; - $selbox .= "\n"; + $options = "\n"; + foreach( $languages as $code => $name ) { + $selected = ($code == $selectedLang); + $options .= Xml::option( "$code - $name", $code, $selected ) . "\n"; } $wgOut->addHTML( $this->addRow( '', - "" + "" ) ); @@ -638,15 +628,16 @@ class PreferencesForm { } } - $selbox = null; - foreach($variantArray as $code => $name) { - $sel = $code == $this->mUserVariant ? 'selected="selected"' : ''; - $selbox .= ""; + $options = "\n"; + foreach( $variantArray as $code => $name ) { + $selected = ($code == $this->mUserVariant); + $options .= Xml::option( "$code - $name", $code, $selected ) . "\n"; } if(count($variantArray) > 1) { $wgOut->addHtml( - $this->addRow( wfMsg( 'yourvariant' ), "" ) + $this->addRow( wfMsg( 'yourvariant' ), + "" ) ); } } @@ -692,6 +683,7 @@ class PreferencesForm { $wgOut->addHTML( "
" ); } + $wgOut->addHtml( $this->getToggle( 'ccmeonemails' ) ); $wgOut->addHTML( '' ); } @@ -732,12 +724,19 @@ class PreferencesForm { # Only show members of Skin::getSkinNames() rather than # $skinNames (skins is all skin names from Language.php) $validSkinNames = Skin::getSkinNames(); - foreach ($validSkinNames as $skinkey => $skinname ) { + # Sort by UI skin name. First though need to update validSkinNames as sometimes + # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI). + foreach ($validSkinNames as $skinkey => & $skinname ) { + if ( isset( $skinNames[$skinkey] ) ) { + $skinname = $skinNames[$skinkey]; + } + } + asort($validSkinNames); + foreach ($validSkinNames as $skinkey => $sn ) { 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"; @@ -761,24 +760,41 @@ class PreferencesForm { # Files # - $wgOut->addHTML("
- " . wfMsg( 'files' ) . " -
-
\n\n"); + + $thumbSizeId = 'wpThumbSize'; + $wgOut->addHTML( + "
" . Xml::label( wfMsg('thumbsize'), $thumbSizeId ) . " " . + Xml::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) . + $imageThumbOptions . + Xml::closeElement( 'select' ) . "
\n" + ); + + $wgOut->addHTML( "\n\n" ); # Date format # @@ -837,17 +853,13 @@ class PreferencesForm { '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')) . '' . wfInputLabel( wfMsg( 'recentchangescount' ), @@ -860,16 +872,29 @@ class PreferencesForm { ); # Watchlist - $wgOut->addHTML( '
' . wfMsgHtml( 'prefs-watchlist' ) . '' ); - - $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), - 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) ); - $wgOut->addHTML( '

' ); # Spacing - $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'extendwatchlist' ) ) ); - $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), - 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) ); - - $wgOut->addHTML( '
' ); + $wgOut->addHtml( '
' . wfMsgHtml( 'prefs-watchlist' ) . '' ); + + $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) ); + $wgOut->addHtml( '

' ); + + $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) ); + $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) ); + $wgOut->addHtml( '

' ); + + $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) ); + + if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) ) + $wgOut->addHtml( $this->getToggle( 'watchcreations' ) ); + foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) { + if( $wgUser->isAllowed( $action ) ) + $wgOut->addHtml( $this->getToggle( $toggle ) ); + } + $this->mUsedToggles['watchcreations'] = true; + $this->mUsedToggles['watchdefault'] = true; + $this->mUsedToggles['watchmoves'] = true; + $this->mUsedToggles['watchdeletion'] = true; + + $wgOut->addHtml( '
' ); # Search $wgOut->addHTML( '
' . wfMsg( 'searchresultshead' ) . '
' . @@ -901,14 +926,13 @@ class PreferencesForm { $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 ) ); -- cgit v1.2.2