MediaWiki  1.33.0
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 
55  public static function getPreferences( $user, IContextSource $context ) {
56  wfDeprecated( __METHOD__, '1.31' );
57  $preferencesFactory = self::getDefaultPreferencesFactory();
58  return $preferencesFactory->getFormDescriptor( $user, $context );
59  }
60 
69  public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
70  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
71  }
72 
81  public static function getOptionFromUser( $name, $info, $user ) {
82  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
83  }
84 
91  public static function profilePreferences(
92  $user, IContextSource $context, &$defaultPreferences
93  ) {
94  wfDeprecated( __METHOD__, '1.31' );
95  $defaultPreferences = self::getPreferences( $user, $context );
96  }
97 
104  public static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
105  wfDeprecated( __METHOD__, '1.31' );
106  $defaultPreferences = self::getPreferences( $user, $context );
107  }
108 
114  public static function filesPreferences(
115  $user, IContextSource $context, &$defaultPreferences
116  ) {
117  wfDeprecated( __METHOD__, '1.31' );
118  $defaultPreferences = self::getPreferences( $user, $context );
119  }
120 
127  public static function datetimePreferences(
128  $user, IContextSource $context, &$defaultPreferences
129  ) {
130  wfDeprecated( __METHOD__, '1.31' );
131  $defaultPreferences = self::getPreferences( $user, $context );
132  }
133 
139  public static function renderingPreferences(
140  $user, IContextSource $context, &$defaultPreferences
141  ) {
142  wfDeprecated( __METHOD__, '1.31' );
143  $defaultPreferences = self::getPreferences( $user, $context );
144  }
145 
151  public static function editingPreferences(
152  $user, IContextSource $context, &$defaultPreferences
153  ) {
154  wfDeprecated( __METHOD__, '1.31' );
155  $defaultPreferences = self::getPreferences( $user, $context );
156  }
157 
163  public static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
164  wfDeprecated( __METHOD__, '1.31' );
165  $defaultPreferences = self::getPreferences( $user, $context );
166  }
167 
173  public static function watchlistPreferences(
174  $user, IContextSource $context, &$defaultPreferences
175  ) {
176  wfDeprecated( __METHOD__, '1.31' );
177  $defaultPreferences = self::getPreferences( $user, $context );
178  }
179 
185  public static function searchPreferences(
186  $user, IContextSource $context, &$defaultPreferences
187  ) {
188  wfDeprecated( __METHOD__, '1.31' );
189  $defaultPreferences = self::getPreferences( $user, $context );
190  }
191 
198  public static function miscPreferences( $user, IContextSource $context, &$defaultPreferences ) {
199  wfDeprecated( __METHOD__, '1.31' );
200  }
201 
207  public static function generateSkinOptions( $user, IContextSource $context ) {
208  wfDeprecated( __METHOD__, '1.31' );
210  }
211 
217  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
218  }
219 
224  public static function getImageSizes( IContextSource $context ) {
225  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
226  }
227 
232  public static function getThumbSizes( IContextSource $context ) {
233  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
234  }
235 
242  public static function validateSignature( $signature, $alldata, $form ) {
243  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
244  }
245 
252  public static function cleanSignature( $signature, $alldata, $form ) {
253  throw new Exception( __METHOD__ . '() is deprecated and does nothing now' );
254  }
255 
263  public static function getFormObject(
264  $user,
266  $formClass = PreferencesFormLegacy::class,
267  array $remove = []
268  ) {
269  wfDeprecated( __METHOD__, '1.31' );
270  $preferencesFactory = self::getDefaultPreferencesFactory();
271  return $preferencesFactory->getForm( $user, $context, $formClass, $remove );
272  }
273 }
Preferences\getPreferences
static getPreferences( $user, IContextSource $context)
Definition: Preferences.php:55
Preferences\getThumbSizes
static getThumbSizes(IContextSource $context)
Definition: Preferences.php:232
$user
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1476
Preferences\rcPreferences
static rcPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:163
$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:2636
Preferences\editingPreferences
static editingPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:151
Preferences\searchPreferences
static searchPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:185
$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:1985
Preferences\getDateOptions
static getDateOptions(IContextSource $context)
Definition: Preferences.php:216
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
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:1078
Preferences\generateSkinOptions
static generateSkinOptions( $user, IContextSource $context)
Definition: Preferences.php:207
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:242
Preferences\miscPreferences
static miscPreferences( $user, IContextSource $context, &$defaultPreferences)
Dummy, kept for backwards-compatibility.
Definition: Preferences.php:198
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
Preferences\watchlistPreferences
static watchlistPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:173
Preferences\skinPreferences
static skinPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:104
Preferences\getFormObject
static getFormObject( $user, IContextSource $context, $formClass=PreferencesFormLegacy::class, array $remove=[])
Definition: Preferences.php:263
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:84
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:91
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:2220
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:224
Preferences\filesPreferences
static filesPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:114
Preferences\getOptionFromUser
static getOptionFromUser( $name, $info, $user)
Pull option from a user account.
Definition: Preferences.php:81
Preferences\loadPreferenceValues
static loadPreferenceValues( $user, $context, &$defaultPreferences)
Loads existing values for a given array of preferences.
Definition: Preferences.php:69
Preferences\renderingPreferences
static renderingPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:139
Preferences\cleanSignature
static cleanSignature( $signature, $alldata, $form)
Definition: Preferences.php:252
Preferences\datetimePreferences
static datetimePreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:127