MediaWiki master
MediaWiki\Preferences\DefaultPreferencesFactory Class Reference

This is the default implementation of PreferencesFactory. More...

Inherits MediaWiki\Preferences\PreferencesFactory.

Collaboration diagram for MediaWiki\Preferences\DefaultPreferencesFactory:

Public Member Functions

 __construct (ServiceOptions $options, Language $contLang, AuthManager $authManager, LinkRenderer $linkRenderer, NamespaceInfo $nsInfo, PermissionManager $permissionManager, ILanguageConverter $languageConverter, LanguageNameUtils $languageNameUtils, HookContainer $hookContainer, UserOptionsLookup $userOptionsLookup, LanguageConverterFactory $languageConverterFactory=null, ParserFactory $parserFactory=null, SkinFactory $skinFactory=null, UserGroupManager $userGroupManager=null, SignatureValidatorFactory $signatureValidatorFactory=null)
 
 getForm (User $user, IContextSource $context, $formClass=PreferencesFormOOUI::class, array $remove=[])
 
 getFormDescriptor (User $user, IContextSource $context)
 
 getOptionNamesForReset (User $user, IContextSource $context, $kinds)
 Get the list of option names which have been saved by the user, thus having non-default values, which match the specified set of kinds.
 
 getResetKinds (User $user, IContextSource $context, $options=null)
 Return an associative array mapping preferences keys to the kind of a preference they're used for.
 
 getSaveBlacklist ()
 Get the names of preferences that should never be saved (such as 'realname' and 'emailaddress').
Returns
string[]

 
 listResetKinds ()
 Return a list of the types of user options currently returned by getResetKinds().
 

Static Public Member Functions

static getPreferenceForField ( $name, HTMLFormField $field, array $userOptions)
 Get preference values for the 'default' param of html form descriptor, compatible with nested fields.
 
static simplifyFormDescriptor (array $descriptor)
 Simplify form descriptor for validation or something similar.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Protected Member Functions

 applyFilters (array &$preferences, array $formDescriptor, $verb)
 Applies filters to preferences either before or after form usage.
 
 cleanSignature ( $signature, $alldata, HTMLForm $form)
 
 datetimePreferences (User $user, IContextSource $context, &$defaultPreferences)
 
 editingPreferences (User $user, MessageLocalizer $l10n, &$defaultPreferences)
 
 filesPreferences (IContextSource $context, &$defaultPreferences)
 
 generateSkinOptions (User $user, IContextSource $context, array $validSkinNames)
 
 getDateOptions (IContextSource $context)
 
 getImageSizes (MessageLocalizer $l10n)
 
 getOptionFromUser ( $name, $info, array $userOptions)
 Pull option from a user account.
 
 getThumbSizes (MessageLocalizer $l10n)
 
 profilePreferences (User $user, IContextSource $context, &$defaultPreferences)
 
 rcPreferences (User $user, MessageLocalizer $l10n, &$defaultPreferences)
 
 renderingPreferences (User $user, MessageLocalizer $l10n, &$defaultPreferences)
 
 saveFormData ( $formData, PreferencesFormOOUI $form, array $formDescriptor)
 Handle the form submission if everything validated properly.
 
 searchPreferences ( $context, &$defaultPreferences)
 
 skinPreferences (User $user, IContextSource $context, &$defaultPreferences)
 
 submitForm (array $formData, PreferencesFormOOUI $form, array $formDescriptor)
 Save the form data and reload the page.
 
 validateSignature ( $signature, $alldata, HTMLForm $form)
 
 watchlistPreferences (User $user, IContextSource $context, &$defaultPreferences)
 

Protected Attributes

AuthManager $authManager
 
Language $contLang
 The wiki's content language.
 
LanguageNameUtils $languageNameUtils
 
LinkRenderer $linkRenderer
 
NamespaceInfo $nsInfo
 
ServiceOptions $options
 
PermissionManager $permissionManager
 
UserOptionsManager $userOptionsManager
 

Detailed Description

This is the default implementation of PreferencesFactory.

