Content: Deprecate and stop using getHighlightHtml()
[lhc/web/wiklou.git] / includes / Preferences.php
index ba1aae8..493626a 100644 (file)
@@ -71,8 +71,8 @@ class Preferences {
 
        /**
         * @throws MWException
-        * @param $user User
-        * @param $context IContextSource
+        * @param User $user
+        * @param IContextSource $context
         * @return array|null
         */
        static function getPreferences( $user, IContextSource $context ) {
@@ -84,8 +84,8 @@ class Preferences {
 
                self::profilePreferences( $user, $context, $defaultPreferences );
                self::skinPreferences( $user, $context, $defaultPreferences );
-               self::filesPreferences( $user, $context, $defaultPreferences );
                self::datetimePreferences( $user, $context, $defaultPreferences );
+               self::filesPreferences( $user, $context, $defaultPreferences );
                self::renderingPreferences( $user, $context, $defaultPreferences );
                self::editingPreferences( $user, $context, $defaultPreferences );
                self::rcPreferences( $user, $context, $defaultPreferences );
@@ -143,10 +143,10 @@ class Preferences {
        /**
         * Pull option from a user account. Handles stuff like array-type preferences.
         *
-        * @param $name
-        * @param $info
-        * @param $user User
-        * @return array|String
+        * @param string $name
+        * @param array $info
+        * @param User $user
+        * @return array|string
         */
        static function getOptionFromUser( $name, $info, $user ) {
                $val = $user->getOption( $name );
@@ -186,14 +186,14 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         * @return void
         */
        static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
-                       $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars,
+                       $wgDisableLangConversion, $wgMaxSigChars,
                        $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
                        $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
                        $wgSecureLogin;
@@ -301,15 +301,7 @@ class Preferences {
                                'section' => 'personal/info',
                        );
                }
-               if ( $wgCookieExpiration > 0 ) {
-                       $defaultPreferences['rememberpassword'] = array(
-                               'type' => 'toggle',
-                               'label' => $context->msg( 'tog-rememberpassword' )->numParams(
-                                       ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(),
-                               'section' => 'personal/info',
-                       );
-               }
-               // Only show preferhttps if secure login is turned on
+               // Only show prefershttps if secure login is turned on
                if ( $wgSecureLogin && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) {
                        $defaultPreferences['prefershttps'] = array(
                                'type' => 'toggle',
@@ -381,14 +373,6 @@ class Preferences {
                                                'section' => 'personal/i18n',
                                                'help-message' => 'prefs-help-variant',
                                        );
-
-                                       if ( !$wgDisableTitleConversion ) {
-                                               $defaultPreferences['noconvertlink'] = array(
-                                                       'type' => 'toggle',
-                                                       'section' => 'personal/i18n',
-                                                       'label-message' => 'tog-noconvertlink',
-                                               );
-                                       }
                                } else {
                                        $defaultPreferences["variant-$langCode"] = array(
                                                'type' => 'api',
@@ -578,9 +562,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         * @return void
         */
        static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
@@ -622,9 +606,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function filesPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                ## Files #####################################
@@ -643,9 +627,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         * @return void
         */
        static function datetimePreferences( $user, IContextSource $context, &$defaultPreferences ) {
@@ -656,7 +640,7 @@ class Preferences {
                                'type' => 'radio',
                                'options' => $dateOptions,
                                'label' => ' ',
-                               'section' => 'datetime/dateformat',
+                               'section' => 'rendering/dateformat',
                        );
                }
 
@@ -673,7 +657,7 @@ class Preferences {
                        'raw' => 1,
                        'label-message' => 'servertime',
                        'default' => $nowserver,
-                       'section' => 'datetime/timeoffset',
+                       'section' => 'rendering/timeoffset',
                );
 
                $defaultPreferences['nowlocal'] = array(
@@ -681,7 +665,7 @@ class Preferences {
                        'raw' => 1,
                        'label-message' => 'localtime',
                        'default' => $nowlocal,
-                       'section' => 'datetime/timeoffset',
+                       'section' => 'rendering/timeoffset',
                );
 
                // Grab existing pref.
@@ -711,14 +695,14 @@ class Preferences {
                        'options' => $tzOptions,
                        'default' => $tzSetting,
                        'size' => 20,
-                       'section' => 'datetime/timeoffset',
+                       'section' => 'rendering/timeoffset',
                );
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function renderingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                ## Diffs ####################################
@@ -776,9 +760,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgAllowUserCssPrefs;
@@ -864,9 +848,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgRCMaxAge, $wgRCShowWatchingUsers;
@@ -921,9 +905,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function watchlistPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge;
@@ -1025,20 +1009,12 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
-               global $wgContLang, $wgVectorUseSimpleSearch;
-
-               if ( $wgVectorUseSimpleSearch ) {
-                       $defaultPreferences['vector-simplesearch'] = array(
-                               'type' => 'toggle',
-                               'label-message' => 'vector-simplesearch-preference',
-                               'section' => 'searchoptions/displaysearchoptions',
-                       );
-               }
+               global $wgContLang;
 
                $defaultPreferences['searcheverything'] = array(
                        'type' => 'toggle',
@@ -1070,9 +1046,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User The User object
-        * @param $context IContextSource
-        * @return Array: text/links to display as key; $skinkey as value
+        * @param User $user The User object
+        * @param IContextSource $context
+        * @return array Text/links to display as key; $skinkey as value
         */
        static function generateSkinOptions( $user, IContextSource $context ) {
                global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs;
@@ -1081,9 +1057,8 @@ class Preferences {
                $mptitle = Title::newMainPage();
                $previewtext = $context->msg( 'skin-preview' )->text();
 
-               # Only show members of Skin::getSkinNames() rather than
-               # $skinNames (skins is all skin names from Language.php)
-               $validSkinNames = Skin::getUsableSkins();
+               # Only show skins that aren't disabled in $wgSkipSkins
+               $validSkinNames = Skin::getAllowedSkins();
 
                # 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).
@@ -1129,7 +1104,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getDateOptions( IContextSource $context ) {
@@ -1164,7 +1139,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getImageSizes( IContextSource $context ) {
@@ -1182,7 +1157,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getThumbSizes( IContextSource $context ) {
@@ -1200,9 +1175,9 @@ class Preferences {
        }
 
        /**
-        * @param $signature string
-        * @param $alldata array
-        * @param $form HTMLForm
+        * @param string $signature
+        * @param array $alldata
+        * @param HTMLForm $form
         * @return bool|string
         */
        static function validateSignature( $signature, $alldata, $form ) {
@@ -1225,9 +1200,9 @@ class Preferences {
        }
 
        /**
-        * @param $signature string
-        * @param $alldata array
-        * @param $form HTMLForm
+        * @param string $signature
+        * @param array $alldata
+        * @param HTMLForm $form
         * @return string
         */
        static function cleanSignature( $signature, $alldata, $form ) {
@@ -1243,10 +1218,10 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $formClass string
-        * @param array $remove array of items to remove
+        * @param User $user
+        * @param IContextSource $context
+        * @param string $formClass
+        * @param array $remove Array of items to remove
         * @return HtmlForm
         */
        static function getFormObject(
@@ -1285,7 +1260,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getTimezoneOptions( IContextSource $context ) {
@@ -1359,8 +1334,8 @@ class Preferences {
        }
 
        /**
-        * @param $value
-        * @param $alldata
+        * @param string $value
+        * @param array $alldata
         * @return int
         */
        static function filterIntval( $value, $alldata ) {
@@ -1368,8 +1343,8 @@ class Preferences {
        }
 
        /**
-        * @param $tz
-        * @param $alldata
+        * @param string $tz
+        * @param array $alldata
         * @return string
         */
        static function filterTimezoneInput( $tz, $alldata ) {
@@ -1402,12 +1377,11 @@ class Preferences {
        /**
         * Handle the form submission if everything validated properly
         *
-        * @param $formData
-        * @param $form PreferencesForm
-        * @param $entryPoint string
+        * @param array $formData
+        * @param PreferencesForm $form
         * @return bool|Status|string
         */
-       static function tryFormSubmit( $formData, $form, $entryPoint = 'internal' ) {
+       static function tryFormSubmit( $formData, $form ) {
                global $wgHiddenPrefs, $wgAuth;
 
                $user = $form->getModifiedUser();
@@ -1427,7 +1401,7 @@ class Preferences {
 
                // Fortunately, the realname field is MUCH simpler
                // (not really "private", but still shouldn't be edited without permission)
-               if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) ) {
+               if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) ) {
                        $realName = $formData['realname'];
                        $user->setRealName( $realName );
                }
@@ -1463,12 +1437,12 @@ class Preferences {
        }
 
        /**
-        * @param $formData
-        * @param $form PreferencesForm
+        * @param array $formData
+        * @param PreferencesForm $form
         * @return Status
         */
        public static function tryUISubmit( $formData, $form ) {
-               $res = self::tryFormSubmit( $formData, $form, 'ui' );
+               $res = self::tryFormSubmit( $formData, $form );
 
                if ( $res ) {
                        $urlOptions = array( 'success' => 1 );
@@ -1493,10 +1467,10 @@ class Preferences {
         * Caller is responsible for checking $wgAuth and 'editmyprivateinfo'
         * right.
         *
-        * @deprecated in 1.20; use User::setEmailWithConfirmation() instead.
-        * @param $user User
+        * @deprecated since 1.20; use User::setEmailWithConfirmation() instead.
+        * @param User $user
         * @param string $newaddr New email address
-        * @return Array (true on success or Status on failure, info string)
+        * @return array (true on success or Status on failure, info string)
         */
        public static function trySetUserEmail( User $user, $newaddr ) {
                wfDeprecated( __METHOD__, '1.20' );
@@ -1510,8 +1484,8 @@ class Preferences {
        }
 
        /**
-        * @deprecated in 1.19
-        * @param $user User
+        * @deprecated since 1.19
+        * @param User $user
         * @return array
         */
        public static function loadOldSearchNs( $user ) {
@@ -1539,7 +1513,7 @@ class PreferencesForm extends HTMLForm {
        private $modifiedUser;
 
        /**
-        * @param $user User
+        * @param User $user
         */
        public function setModifiedUser( $user ) {
                $this->modifiedUser = $user;
@@ -1567,8 +1541,8 @@ class PreferencesForm extends HTMLForm {
        }
 
        /**
-        * @param $html string
-        * @return String
+        * @param string $html
+        * @return string
         */
        function wrapForm( $html ) {
                $html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html );
@@ -1577,7 +1551,7 @@ class PreferencesForm extends HTMLForm {
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getButtons() {
                if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
@@ -1600,7 +1574,7 @@ class PreferencesForm extends HTMLForm {
        /**
         * Separate multi-option preferences into multiple preferences, since we
         * have to store them separately
-        * @param $data array
+        * @param array $data
         * @return array
         */
        function filterDataForSubmit( $data ) {
@@ -1629,7 +1603,7 @@ class PreferencesForm extends HTMLForm {
        /**
         * Get the "<legend>" for a given section key. Normally this is the
         * prefs-$key message but we'll allow extensions to override it.
-        * @param $key string
+        * @param string $key
         * @return string
         */
        function getLegend( $key ) {