3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 use MediaWiki\Auth\AuthManager
;
22 use MediaWiki\MediaWikiServices
;
23 use MediaWiki\Preferences\DefaultPreferencesFactory
;
26 * This class has been replaced by the PreferencesFactory service.
28 * @deprecated since 1.31 use the PreferencesFactory service instead.
33 * A shim to maintain backwards-compatibility of this class, basically replicating the
34 * default behaviour of the PreferencesFactory service but not permitting overriding.
35 * @return DefaultPreferencesFactory
37 protected static function getDefaultPreferencesFactory() {
38 $services = MediaWikiServices
::getInstance();
39 $authManager = AuthManager
::singleton();
40 $linkRenderer = $services->getLinkRenderer();
41 $config = $services->getMainConfig();
42 $preferencesFactory = new DefaultPreferencesFactory(
43 $config, $services->getContentLanguage(), $authManager,
46 return $preferencesFactory;
52 public static function getSaveBlacklist() {
53 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
59 * @param IContextSource $context
62 public static function getPreferences( $user, IContextSource
$context ) {
63 $preferencesFactory = self
::getDefaultPreferencesFactory();
64 return $preferencesFactory->getFormDescriptor( $user, $context );
68 * Loads existing values for a given array of preferences
71 * @param IContextSource $context
72 * @param array &$defaultPreferences Array to load values for
75 public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
76 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
80 * Pull option from a user account. Handles stuff like array-type preferences.
85 * @return array|string
87 public static function getOptionFromUser( $name, $info, $user ) {
88 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
93 * @param IContextSource $context
94 * @param array &$defaultPreferences
97 public static function profilePreferences(
98 $user, IContextSource
$context, &$defaultPreferences
100 wfDeprecated( __METHOD__
, '1.31' );
101 $defaultPreferences = self
::getPreferences( $user, $context );
106 * @param IContextSource $context
107 * @param array &$defaultPreferences
110 public static function skinPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
111 wfDeprecated( __METHOD__
, '1.31' );
112 $defaultPreferences = self
::getPreferences( $user, $context );
117 * @param IContextSource $context
118 * @param array &$defaultPreferences
120 public static function filesPreferences(
121 $user, IContextSource
$context, &$defaultPreferences
123 wfDeprecated( __METHOD__
, '1.31' );
124 $defaultPreferences = self
::getPreferences( $user, $context );
129 * @param IContextSource $context
130 * @param array &$defaultPreferences
133 public static function datetimePreferences(
134 $user, IContextSource
$context, &$defaultPreferences
136 wfDeprecated( __METHOD__
, '1.31' );
137 $defaultPreferences = self
::getPreferences( $user, $context );
142 * @param IContextSource $context
143 * @param array &$defaultPreferences
145 public static function renderingPreferences(
146 $user, IContextSource
$context, &$defaultPreferences
148 wfDeprecated( __METHOD__
, '1.31' );
149 $defaultPreferences = self
::getPreferences( $user, $context );
154 * @param IContextSource $context
155 * @param array &$defaultPreferences
157 public static function editingPreferences(
158 $user, IContextSource
$context, &$defaultPreferences
160 wfDeprecated( __METHOD__
, '1.31' );
161 $defaultPreferences = self
::getPreferences( $user, $context );
166 * @param IContextSource $context
167 * @param array &$defaultPreferences
169 public static function rcPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
170 wfDeprecated( __METHOD__
, '1.31' );
171 $defaultPreferences = self
::getPreferences( $user, $context );
176 * @param IContextSource $context
177 * @param array &$defaultPreferences
179 public static function watchlistPreferences(
180 $user, IContextSource
$context, &$defaultPreferences
182 wfDeprecated( __METHOD__
, '1.31' );
183 $defaultPreferences = self
::getPreferences( $user, $context );
188 * @param IContextSource $context
189 * @param array &$defaultPreferences
191 public static function searchPreferences(
192 $user, IContextSource
$context, &$defaultPreferences
194 wfDeprecated( __METHOD__
, '1.31' );
195 $defaultPreferences = self
::getPreferences( $user, $context );
199 * Dummy, kept for backwards-compatibility.
201 * @param IContextSource $context
202 * @param array &$defaultPreferences
204 public static function miscPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
209 * @param IContextSource $context
210 * @return array Text/links to display as key; $skinkey as value
212 public static function generateSkinOptions( $user, IContextSource
$context ) {
213 wfDeprecated( __METHOD__
, '1.31' );
214 return self
::getPreferences( $user, $context );
218 * @param IContextSource $context
221 static function getDateOptions( IContextSource
$context ) {
222 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
226 * @param IContextSource $context
229 public static function getImageSizes( IContextSource
$context ) {
230 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
234 * @param IContextSource $context
237 public static function getThumbSizes( IContextSource
$context ) {
238 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
242 * @param string $signature
243 * @param array $alldata
244 * @param HTMLForm $form
245 * @return bool|string
247 public static function validateSignature( $signature, $alldata, $form ) {
248 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
252 * @param string $signature
253 * @param array $alldata
254 * @param HTMLForm $form
257 public static function cleanSignature( $signature, $alldata, $form ) {
258 throw new Exception( __METHOD__
. '() is deprecated and does nothing now' );
263 * @param IContextSource $context
264 * @param string $formClass
265 * @param array $remove Array of items to remove
266 * @return PreferencesFormLegacy|HTMLForm
268 public static function getFormObject(
270 IContextSource
$context,
271 $formClass = PreferencesFormLegacy
::class,
274 $preferencesFactory = self
::getDefaultPreferencesFactory();
275 return $preferencesFactory->getForm( $user, $context, $formClass, $remove );
279 * @param IContextSource $context
282 public static function getTimezoneOptions( IContextSource
$context ) {
283 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
287 * @param string $value
288 * @param array $alldata
291 public static function filterIntval( $value, $alldata ) {
292 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
297 * @param array $alldata
300 public static function filterTimezoneInput( $tz, $alldata ) {
301 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
305 * Get a list of all time zones
306 * @param Language $language Language used for the localized names
307 * @return array A list of all time zones. The system name of the time zone is used as key and
308 * the value is an array which contains localized name, the timecorrection value used for
309 * preferences and the region
312 public static function getTimeZoneList( Language
$language ) {
313 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );