MediaWiki  REL1_31
Preferences.php
Go to the documentation of this file.
1 <?php
24 
30 class Preferences {
31 
37  protected static function getDefaultPreferencesFactory() {
39  $authManager = AuthManager::singleton();
40  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
41  $config = MediaWikiServices::getInstance()->getMainConfig();
42  $preferencesFactory = new DefaultPreferencesFactory(
43  $config, $wgContLang, $authManager, $linkRenderer
44  );
45  return $preferencesFactory;
46  }
47 
51  public static function getSaveBlacklist() {
52  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
53  }
54 
61  public static function getPreferences( $user, IContextSource $context ) {
62  $preferencesFactory = self::getDefaultPreferencesFactory();
63  return $preferencesFactory->getFormDescriptor( $user, $context );
64  }
65 
74  public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
75  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
76  }
77 
86  public static function getOptionFromUser( $name, $info, $user ) {
87  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
88  }
89 
96  public static function profilePreferences(
97  $user, IContextSource $context, &$defaultPreferences
98  ) {
99  wfDeprecated( __METHOD__, '1.31' );
100  $defaultPreferences = self::getPreferences( $user, $context );
101  }
102 
109  public static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
110  wfDeprecated( __METHOD__, '1.31' );
111  $defaultPreferences = self::getPreferences( $user, $context );
112  }
113 
119  public static function filesPreferences(
120  $user, IContextSource $context, &$defaultPreferences
121  ) {
122  wfDeprecated( __METHOD__, '1.31' );
123  $defaultPreferences = self::getPreferences( $user, $context );
124  }
125 
132  public static function datetimePreferences(
133  $user, IContextSource $context, &$defaultPreferences
134  ) {
135  wfDeprecated( __METHOD__, '1.31' );
136  $defaultPreferences = self::getPreferences( $user, $context );
137  }
138 
144  public static function renderingPreferences(
145  $user, IContextSource $context, &$defaultPreferences
146  ) {
147  wfDeprecated( __METHOD__, '1.31' );
148  $defaultPreferences = self::getPreferences( $user, $context );
149  }
150 
156  public static function editingPreferences(
157  $user, IContextSource $context, &$defaultPreferences
158  ) {
159  wfDeprecated( __METHOD__, '1.31' );
160  $defaultPreferences = self::getPreferences( $user, $context );
161  }
162 
168  public static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
169  wfDeprecated( __METHOD__, '1.31' );
170  $defaultPreferences = self::getPreferences( $user, $context );
171  }
172 
178  public static function watchlistPreferences(
179  $user, IContextSource $context, &$defaultPreferences
180  ) {
181  wfDeprecated( __METHOD__, '1.31' );
182  $defaultPreferences = self::getPreferences( $user, $context );
183  }
184 
190  public static function searchPreferences(
191  $user, IContextSource $context, &$defaultPreferences
192  ) {
193  wfDeprecated( __METHOD__, '1.31' );
194  $defaultPreferences = self::getPreferences( $user, $context );
195  }
196 
203  public static function miscPreferences( $user, IContextSource $context, &$defaultPreferences ) {
204  }
205 
211  public static function generateSkinOptions( $user, IContextSource $context ) {
212  wfDeprecated( __METHOD__, '1.31' );
214  }
215 
221  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
222  }
223 
228  public static function getImageSizes( IContextSource $context ) {
229  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
230  }
231 
236  public static function getThumbSizes( IContextSource $context ) {
237  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
238  }
239 
246  public static function validateSignature( $signature, $alldata, $form ) {
247  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
248  }
249 
256  public static function cleanSignature( $signature, $alldata, $form ) {
257  throw new Exception( __METHOD__ . '() is deprecated and does nothing now' );
258  }
259 
267  public static function getFormObject(
268  $user,
270  $formClass = PreferencesForm::class,
271  array $remove = []
272  ) {
273  $preferencesFactory = self::getDefaultPreferencesFactory();
274  return $preferencesFactory->getForm( $user, $context, $formClass, $remove );
275  }
276 
281  public static function getTimezoneOptions( IContextSource $context ) {
282  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
283  }
284 
290  public static function filterIntval( $value, $alldata ) {
291  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
292  }
293 
299  public static function filterTimezoneInput( $tz, $alldata ) {
300  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
301  }
302 
312  public static function tryFormSubmit( $formData, $form ) {
313  $preferencesFactory = self::getDefaultPreferencesFactory();
314  return $preferencesFactory->legacySaveFormData( $formData, $form );
315  }
316 
322  public static function tryUISubmit( $formData, $form ) {
323  $preferencesFactory = self::getDefaultPreferencesFactory();
324  return $preferencesFactory->legacySubmitForm( $formData, $form );
325  }
326 
335  public static function getTimeZoneList( Language $language ) {
336  throw new Exception( __METHOD__ . '() is deprecated and does nothing' );
337  }
338 }
$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:247
Preferences\getPreferences
static getPreferences( $user, IContextSource $context)
Definition: Preferences.php:61
Preferences\getThumbSizes
static getThumbSizes(IContextSource $context)
Definition: Preferences.php:236
Preferences\filterTimezoneInput
static filterTimezoneInput( $tz, $alldata)
Definition: Preferences.php:299
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
Preferences\rcPreferences
static rcPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:168
Preferences\editingPreferences
static editingPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:156
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Preferences\getTimeZoneList
static getTimeZoneList(Language $language)
Get a list of all time zones.
Definition: Preferences.php:335
Preferences\searchPreferences
static searchPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:190
Preferences\filterIntval
static filterIntval( $value, $alldata)
Definition: Preferences.php:290
Preferences\getDateOptions
static getDateOptions(IContextSource $context)
Definition: Preferences.php:220
$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:2056
Preferences\tryUISubmit
static tryUISubmit( $formData, $form)
Definition: Preferences.php:322
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:37
Preferences\getSaveBlacklist
static getSaveBlacklist()
Definition: Preferences.php:51
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:1123
Preferences\generateSkinOptions
static generateSkinOptions( $user, IContextSource $context)
Definition: Preferences.php:211
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
Preferences\validateSignature
static validateSignature( $signature, $alldata, $form)
Definition: Preferences.php:246
Preferences\miscPreferences
static miscPreferences( $user, IContextSource $context, &$defaultPreferences)
Dummy, kept for backwards-compatibility.
Definition: Preferences.php:203
Preferences\watchlistPreferences
static watchlistPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:178
Preferences\tryFormSubmit
static tryFormSubmit( $formData, $form)
Handle the form submission if everything validated properly.
Definition: Preferences.php:312
Preferences\skinPreferences
static skinPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:109
$value
$value
Definition: styleTest.css.php:45
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
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
Preferences\profilePreferences
static profilePreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:96
Preferences\getTimezoneOptions
static getTimezoneOptions(IContextSource $context)
Definition: Preferences.php:281
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:56
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:25
Preferences\getImageSizes
static getImageSizes(IContextSource $context)
Definition: Preferences.php:228
Preferences\filesPreferences
static filesPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:119
Preferences\getOptionFromUser
static getOptionFromUser( $name, $info, $user)
Pull option from a user account.
Definition: Preferences.php:86
Preferences\loadPreferenceValues
static loadPreferenceValues( $user, $context, &$defaultPreferences)
Loads existing values for a given array of preferences.
Definition: Preferences.php:74
Preferences\renderingPreferences
static renderingPreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:144
$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:2811
Language
Internationalisation code.
Definition: Language.php:35
Preferences\getFormObject
static getFormObject( $user, IContextSource $context, $formClass=PreferencesForm::class, array $remove=[])
Definition: Preferences.php:267
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:57
Preferences\cleanSignature
static cleanSignature( $signature, $alldata, $form)
Definition: Preferences.php:256
Preferences\datetimePreferences
static datetimePreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:132