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 * @param IContextSource $context
55 public static function getPreferences( $user, IContextSource
$context ) {
56 wfDeprecated( __METHOD__
, '1.31' );
57 $preferencesFactory = self
::getDefaultPreferencesFactory();
58 return $preferencesFactory->getFormDescriptor( $user, $context );
62 * Loads existing values for a given array of preferences
65 * @param IContextSource $context
66 * @param array &$defaultPreferences Array to load values for
69 public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
70 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
74 * Pull option from a user account. Handles stuff like array-type preferences.
79 * @return array|string
81 public static function getOptionFromUser( $name, $info, $user ) {
82 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
87 * @param IContextSource $context
88 * @param array &$defaultPreferences
91 public static function profilePreferences(
92 $user, IContextSource
$context, &$defaultPreferences
94 wfDeprecated( __METHOD__
, '1.31' );
95 $defaultPreferences = self
::getPreferences( $user, $context );
100 * @param IContextSource $context
101 * @param array &$defaultPreferences
104 public static function skinPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
105 wfDeprecated( __METHOD__
, '1.31' );
106 $defaultPreferences = self
::getPreferences( $user, $context );
111 * @param IContextSource $context
112 * @param array &$defaultPreferences
114 public static function filesPreferences(
115 $user, IContextSource
$context, &$defaultPreferences
117 wfDeprecated( __METHOD__
, '1.31' );
118 $defaultPreferences = self
::getPreferences( $user, $context );
123 * @param IContextSource $context
124 * @param array &$defaultPreferences
127 public static function datetimePreferences(
128 $user, IContextSource
$context, &$defaultPreferences
130 wfDeprecated( __METHOD__
, '1.31' );
131 $defaultPreferences = self
::getPreferences( $user, $context );
136 * @param IContextSource $context
137 * @param array &$defaultPreferences
139 public static function renderingPreferences(
140 $user, IContextSource
$context, &$defaultPreferences
142 wfDeprecated( __METHOD__
, '1.31' );
143 $defaultPreferences = self
::getPreferences( $user, $context );
148 * @param IContextSource $context
149 * @param array &$defaultPreferences
151 public static function editingPreferences(
152 $user, IContextSource
$context, &$defaultPreferences
154 wfDeprecated( __METHOD__
, '1.31' );
155 $defaultPreferences = self
::getPreferences( $user, $context );
160 * @param IContextSource $context
161 * @param array &$defaultPreferences
163 public static function rcPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
164 wfDeprecated( __METHOD__
, '1.31' );
165 $defaultPreferences = self
::getPreferences( $user, $context );
170 * @param IContextSource $context
171 * @param array &$defaultPreferences
173 public static function watchlistPreferences(
174 $user, IContextSource
$context, &$defaultPreferences
176 wfDeprecated( __METHOD__
, '1.31' );
177 $defaultPreferences = self
::getPreferences( $user, $context );
182 * @param IContextSource $context
183 * @param array &$defaultPreferences
185 public static function searchPreferences(
186 $user, IContextSource
$context, &$defaultPreferences
188 wfDeprecated( __METHOD__
, '1.31' );
189 $defaultPreferences = self
::getPreferences( $user, $context );
193 * Dummy, kept for backwards-compatibility.
195 * @param IContextSource $context
196 * @param array &$defaultPreferences
198 public static function miscPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
199 wfDeprecated( __METHOD__
, '1.31' );
204 * @param IContextSource $context
205 * @return array Text/links to display as key; $skinkey as value
207 public static function generateSkinOptions( $user, IContextSource
$context ) {
208 wfDeprecated( __METHOD__
, '1.31' );
209 return self
::getPreferences( $user, $context );
213 * @param IContextSource $context
216 static function getDateOptions( IContextSource
$context ) {
217 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
221 * @param IContextSource $context
224 public static function getImageSizes( IContextSource
$context ) {
225 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
229 * @param IContextSource $context
232 public static function getThumbSizes( IContextSource
$context ) {
233 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
237 * @param string $signature
238 * @param array $alldata
239 * @param HTMLForm $form
240 * @return bool|string
242 public static function validateSignature( $signature, $alldata, $form ) {
243 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
247 * @param string $signature
248 * @param array $alldata
249 * @param HTMLForm $form
252 public static function cleanSignature( $signature, $alldata, $form ) {
253 throw new Exception( __METHOD__
. '() is deprecated and does nothing now' );
258 * @param IContextSource $context
259 * @param string $formClass
260 * @param array $remove Array of items to remove
261 * @return PreferencesFormLegacy|HTMLForm
263 public static function getFormObject(
265 IContextSource
$context,
266 $formClass = PreferencesFormLegacy
::class,
269 wfDeprecated( __METHOD__
, '1.31' );
270 $preferencesFactory = self
::getDefaultPreferencesFactory();
271 return $preferencesFactory->getForm( $user, $context, $formClass, $remove );