123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <?php
- /**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
- use MediaWiki\Auth\AuthManager;
- use MediaWiki\MediaWikiServices;
- use MediaWiki\Preferences\DefaultPreferencesFactory;
- /**
- * This class has been replaced by the PreferencesFactory service.
- *
- * @deprecated since 1.31 use the PreferencesFactory service instead.
- */
- class Preferences {
- /**
- * A shim to maintain backwards-compatibility of this class, basically replicating the
- * default behaviour of the PreferencesFactory service but not permitting overriding.
- * @return DefaultPreferencesFactory
- */
- protected static function getDefaultPreferencesFactory() {
- global $wgContLang;
- $authManager = AuthManager::singleton();
- $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
- $config = MediaWikiServices::getInstance()->getMainConfig();
- $preferencesFactory = new DefaultPreferencesFactory(
- $config, $wgContLang, $authManager, $linkRenderer
- );
- return $preferencesFactory;
- }
- /**
- * @return array
- */
- public static function getSaveBlacklist() {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @throws MWException
- * @param User $user
- * @param IContextSource $context
- * @return array|null
- */
- public static function getPreferences( $user, IContextSource $context ) {
- $preferencesFactory = self::getDefaultPreferencesFactory();
- return $preferencesFactory->getFormDescriptor( $user, $context );
- }
- /**
- * Loads existing values for a given array of preferences
- * @throws MWException
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences Array to load values for
- * @return array|null
- */
- public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * Pull option from a user account. Handles stuff like array-type preferences.
- *
- * @param string $name
- * @param array $info
- * @param User $user
- * @return array|string
- */
- public static function getOptionFromUser( $name, $info, $user ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- * @return void
- */
- public static function profilePreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- * @return void
- */
- public static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function filesPreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- * @return void
- */
- public static function datetimePreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function renderingPreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function editingPreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function watchlistPreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function searchPreferences(
- $user, IContextSource $context, &$defaultPreferences
- ) {
- wfDeprecated( __METHOD__, '1.31' );
- $defaultPreferences = self::getPreferences( $user, $context );
- }
- /**
- * Dummy, kept for backwards-compatibility.
- * @param User $user
- * @param IContextSource $context
- * @param array &$defaultPreferences
- */
- public static function miscPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @return array Text/links to display as key; $skinkey as value
- */
- public static function generateSkinOptions( $user, IContextSource $context ) {
- wfDeprecated( __METHOD__, '1.31' );
- return self::getPreferences( $user, $context );
- }
- /**
- * @param IContextSource $context
- * @return array
- */
- static function getDateOptions( IContextSource $context ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param IContextSource $context
- * @return array
- */
- public static function getImageSizes( IContextSource $context ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param IContextSource $context
- * @return array
- */
- public static function getThumbSizes( IContextSource $context ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param string $signature
- * @param array $alldata
- * @param HTMLForm $form
- * @return bool|string
- */
- public static function validateSignature( $signature, $alldata, $form ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param string $signature
- * @param array $alldata
- * @param HTMLForm $form
- * @return string
- */
- public static function cleanSignature( $signature, $alldata, $form ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing now' );
- }
- /**
- * @param User $user
- * @param IContextSource $context
- * @param string $formClass
- * @param array $remove Array of items to remove
- * @return PreferencesForm|HTMLForm
- */
- public static function getFormObject(
- $user,
- IContextSource $context,
- $formClass = PreferencesForm::class,
- array $remove = []
- ) {
- $preferencesFactory = self::getDefaultPreferencesFactory();
- return $preferencesFactory->getForm( $user, $context, $formClass, $remove );
- }
- /**
- * @param IContextSource $context
- * @return array
- */
- public static function getTimezoneOptions( IContextSource $context ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param string $value
- * @param array $alldata
- * @return int
- */
- public static function filterIntval( $value, $alldata ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * @param string $tz
- * @param array $alldata
- * @return string
- */
- public static function filterTimezoneInput( $tz, $alldata ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- /**
- * Handle the form submission if everything validated properly
- *
- * @deprecated since 1.31, use PreferencesFactory
- *
- * @param array $formData
- * @param PreferencesForm $form
- * @return bool|Status|string
- */
- public static function tryFormSubmit( $formData, $form ) {
- $preferencesFactory = self::getDefaultPreferencesFactory();
- return $preferencesFactory->legacySaveFormData( $formData, $form );
- }
- /**
- * @param array $formData
- * @param PreferencesForm $form
- * @return Status
- */
- public static function tryUISubmit( $formData, $form ) {
- $preferencesFactory = self::getDefaultPreferencesFactory();
- return $preferencesFactory->legacySubmitForm( $formData, $form );
- }
- /**
- * Get a list of all time zones
- * @param Language $language Language used for the localized names
- * @return array A list of all time zones. The system name of the time zone is used as key and
- * the value is an array which contains localized name, the timecorrection value used for
- * preferences and the region
- * @since 1.26
- */
- public static function getTimeZoneList( Language $language ) {
- throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
- }
- }
|