Let's just kill $wgUpdates since OpenID was converted in r72798.
[lhc/web/wiklou.git] / includes / Preferences.php
index d2ce5ce..abb3f5c 100644 (file)
@@ -35,8 +35,6 @@ class Preferences {
                if ( self::$defaultPreferences )
                        return self::$defaultPreferences;
 
-               global $wgRCMaxAge;
-
                $defaultPreferences = array();
 
                self::profilePreferences( $user, $defaultPreferences );
@@ -62,7 +60,6 @@ class Preferences {
                }
 
                ## Prod in defaults from the user
-               global $wgDefaultUserOptions;
                foreach ( $defaultPreferences as $name => &$info ) {
                        $prefFromUser = self::getOptionFromUser( $name, $info, $user );
                        $field = HTMLForm::loadInputFromParameters( $info ); // For validation
@@ -217,18 +214,24 @@ class Preferences {
                                'section' => 'personal/info',
                        );
                }
-
-               $defaultPreferences['rememberpassword'] = array(
-                       'type' => 'toggle',
-                       'label-message' => 'tog-rememberpassword',
-                       'section' => 'personal/info',
-               );
+               global $wgCookieExpiration;
+               if ( $wgCookieExpiration > 0 ) {
+                       $defaultPreferences['rememberpassword'] = array(
+                               'type' => 'toggle',
+                               'label' => wfMsgExt(
+                                       'tog-rememberpassword',
+                                       array( 'parsemag' ),
+                                       $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )
+                                       ),
+                               'section' => 'personal/info',
+                       );
+               }
 
                // Language
-               global $wgContLanguageCode;
-               $languages = array_reverse( Language::getLanguageNames( false ) );
-               if ( !array_key_exists( $wgContLanguageCode, $languages ) ) {
-                       $languages[$wgContLanguageCode] = $wgContLanguageCode;
+               global $wgLanguageCode;
+               $languages = Language::getLanguageNames( false );
+               if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
+                       $languages[$wgLanguageCode] = $wgLanguageCode;
                }
                ksort( $languages );
 
