MediaWiki master
|
This is the default implementation of PreferencesFactory. More...
Inherits MediaWiki\Preferences\PreferencesFactory.
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').
| |
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 |
This is the default implementation of PreferencesFactory.
Definition at line 78 of file DefaultPreferencesFactory.php.
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 ) |
ServiceOptions | $options | |
Language | $contLang | |
AuthManager | $authManager | |
LinkRenderer | $linkRenderer | |
NamespaceInfo | $nsInfo | |
PermissionManager | $permissionManager | |
ILanguageConverter | $languageConverter | |
LanguageNameUtils | $languageNameUtils | |
HookContainer | $hookContainer | |
UserOptionsLookup | $userOptionsLookup | Should 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().
|
protected |
Applies filters to preferences either before or after form usage.
array | &$preferences | |
array | $formDescriptor | |
string | $verb | Name of the filter method to call, either 'filterFromForm' or 'filterForForm' |
Definition at line 2046 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().
|
protected |
string | $signature | |
array | $alldata | |
HTMLForm | $form |
Definition at line 1889 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().
|
protected |
User | $user | |
IContextSource | $context | |
array | &$defaultPreferences |
Definition at line 1050 of file DefaultPreferencesFactory.php.
References MediaWiki\Html\Html\element(), MediaWiki\Preferences\DefaultPreferencesFactory\getDateOptions(), MediaWiki\Context\IContextSource\getLanguage(), MediaWiki\MainConfigNames\LocalTZoffset, and wfTimestampNow().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
User | $user | |
MessageLocalizer | $l10n | |
array | &$defaultPreferences |
Definition at line 1180 of file DefaultPreferencesFactory.php.
References MediaWiki\MainConfigNames\AllowUserCssPrefs, MediaWiki\MainConfigNames\EnableEditRecovery, MediaWiki\User\User\isAllowed(), and MessageLocalizer\msg().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
IContextSource | $context | |
array | &$defaultPreferences |
Definition at line 1029 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\getImageSizes(), and MediaWiki\Preferences\DefaultPreferencesFactory\getThumbSizes().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
User | $user | |
IContextSource | $context | |
array | $validSkinNames |
Definition at line 1692 of file DefaultPreferencesFactory.php.
References MediaWiki\MainConfigNames\AllowUserCss, MediaWiki\MainConfigNames\AllowUserJs, MediaWiki\MainConfigNames\DefaultSkin, MediaWiki\Context\IContextSource\getLanguage(), MediaWiki\User\User\getName(), MessageLocalizer\msg(), and NS_USER.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\skinPreferences().
|
protected |
IContextSource | $context |
Definition at line 1756 of file DefaultPreferencesFactory.php.
References $wgDefaultUserOptions, MediaWiki\Context\IContextSource\getLanguage(), MessageLocalizer\msg(), and wfTimestampNow().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\datetimePreferences().
MediaWiki\Preferences\DefaultPreferencesFactory::getForm | ( | User | $user, |
IContextSource | $context, | ||
$formClass = PreferencesFormOOUI::class, | |||
array | $remove = [] ) |
User | $user | |
IContextSource | $context | |
string | $formClass | |
array | $remove | Array of items to remove |
Implements MediaWiki\Preferences\PreferencesFactory.
Definition at line 1907 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor(), MediaWiki\Context\IContextSource\getOutput(), MediaWiki\Context\IContextSource\getRequest(), MediaWiki\Context\IContextSource\getTitle(), MediaWiki\User\User\isAllowed(), and MediaWiki\Preferences\DefaultPreferencesFactory\submitForm().
MediaWiki\Preferences\DefaultPreferencesFactory::getFormDescriptor | ( | User | $user, |
IContextSource | $context ) |
User | $user | |
IContextSource | $context |
Implements MediaWiki\Preferences\PreferencesFactory.
Definition at line 247 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\datetimePreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\editingPreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\filesPreferences(), MediaWiki\Context\IContextSource\getLanguage(), MediaWiki\Context\IContextSource\getSkin(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\rcPreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\renderingPreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\searchPreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\skinPreferences(), and MediaWiki\Preferences\DefaultPreferencesFactory\watchlistPreferences().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getForm().
|
protected |
MessageLocalizer | $l10n |
Definition at line 1790 of file DefaultPreferencesFactory.php.
References MediaWiki\MainConfigNames\ImageLimits, and MessageLocalizer\msg().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\filesPreferences().
|
protected |
Pull option from a user account.
Handles stuff like array-type preferences.
string | $name | |
array | $info | |
array | $userOptions |
Definition at line 405 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\$options.
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.
User | $user | |
IContextSource | $context | |
string | string[] | $kinds | List of option kinds, which may be any of the kinds returned by listResetKinds(), or "all" for all options. |
Implements MediaWiki\Preferences\PreferencesFactory.
Definition at line 2187 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().
|
static |
Get preference values for the 'default' param of html form descriptor, compatible with nested fields.
string | $name | |
HTMLFormField | $field | |
array | $userOptions |
Definition at line 378 of file DefaultPreferencesFactory.php.
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.
User | $user | |
IContextSource | $context | |
array | null | $options | Assoc. array with options keys to check as keys. Defaults to all user options. |
Implements MediaWiki\Preferences\PreferencesFactory.
Definition at line 2099 of file DefaultPreferencesFactory.php.
MediaWiki\Preferences\DefaultPreferencesFactory::getSaveBlacklist | ( | ) |
Get the names of preferences that should never be saved (such as 'realname' and 'emailaddress').
Implements MediaWiki\Preferences\PreferencesFactory.
Definition at line 235 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().
|
protected |
MessageLocalizer | $l10n |
Definition at line 1807 of file DefaultPreferencesFactory.php.
References MessageLocalizer\msg(), and MediaWiki\MainConfigNames\ThumbLimits.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\filesPreferences().
MediaWiki\Preferences\DefaultPreferencesFactory::listResetKinds | ( | ) |
Return a list of the types of user options currently returned by getResetKinds().
Currently, the option kinds are:
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.
Implements MediaWiki\Preferences\PreferencesFactory.
Definition at line 2176 of file DefaultPreferencesFactory.php.
|
protected |
User | $user | |
IContextSource | $context | |
array | &$defaultPreferences |
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().
|
protected |
User | $user | |
MessageLocalizer | $l10n | |
array | &$defaultPreferences |
Definition at line 1260 of file DefaultPreferencesFactory.php.
References MediaWiki\Message\Message\numParam(), MediaWiki\MainConfigNames\RCMaxAge, MediaWiki\MainConfigNames\RCShowWatchingUsers, MediaWiki\MainConfigNames\RCWatchCategoryMembership, MediaWiki\User\User\useNPPatrol(), and MediaWiki\User\User\useRCPatrol().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
User | $user | |
MessageLocalizer | $l10n | |
array | &$defaultPreferences |
Definition at line 1119 of file DefaultPreferencesFactory.php.
References MediaWiki\MainConfigNames\AllowUserCssPrefs, MediaWiki\User\User\isAllowed(), and MessageLocalizer\msg().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
Handle the form submission if everything validated properly.
array | $formData | |
PreferencesFormOOUI | $form | |
array[] | $formDescriptor |
Definition at line 1969 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\applyFilters(), MediaWiki\Context\ContextSource\getContext(), PreferencesFormOOUI\getModifiedUser(), MediaWiki\Preferences\DefaultPreferencesFactory\getOptionNamesForReset(), MediaWiki\Preferences\DefaultPreferencesFactory\getSaveBlacklist(), and MediaWiki\MainConfigNames\HiddenPrefs.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\submitForm().
|
protected |
IContextSource | $context | |
array | &$defaultPreferences |
Definition at line 1533 of file DefaultPreferencesFactory.php.
References MediaWiki\Context\IContextSource\getLanguage(), MessageLocalizer\msg(), NS_FILE, NS_MAIN, MediaWiki\MainConfigNames\SearchMatchRedirectPreference, and MediaWiki\MainConfigNames\ThumbnailNamespaces.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
static |
Simplify form descriptor for validation or something similar.
array | $descriptor | HTML form descriptor. |
Definition at line 278 of file DefaultPreferencesFactory.php.
References $params.
Referenced by MediaWiki\Api\ApiOptionsBase\getHtmlForm().
|
protected |
User | $user | |
IContextSource | $context | |
array | &$defaultPreferences |
Definition at line 955 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\$options, MediaWiki\MainConfigNames\AllowUserCss, MediaWiki\MainConfigNames\AllowUserJs, MediaWiki\Preferences\DefaultPreferencesFactory\generateSkinOptions(), MediaWiki\Config\ServiceOptions\get(), MediaWiki\Context\IContextSource\getLanguage(), MediaWiki\User\User\getName(), MessageLocalizer\msg(), and NS_USER.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
Save the form data and reload the page.
array | $formData | |
PreferencesFormOOUI | $form | |
array | $formDescriptor |
Definition at line 2075 of file DefaultPreferencesFactory.php.
References $url, MediaWiki\Context\ContextSource\getContext(), PreferencesFormOOUI\getExtraSuccessRedirectParameters(), MediaWiki\HTMLForm\HTMLForm\getTitle(), and MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getForm().
|
protected |
mixed | $signature | |
array | $alldata | |
HTMLForm | $form |
Definition at line 1825 of file DefaultPreferencesFactory.php.
References MediaWiki\Context\ContextSource\getContext(), MediaWiki\Context\ContextSource\getUser(), MediaWiki\MainConfigNames\MaxSigChars, MediaWiki\Context\ContextSource\msg(), and MediaWiki\MainConfigNames\SignatureValidation.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().
|
protected |
User | $user | |
IContextSource | $context | |
array | &$defaultPreferences |
Definition at line 1361 of file DefaultPreferencesFactory.php.
References MediaWiki\Preferences\DefaultPreferencesFactory\$options, MediaWiki\Specials\SpecialWatchlist\checkStructuredFilterUiEnabled(), MediaWiki\SpecialPage\SpecialPage\getTitleFor(), MediaWiki\User\User\isAllowed(), MediaWiki\User\User\isAllowedAny(), MessageLocalizer\msg(), MediaWiki\Message\Message\numParam(), MediaWiki\MainConfigNames\RCMaxAge, MediaWiki\MainConfigNames\RCWatchCategoryMembership, and MediaWiki\User\User\useRCPatrol().
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor().
|
protected |
Definition at line 91 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().
|
protected |
The wiki's content language.
Definition at line 85 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().
|
protected |
Definition at line 88 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().
|
protected |
Definition at line 94 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().
|
protected |
Definition at line 97 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().
|
protected |
Definition at line 82 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct(), MediaWiki\Preferences\DefaultPreferencesFactory\getOptionFromUser(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\skinPreferences(), and MediaWiki\Preferences\DefaultPreferencesFactory\watchlistPreferences().
|
protected |
Definition at line 100 of file DefaultPreferencesFactory.php.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\__construct().
|
protected |
Definition at line 109 of file DefaultPreferencesFactory.php.
const MediaWiki\Preferences\DefaultPreferencesFactory::CONSTRUCTOR_OPTIONS |
Definition at line 129 of file DefaultPreferencesFactory.php.