Definition at line 78 of file DefaultPreferencesFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Preferences\DefaultPreferencesFactory::__construct ( ServiceOptions $options,
Language $contLang,
AuthManager $authManager,
LinkRenderer $linkRenderer,
NamespaceInfo $nsInfo,
PermissionManager $permissionManager,
ILanguageConverter $languageConverter,
LanguageNameUtils $languageNameUtils,
HookContainer $hookContainer,
UserOptionsLookup $userOptionsLookup,
LanguageConverterFactory $languageConverterFactory = null,
ParserFactory $parserFactory = null,
SkinFactory $skinFactory = null,
UserGroupManager $userGroupManager = null,
SignatureValidatorFactory $signatureValidatorFactory = null )
Parameters
ServiceOptions$options
Language$contLang
AuthManager$authManager
LinkRenderer$linkRenderer
NamespaceInfo$nsInfo
PermissionManager$permissionManager
ILanguageConverter$languageConverter
LanguageNameUtils$languageNameUtils
HookContainer$hookContainer
UserOptionsLookup$userOptionsLookupShould be an instance of UserOptionsManager
LanguageConverterFactory | null$languageConverterFactory
ParserFactory | null$parserFactory
SkinFactory | null$skinFactory
UserGroupManager | null$userGroupManager
SignatureValidatorFactory | null$signatureValidatorFactory

Definition at line 179 of file DefaultPreferencesFactory.php.

References MediaWiki\Preferences\DefaultPreferencesFactory\$authManager, MediaWiki\Preferences\DefaultPreferencesFactory\$contLang, MediaWiki\Preferences\DefaultPreferencesFactory\$languageNameUtils, MediaWiki\Preferences\DefaultPreferencesFactory\$linkRenderer, MediaWiki\Preferences\DefaultPreferencesFactory\$nsInfo, MediaWiki\Preferences\DefaultPreferencesFactory\$options, MediaWiki\Preferences\DefaultPreferencesFactory\$permissionManager, MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and MediaWiki\MediaWikiServices\getInstance().

Member Function Documentation

◆ applyFilters()

MediaWiki\Preferences\DefaultPreferencesFactory::applyFilters ( array & $preferences,
array $formDescriptor,
$verb )
protected

Applies filters to preferences either before or after form usage.

Parameters
array&$preferences
array$formDescriptor
string$verbName of the filter method to call, either 'filterFromForm' or 'filterForForm'

Definition at line 2046 of file DefaultPreferencesFactory.php.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().

◆ cleanSignature()

MediaWiki\Preferences\DefaultPreferencesFactory::cleanSignature ( $signature,
$alldata,
HTMLForm $form )
protected
Parameters
string$signature
array$alldata
HTMLForm$form
Returns
string

Definition at line 1889 of file DefaultPreferencesFactory.php.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ datetimePreferences()

MediaWiki\Preferences\DefaultPreferencesFactory::datetimePreferences ( User $user,
IContextSource $context,
& $defaultPreferences )
protected

◆ editingPreferences()

MediaWiki\Preferences\DefaultPreferencesFactory::editingPreferences ( User $user,
MessageLocalizer $l10n,
& $defaultPreferences )
protected

◆ filesPreferences()

MediaWiki\Preferences\DefaultPreferencesFactory::filesPreferences ( IContextSource $context,
& $defaultPreferences )
protected

◆ generateSkinOptions()

MediaWiki\Preferences\DefaultPreferencesFactory::generateSkinOptions ( User $user,
IContextSource $context,
array $validSkinNames )
protected

◆ getDateOptions()

MediaWiki\Preferences\DefaultPreferencesFactory::getDateOptions ( IContextSource $context)
protected

◆ getForm()

MediaWiki\Preferences\DefaultPreferencesFactory::getForm ( User $user,
IContextSource $context,
$formClass = PreferencesFormOOUI::class,
array $remove = [] )

◆ getFormDescriptor()

◆ getImageSizes()

MediaWiki\Preferences\DefaultPreferencesFactory::getImageSizes ( MessageLocalizer $l10n)
protected

◆ getOptionFromUser()

MediaWiki\Preferences\DefaultPreferencesFactory::getOptionFromUser ( $name,
$info,
array $userOptions )
protected

Pull option from a user account.

Handles stuff like array-type preferences.

Deprecated
since 1.41; Use getPreferenceForField() instead.
Parameters
string$name
array$info
array$userOptions
Returns
array|string

Definition at line 405 of file DefaultPreferencesFactory.php.

