MediaWiki  1.32.5
Preferences.php
Go to the documentation of this file.
1 <?php
24 
30 class Preferences {
31 
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,
45  );
46  return $preferencesFactory;
47  }
48 
52  public static function getSaveBlacklist() {
53  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
54  }
55 
62  public static function getPreferences( $user, IContextSource $context ) {
63  $preferencesFactory = self::getDefaultPreferencesFactory();
64  return $preferencesFactory->getFormDescriptor( $user, $context );
65  }
66 
75  public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
76  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
77  }
78 
87  public static function getOptionFromUser( $name, $info, $user ) {
88  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
89  }
90 
97  public static function profilePreferences(
98  $user, IContextSource $context, &$defaultPreferences
99  ) {
100  wfDeprecated( __METHOD__, '1.31' );
101  $defaultPreferences = self::getPreferences( $user, $context );
102  }
103 
110  public static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
111  wfDeprecated( __METHOD__, '1.31' );
112  $defaultPreferences = self::getPreferences( $user, $context );
113  }
114 
120  public static function filesPreferences(
121  $user, IContextSource $context, &$defaultPreferences
122  ) {
123  wfDeprecated( __METHOD__, '1.31' );
124  $defaultPreferences = self::getPreferences( $user, $context );
125  }
126 
133  public static function datetimePreferences(
134  $user, IContextSource $context, &$defaultPreferences
135  ) {
136  wfDeprecated( __METHOD__, '1.31' );
137  $defaultPreferences = self::getPreferences( $user, $context );
138  }
139 
145  public static function renderingPreferences(
146  $user, IContextSource $context, &$defaultPreferences
147  ) {
148  wfDeprecated( __METHOD__, '1.31' );
149  $defaultPreferences = self::getPreferences( $user, $context );
150  }
151 
157  public static function editingPreferences(
158  $user, IContextSource $context, &$defaultPreferences
159  ) {
160  wfDeprecated( __METHOD__, '1.31' );
161  $defaultPreferences = self::getPreferences( $user, $context );
162  }
163 
169  public static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
170  wfDeprecated( __METHOD__, '1.31' );
171  $defaultPreferences = self::getPreferences( $user, $context );
172  }
173 
179  public static function watchlistPreferences(
180  $user, IContextSource $context, &$defaultPreferences
181  ) {
182  wfDeprecated( __METHOD__, '1.31' );
183  $defaultPreferences = self::getPreferences( $user, $context );
184  }
185 
191  public static function searchPreferences(
192  $user, IContextSource $context, &$defaultPreferences
193  ) {
194  wfDeprecated( __METHOD__, '1.31' );
195  $defaultPreferences = self::getPreferences( $user, $context );
196  }
197 
204  public static function miscPreferences( $user, IContextSource $context, &$defaultPreferences ) {
205  wfDeprecated( __METHOD__, '1.31' );
206  }
207 
213  public static function generateSkinOptions( $user, IContextSource $context ) {
214  wfDeprecated( __METHOD__, '1.31' );
216  }
217 
223  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
224  }
225 
230  public static function getImageSizes( IContextSource $context ) {
231  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
232  }
233 
238  public static function getThumbSizes( IContextSource $context ) {
239  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
240  }
241 
248  public static function validateSignature( $signature, $alldata, $form ) {
249  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
250  }
251 
258  public static function cleanSignature( $signature, $alldata, $form ) {
259  throw new Exception( __METHOD__ . '() is deprecated and does nothing now' );
260  }
261 
269  public static function getFormObject(
270  $user,
272  $formClass = PreferencesFormLegacy::class,
273  array $remove = []
274  ) {
275  $preferencesFactory = self::getDefaultPreferencesFactory();
276  return $preferencesFactory->getForm( $user, $context, $formClass, $remove );
277  }
278 
283  public static function getTimezoneOptions( IContextSource $context ) {
284  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
285  }
286 
292  public static function filterIntval( $value, $alldata ) {
293  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
294  }
295 
301  public static function filterTimezoneInput( $tz, $alldata ) {
302  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
303  }
304 
313  public static function getTimeZoneList( Language $language ) {
314  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
315  }
316 }
Preferences\getPreferences
static getPreferences( $user, IContextSource $context)
Definition: Preferences.php:62
Preferences\getThumbSizes
static getThumbSizes(IContextSource $context)
Definition: Preferences.php:238
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
Preferences\filterTimezoneInput
static filterTimezoneInput( $tz, $alldata)
Definition: Preferences.php:301
Preferences\rcPreferences
static rcPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:169
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2683
Preferences\editingPreferences
static editingPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:157
Preferences\getTimeZoneList
static getTimeZoneList(Language $language)
Get a list of all time zones.
Definition: Preferences.php:313
Preferences\searchPreferences
static searchPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:191
$linkRenderer
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition: hooks.txt:2044
Preferences\filterIntval
static filterIntval( $value, $alldata)
Definition: Preferences.php:292
Preferences\getDateOptions
static getDateOptions(IContextSource $context)
Definition: Preferences.php:222
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Preferences\getSaveBlacklist
static getSaveBlacklist()
Definition: Preferences.php:52
Preferences
This class has been replaced by the PreferencesFactory service.
Definition: Preferences.php:30
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1118
Preferences\generateSkinOptions
static generateSkinOptions( $user, IContextSource $context)
Definition: Preferences.php:213
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
Preferences\validateSignature
static validateSignature( $signature, $alldata, $form)
Definition: Preferences.php:248
Preferences\miscPreferences
static miscPreferences( $user, IContextSource $context, &$defaultPreferences)
Dummy, kept for backwards-compatibility.
Definition: Preferences.php:204
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
Preferences\watchlistPreferences
static watchlistPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:179
Preferences\skinPreferences
static skinPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:110
$value
$value
Definition: styleTest.css.php:49
Preferences\getFormObject
static getFormObject( $user, IContextSource $context, $formClass=PreferencesFormLegacy::class, array $remove=[])
Definition: Preferences.php:269
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:83
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
Preferences\profilePreferences
static profilePreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:97
Preferences\getTimezoneOptions
static getTimezoneOptions(IContextSource $context)
Definition: Preferences.php:283
Preferences\getDefaultPreferencesFactory
static getDefaultPreferencesFactory()
A shim to maintain backwards-compatibility of this class, basically replicating the default behaviour...
Definition: Preferences.php:37
MediaWiki\Preferences\DefaultPreferencesFactory
This is the default implementation of PreferencesFactory.
Definition: DefaultPreferencesFactory.php:61
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
$services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2278
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
Preferences\getImageSizes
static getImageSizes(IContextSource $context)
Definition: Preferences.php:230
Preferences\filesPreferences
static filesPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:120
Preferences\getOptionFromUser
static getOptionFromUser( $name, $info, $user)
Pull option from a user account.
Definition: Preferences.php:87
Preferences\loadPreferenceValues
static loadPreferenceValues( $user, $context, &$defaultPreferences)
Loads existing values for a given array of preferences.
Definition: Preferences.php:75
Preferences\renderingPreferences
static renderingPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:145
Language
Internationalisation code.
Definition: Language.php:35
Preferences\cleanSignature
static cleanSignature( $signature, $alldata, $form)
Definition: Preferences.php:258
Preferences\datetimePreferences
static datetimePreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:133