@@ -436,7 +439,7 @@ class Preferences {
                $defaultPreferences['skin'] = array(
                        'type' => 'radio',
                        'options' => self::generateSkinOptions( $user ),
-                       'label' => ' ',
+                       'label' => ' ',
                        'section' => 'rendering/skin',
                );
 
@@ -468,8 +471,6 @@ class Preferences {
 
                $selectedSkin = $user->getOption( 'skin' );
                if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) {
-                       global $wgLang;
-
                        $settings = array_flip( $wgLang->getQuickbarSettings() );
 
                        $defaultPreferences['quickbar'] = array(
@@ -488,7 +489,7 @@ class Preferences {
                        $defaultPreferences['math'] = array(
                                'type' => 'radio',
                                'options' => array_flip( array_map( 'wfMsgHtml', $wgLang->getMathNames() ) ),
-                               'label' => ' ',
+                               'label' => ' ',
                                'section' => 'rendering/math',
                        );
                }
@@ -519,7 +520,7 @@ class Preferences {
                        $defaultPreferences['date'] = array(
                                'type' => 'radio',
                                'options' => $dateOptions,
-                               'label' => ' ',
+                               'label' => ' ',
                                'section' => 'datetime/dateformat',
                        );
                }
@@ -582,8 +583,8 @@ class Preferences {
                        );
                }
 
-               $stubThresholdValues = array( 0, 50, 100, 500, 1000, 2000, 5000, 10000 );
-               $stubThresholdOptions = array();
+               $stubThresholdValues = array( 50, 100, 500, 1000, 2000, 5000, 10000 );
+               $stubThresholdOptions = array( wfMsg( 'stub-threshold-disabled' ) => 0 );
                foreach ( $stubThresholdValues as $value ) {
                        $stubThresholdOptions[wfMsg( 'size-bytes', $value )] = $value;
                }
@@ -704,11 +705,6 @@ class Preferences {
                        'section' => 'editing/advancedediting',
                        'label-message' => 'tog-showtoolbar',
                );
-               $defaultPreferences['minordefault'] = array(
-                       'type' => 'toggle',
-                       'section' => 'editing/advancedediting',
-                       'label-message' => 'tog-minordefault',
-               );
 
                if ( $wgUseExternalEditor ) {
                        $defaultPreferences['externaleditor'] = array(
@@ -744,7 +740,7 @@ class Preferences {
                $defaultPreferences['rcdays'] = array(
                        'type' => 'float',
                        'label-message' => 'recentchangesdays',
-                       'section' => 'rc/display',
+                       'section' => 'rc/displayrc',
                        'min' => 1,
                        'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ),
                        'help' => wfMsgExt(
@@ -757,7 +753,7 @@ class Preferences {
                        'type' => 'int',
                        'label-message' => 'recentchangescount',
                        'help-message' => 'prefs-help-recentchangescount',
-                       'section' => 'rc/display',
+                       'section' => 'rc/displayrc',
                );
                $defaultPreferences['usenewrc'] = array(
                        'type' => 'toggle',
@@ -801,7 +797,7 @@ class Preferences {
                        'type' => 'float',
                        'min' => 0,
                        'max' => 7,
-                       'section' => 'watchlist/display',
+                       'section' => 'watchlist/displaywatchlist',
                        'help' => wfMsgHtml( 'prefs-watchlist-days-max' ),
                        'label-message' => 'prefs-watchlist-days',
                );
@@ -811,7 +807,7 @@ class Preferences {
                        'max' => 1000,
                        'label-message' => 'prefs-watchlist-edits',
                        'help' => wfMsgHtml( 'prefs-watchlist-edits-max' ),
-                       'section' => 'watchlist/display',
+                       'section' => 'watchlist/displaywatchlist',
                );
                $defaultPreferences['extendwatchlist'] = array(
                        'type' => 'toggle',
@@ -844,6 +840,14 @@ class Preferences {
                        'label-message' => 'tog-watchlisthideliu',
                );
 
+               if ( $wgUseRCPatrol ) {
+                       $defaultPreferences['watchlisthidepatrolled'] = array(
+                               'type' => 'toggle',
+                               'section' => 'watchlist/advancedwatchlist',
+                               'label-message' => 'tog-watchlisthidepatrolled',
+                       );
+               }
+
                if ( $wgEnableAPI ) {
                        # Some random gibberish as a proposed default
                        $hash = sha1( mt_rand() . microtime( true ) );
@@ -856,14 +860,6 @@ class Preferences {
                        );
                }
 
-               if ( $wgUseRCPatrol ) {
-                       $defaultPreferences['watchlisthidepatrolled'] = array(
-                               'type' => 'toggle',
-                               'section' => 'watchlist/advancedwatchlist',
-                               'label-message' => 'tog-watchlisthidepatrolled',
-                       );
-               }
-
                $watchTypes = array(
                        'edit' => 'watchdefault',
                        'move' => 'watchmoves',
@@ -893,19 +889,19 @@ class Preferences {
                $defaultPreferences['searchlimit'] = array(
                        'type' => 'int',
                        'label-message' => 'resultsperpage',
-                       'section' => 'searchoptions/display',
+                       'section' => 'searchoptions/displaysearchoptions',
                        'min' => 0,
                );
                $defaultPreferences['contextlines'] = array(
                        'type' => 'int',
                        'label-message' => 'contextlines',
-                       'section' => 'searchoptions/display',
+                       'section' => 'searchoptions/displaysearchoptions',
                        'min' => 0,
                );
                $defaultPreferences['contextchars'] = array(
                        'type' => 'int',
                        'label-message' => 'contextchars',
-                       'section' => 'searchoptions/display',
+                       'section' => 'searchoptions/displaysearchoptions',
                        'min' => 0,
                );
 
@@ -914,7 +910,16 @@ class Preferences {
                        $defaultPreferences['disablesuggest'] = array(
                                'type' => 'toggle',
                                'label-message' => 'mwsuggest-disable',
-                               'section' => 'searchoptions/display',
+                               'section' => 'searchoptions/displaysearchoptions',
+                       );
+               }
+               
+               global $wgVectorUseSimpleSearch;
+               if ( $wgVectorUseSimpleSearch ) {
+                       $defaultPreferences['vector-simplesearch'] = array(
+                               'type' => 'toggle',
+                               'label-message' => 'vector-simplesearch-preference',
+                               'section' => 'searchoptions/displaysearchoptions'
                        );
                }
 
@@ -981,8 +986,8 @@ class Preferences {
        }
 
        /**
-        * @param object $user The user object
-        * @return array Text/links to display as key; $skinkey as value
+        * @param $user The User object
+        * @return Array: text/links to display as key; $skinkey as value
         */
        static function generateSkinOptions( $user ) {
                global $wgDefaultSkin, $wgLang, $wgAllowUserCss, $wgAllowUserJs;
@@ -1055,7 +1060,6 @@ class Preferences {
                                $wgDefaultUserOptions['date'] = 'default';
                        }
 
-                       $idCnt = 0;
                        $epoch = wfTimestampNow();
                        foreach ( $dateopts as $key ) {
                                if ( $key == 'default' ) {
@@ -1135,11 +1139,13 @@ class Preferences {
                return true;
        }
 
-       static function getFormObject( $user ) {
+       static function getFormObject( $user, $formClass = 'PreferencesForm' ) {
                $formDescriptor = Preferences::getPreferences( $user );
-               $htmlForm = new PreferencesForm( $formDescriptor, 'prefs' );
+               $htmlForm = new $formClass( $formDescriptor, 'prefs' );
 
                $htmlForm->setSubmitText( wfMsg( 'saveprefs' ) );
+               # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
+               $htmlForm->setSubmitTooltip( 'preferences-save' );
                $htmlForm->setTitle( SpecialPage::getTitleFor( 'Preferences' ) );
                $htmlForm->setSubmitID( 'prefsubmit' );
                $htmlForm->setSubmitCallback( array( 'Preferences', 'tryFormSubmit' ) );