References MediaWiki\Preferences\DefaultPreferencesFactory\$options.

◆ getOptionNamesForReset()

MediaWiki\Preferences\DefaultPreferencesFactory::getOptionNamesForReset ( User $user,
IContextSource $context,
$kinds )

Get the list of option names which have been saved by the user, thus having non-default values, which match the specified set of kinds.

Since
1.43
Parameters
User$user
IContextSource$context
string | string[]$kindsList of option kinds, which may be any of the kinds returned by listResetKinds(), or "all" for all options.
Returns
string[]

Implements MediaWiki\Preferences\PreferencesFactory.

Definition at line 2187 of file DefaultPreferencesFactory.php.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().

◆ getPreferenceForField()

static MediaWiki\Preferences\DefaultPreferencesFactory::getPreferenceForField ( $name,
HTMLFormField $field,
array $userOptions )
static

Get preference values for the 'default' param of html form descriptor, compatible with nested fields.

Since
1.41
Parameters
string$name
HTMLFormField$field
array$userOptions
Returns
array|string

Definition at line 378 of file DefaultPreferencesFactory.php.

◆ getResetKinds()

MediaWiki\Preferences\DefaultPreferencesFactory::getResetKinds ( User $user,
IContextSource $context,
$options = null )

Return an associative array mapping preferences keys to the kind of a preference they're used for.

Different kinds are handled differently when setting or reading preferences.

See PreferencesFactory::listResetKinds for the list of valid option types that can be provided.

Since
1.43
Parameters
User$user
IContextSource$context
array | null$optionsAssoc. array with options keys to check as keys. Defaults to all user options.
Returns
string[] The key => kind mapping data

Implements MediaWiki\Preferences\PreferencesFactory.

Definition at line 2099 of file DefaultPreferencesFactory.php.

◆ getSaveBlacklist()

MediaWiki\Preferences\DefaultPreferencesFactory::getSaveBlacklist ( )

Get the names of preferences that should never be saved (such as 'realname' and 'emailaddress').

Returns
string[]

Implements MediaWiki\Preferences\PreferencesFactory.

Definition at line 235 of file DefaultPreferencesFactory.php.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().

◆ getThumbSizes()

MediaWiki\Preferences\DefaultPreferencesFactory::getThumbSizes ( MessageLocalizer $l10n)
protected

◆ listResetKinds()

MediaWiki\Preferences\DefaultPreferencesFactory::listResetKinds ( )

Return a list of the types of user options currently returned by getResetKinds().

Currently, the option kinds are:

  • 'registered' - preferences which are registered in core MediaWiki or by extensions using the UserGetDefaultOptions hook.
  • 'registered-multiselect' - as above, using the 'multiselect' type.
  • 'registered-checkmatrix' - as above, using the 'checkmatrix' type.
  • 'userjs' - preferences with names starting with 'userjs-', intended to be used by user scripts.
  • 'special' - "preferences" that are not accessible via UserOptionsLookup::getOptions or UserOptionsManager::setOptions.
  • 'unused' - preferences about which MediaWiki doesn't know anything. These are usually legacy options, removed in newer versions.

The API (and possibly others) use this function to determine the possible option types for validation purposes, so make sure to update this when a new option kind is added.

Since
1.43
Returns
string[] Option kinds

Implements MediaWiki\Preferences\PreferencesFactory.

Definition at line 2176 of file DefaultPreferencesFactory.php.

◆ profilePreferences()

MediaWiki\Preferences\DefaultPreferencesFactory::profilePreferences ( User $user,
IContextSource $context,
& $defaultPreferences )
protected
Todo
Inject user Language instead of using context.
Parameters
User$user
IContextSource$context
array&$defaultPreferences
Returns
void

Definition at line 455 of file DefaultPreferencesFactory.php.

References MediaWiki\Preferences\DefaultPreferencesFactory\$options, MediaWiki\Preferences\DefaultPreferencesFactory\cleanSignature(), MediaWiki\Html\element(), MediaWiki\MainConfigNames\EmailAuthentication, MediaWiki\MainConfigNames\EmailConfirmToEdit, MediaWiki\MainConfigNames\EnableEmail, MediaWiki\MainConfigNames\EnableUserEmail, MediaWiki\MainConfigNames\EnableUserEmailMuteList, MediaWiki\MainConfigNames\EnotifMinorEdits, MediaWiki\MainConfigNames\EnotifRevealEditorAddress, MediaWiki\MainConfigNames\EnotifUserTalk, MediaWiki\MainConfigNames\EnotifWatchlist, MediaWiki\MainConfigNames\ForceHTTPS, MediaWiki\User\User\getEditCount(), MediaWiki\User\User\getEmail(), MediaWiki\User\User\getEmailAuthenticationTimestamp(), MediaWiki\User\UserGroupMembership\getExpiry(), MediaWiki\Context\IContextSource\getLanguage(), MediaWiki\User\User\getName(), MediaWiki\Context\IContextSource\getOutput(), MediaWiki\User\User\getRealName(), MediaWiki\User\User\getRegistration(), MediaWiki\Context\IContextSource\getRequest(), MediaWiki\Context\IContextSource\getTitle(), MediaWiki\SpecialPage\SpecialPage\getTitleFor(), MediaWiki\User\User\getTitleKey(), MediaWiki\Context\IContextSource\getUser(), MediaWiki\User\User\isAllowed(), MediaWiki\MainConfigNames\LanguageCode, MediaWiki\MainConfigNames\MaxSigChars, MessageLocalizer\msg(), MediaWiki\Message\Message\numParam(), MediaWiki\MainConfigNames\ScriptPath, MediaWiki\MainConfigNames\SecureLogin, MediaWiki\MainConfigNames\SignatureValidation, and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().

◆ rcPreferences()

◆ renderingPreferences()

MediaWiki\Preferences\DefaultPreferencesFactory::renderingPreferences ( User $user,
MessageLocalizer $l10n,
& $defaultPreferences )
protected

◆ saveFormData()

MediaWiki\Preferences\DefaultPreferencesFactory::saveFormData ( $formData,
PreferencesFormOOUI $form,
array $formDescriptor )
protected

◆ searchPreferences()

MediaWiki\Preferences\DefaultPreferencesFactory::searchPreferences ( $context,
& $defaultPreferences )
protected

◆ simplifyFormDescriptor()

static MediaWiki\Preferences\DefaultPreferencesFactory::simplifyFormDescriptor ( array $descriptor)
static

Simplify form descriptor for validation or something similar.

Parameters
array$descriptorHTML form descriptor.
Returns
array

Definition at line 278 of file DefaultPreferencesFactory.php.

References $params.

Referenced by MediaWiki\Api\ApiOptionsBase\getHtmlForm().

◆ skinPreferences()

◆ submitForm()

MediaWiki\Preferences\DefaultPreferencesFactory::submitForm ( array $formData,
PreferencesFormOOUI $form,
array $formDescriptor )
protected

◆ validateSignature()

MediaWiki\Preferences\DefaultPreferencesFactory::validateSignature ( $signature,
$alldata,
HTMLForm $form )
protected

◆ watchlistPreferences()

Member Data Documentation

◆ $authManager

AuthManager MediaWiki\Preferences\DefaultPreferencesFactory::$authManager
protected

◆ $contLang

Language MediaWiki\Preferences\DefaultPreferencesFactory::$contLang
protected

The wiki's content language.

Definition at line 85 of file DefaultPreferencesFactory.php.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().

◆ $languageNameUtils

LanguageNameUtils MediaWiki\Preferences\DefaultPreferencesFactory::$languageNameUtils
protected

◆ $linkRenderer

LinkRenderer MediaWiki\Preferences\DefaultPreferencesFactory::$linkRenderer
protected

◆ $nsInfo

NamespaceInfo MediaWiki\Preferences\DefaultPreferencesFactory::$nsInfo
protected

◆ $options

◆ $permissionManager

PermissionManager MediaWiki\Preferences\DefaultPreferencesFactory::$permissionManager
protected

◆ $userOptionsManager

UserOptionsManager MediaWiki\Preferences\DefaultPreferencesFactory::$userOptionsManager
protected

Definition at line 109 of file DefaultPreferencesFactory.php.

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Preferences\DefaultPreferencesFactory::CONSTRUCTOR_OPTIONS
Access: internal
For use by ServiceWiring

Definition at line 129 of file DefaultPreferencesFactory.php.


The documentation for this class was generated from the following file: