MediaWiki
REL1_24
|
We're now using the HTMLForm object with some customisation to generate the Preferences form. More...
Static Public Member Functions | |
static | cleanSignature ($signature, $alldata, $form) |
static | datetimePreferences ($user, IContextSource $context, &$defaultPreferences) |
static | editingPreferences ($user, IContextSource $context, &$defaultPreferences) |
static | filesPreferences ($user, IContextSource $context, &$defaultPreferences) |
static | filterIntval ($value, $alldata) |
static | filterTimezoneInput ($tz, $alldata) |
static | generateSkinOptions ($user, IContextSource $context) |
static | getDateOptions (IContextSource $context) |
static | getFormObject ($user, IContextSource $context, $formClass= 'PreferencesForm', array $remove=array()) |
static | getImageSizes (IContextSource $context) |
static | getOptionFromUser ($name, $info, $user) |
Pull option from a user account. | |
static | getPreferences ($user, IContextSource $context) |
static | getSaveBlacklist () |
static | getThumbSizes (IContextSource $context) |
static | getTimezoneOptions (IContextSource $context) |
static | loadPreferenceValues ($user, $context, &$defaultPreferences) |
Loads existing values for a given array of preferences. | |
static | miscPreferences ($user, IContextSource $context, &$defaultPreferences) |
Dummy, kept for backwards-compatibility. | |
static | profilePreferences ($user, IContextSource $context, &$defaultPreferences) |
static | rcPreferences ($user, IContextSource $context, &$defaultPreferences) |
static | renderingPreferences ($user, IContextSource $context, &$defaultPreferences) |
static | searchPreferences ($user, IContextSource $context, &$defaultPreferences) |
static | skinPreferences ($user, IContextSource $context, &$defaultPreferences) |
static | tryFormSubmit ($formData, $form) |
Handle the form submission if everything validated properly. | |
static | trySetUserEmail (User $user, $newaddr) |
Try to set a user's email address. | |
static | tryUISubmit ($formData, $form) |
static | validateSignature ($signature, $alldata, $form) |
static | watchlistPreferences ($user, IContextSource $context, &$defaultPreferences) |
Static Protected Attributes | |
static | $defaultPreferences = null |
static | $saveFilters |
Static Private Attributes | |
static | $saveBlacklist |
We're now using the HTMLForm object with some customisation to generate the Preferences form.
This object handles generic submission, CSRF protection, layout and other logic in a reusable manner. We subclass it as a PreferencesForm to make some minor customisations.
In order to generate the form, the HTMLForm object needs an array structure detailing the form fields available, and that's what this class is for. Each element of the array is a basic property-list, including the type of field, the label it is to be given in the form, callbacks for validation and 'filtering', and other pertinent information. Note that the 'default' field is named for generic forms, and does not represent the preference's default (which is stored in $wgDefaultUserOptions), but the default for the form field, which should be whatever the user has set for that preference. There is no need to override it unless you have some special storage logic (for instance, those not presently stored as options, but which are best set from the user preferences view).
Field types are implemented as subclasses of the generic HTMLFormField object, and typically implement at least getInputHTML, which generates the HTML for the input field to be placed in the table.
Once fields have been retrieved and validated, submission logic is handed over to the tryUISubmit static method of this class.
Definition at line 48 of file Preferences.php.
static Preferences::cleanSignature | ( | $ | signature, |
$ | alldata, | ||
$ | form | ||
) | [static] |
string | $signature | |
array | $alldata | |
HTMLForm | $form |
Definition at line 1210 of file Preferences.php.
References $wgParser, Parser\cleanSigInSig(), and global.
static Preferences::datetimePreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 646 of file Preferences.php.
References $defaultPreferences, $user, array(), Xml\element(), HTMLFormField\flattenOptions(), getDateOptions(), IContextSource\getLanguage(), getTimezoneOptions(), Html\hidden(), and wfTimestampNow().
Referenced by getPreferences().
static Preferences::editingPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 776 of file Preferences.php.
References $defaultPreferences, $user, array(), IContextSource\getConfig(), and IContextSource\msg().
Referenced by getPreferences().
static Preferences::filesPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 624 of file Preferences.php.
References $defaultPreferences, and array().
Referenced by getPreferences().
static Preferences::filterIntval | ( | $ | value, |
$ | alldata | ||
) | [static] |
string | $value | |
array | $alldata |
Definition at line 1343 of file Preferences.php.
References $value.
static Preferences::filterTimezoneInput | ( | $ | tz, |
$ | alldata | ||
) | [static] |
static Preferences::generateSkinOptions | ( | $ | user, |
IContextSource $ | context | ||
) | [static] |
User | $user | The User object |
IContextSource | $context |
Definition at line 1046 of file Preferences.php.
References $ret, $user, array(), as, Skin\getAllowedSkins(), IContextSource\getConfig(), IContextSource\getLanguage(), Linker\link(), Title\makeTitleSafe(), IContextSource\msg(), Title\newMainPage(), and text.
Referenced by skinPreferences().
static Preferences::getDateOptions | ( | IContextSource $ | context | ) | [static] |
IContextSource | $context |
Definition at line 1115 of file Preferences.php.
References $key, $ret, array(), as, IContextSource\getLanguage(), global, IContextSource\msg(), and wfTimestampNow().
Referenced by datetimePreferences().
static Preferences::getFormObject | ( | $ | user, |
IContextSource $ | context, | ||
$ | formClass = 'PreferencesForm' , |
||
array $ | remove = array() |
||
) | [static] |
User | $user | |
IContextSource | $context | |
string | $formClass | |
array | $remove | Array of items to remove |
Definition at line 1229 of file Preferences.php.
References $name, $user, array(), as, getPreferences(), and IContextSource\msg().
Referenced by SpecialPreferences\execute().
static Preferences::getImageSizes | ( | IContextSource $ | context | ) | [static] |
IContextSource | $context |
Definition at line 1150 of file Preferences.php.
References $ret, array(), as, IContextSource\getConfig(), and IContextSource\msg().
static Preferences::getOptionFromUser | ( | $ | name, |
$ | info, | ||
$ | user | ||
) | [static] |
Pull option from a user account.
Handles stuff like array-type preferences.
string | $name | |
array | $info | |
User | $user |
Definition at line 165 of file Preferences.php.
References $columns, $name, $options, $user, $value, array(), as, and HTMLFormField\flattenOptions().
Referenced by loadPreferenceValues().
static Preferences::getPreferences | ( | $ | user, |
IContextSource $ | context | ||
) | [static] |
MWException |
User | $user | |
IContextSource | $context |
Definition at line 81 of file Preferences.php.
References $defaultPreferences, $user, array(), datetimePreferences(), editingPreferences(), filesPreferences(), loadPreferenceValues(), miscPreferences(), profilePreferences(), rcPreferences(), renderingPreferences(), searchPreferences(), skinPreferences(), watchlistPreferences(), and wfRunHooks().
Referenced by ApiOptions\execute(), and getFormObject().
static Preferences::getSaveBlacklist | ( | ) | [static] |
static Preferences::getThumbSizes | ( | IContextSource $ | context | ) | [static] |
IContextSource | $context |
Definition at line 1166 of file Preferences.php.
References $ret, $size, array(), as, IContextSource\getConfig(), and IContextSource\msg().
static Preferences::getTimezoneOptions | ( | IContextSource $ | context | ) | [static] |
IContextSource | $context |
Definition at line 1268 of file Preferences.php.
References $timestamp, $value, array(), as, IContextSource\getConfig(), MWTimestamp\getLocalInstance(), IContextSource\msg(), and text.
Referenced by datetimePreferences().
static Preferences::loadPreferenceValues | ( | $ | user, |
$ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
Loads existing values for a given array of preferences.
MWException |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences | Array to load values for |
Definition at line 114 of file Preferences.php.
References $defaultOptions, $defaultPreferences, $name, $user, array(), as, User\getDefaultOptions(), getOptionFromUser(), and HTMLForm\loadInputFromParameters().
Referenced by getPreferences().
static Preferences::miscPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
Dummy, kept for backwards-compatibility.
Definition at line 1038 of file Preferences.php.
Referenced by getPreferences().
static Preferences::profilePreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 208 of file Preferences.php.
References $defaultPreferences, LanguageConverter\$languagesWithVariants, $link, $name, $options, $t, $time, $user, $wgContLang, $wgParser, array(), as, below, Language\fetchLanguageNames(), IContextSource\getConfig(), User\getGroupMember(), User\getGroupName(), IContextSource\getLanguage(), IContextSource\getOutput(), IContextSource\getRequest(), IContextSource\getTitle(), SpecialPage\getTitleFor(), IContextSource\getUser(), global, Linker\link(), Linker\linkKnown(), User\makeGroupLinkHTML(), message, IContextSource\msg(), ParserOptions\newFromContext(), on, text, used, wfBCP47(), and wfCanIPUseHTTPS().
Referenced by getPreferences(), and PreferencesTest\prefsFor().
static Preferences::rcPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 862 of file Preferences.php.
References $defaultPreferences, $user, array(), IContextSource\getConfig(), and IContextSource\msg().
Referenced by getPreferences().
static Preferences::renderingPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 718 of file Preferences.php.
References $defaultPreferences, $value, array(), as, IContextSource\getConfig(), and IContextSource\msg().
Referenced by getPreferences().
static Preferences::searchPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 1027 of file Preferences.php.
References $defaultPreferences, $n, array(), as, and MWNamespace\getValidNamespaces().
Referenced by getPreferences().
static Preferences::skinPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 575 of file Preferences.php.
References $defaultPreferences, $user, array(), generateSkinOptions(), IContextSource\getConfig(), IContextSource\getLanguage(), Linker\link(), Title\makeTitleSafe(), and IContextSource\msg().
Referenced by getPreferences().
static Preferences::tryFormSubmit | ( | $ | formData, |
$ | form | ||
) | [static] |
Handle the form submission if everything validated properly.
array | $formData | |
PreferencesForm | $form |
Definition at line 1386 of file Preferences.php.
References $form, $key, $name, $result, $user, $value, array(), as, global, Status\newFatal(), and wfRunHooks().
Referenced by tryUISubmit().
static Preferences::trySetUserEmail | ( | User $ | user, |
$ | newaddr | ||
) | [static] |
Try to set a user's email address.
This does *not* try to validate the address. Caller is responsible for checking $wgAuth and 'editmyprivateinfo' right.
User | $user | |
string | $newaddr | New email address |
Definition at line 1481 of file Preferences.php.
References $result, array(), User\setEmailWithConfirmation(), and wfDeprecated().
static Preferences::tryUISubmit | ( | $ | formData, |
$ | form | ||
) | [static] |
array | $formData | |
PreferencesForm | $form |
Definition at line 1450 of file Preferences.php.
References $form, $res, array(), MediaWiki\getTitle(), Status\newGood(), and tryFormSubmit().
static Preferences::validateSignature | ( | $ | signature, |
$ | alldata, | ||
$ | form | ||
) | [static] |
string | $signature | |
array | $alldata | |
HTMLForm | $form |
Definition at line 1184 of file Preferences.php.
References $form, $wgParser, array(), Xml\element(), false, and global.
static Preferences::watchlistPreferences | ( | $ | user, |
IContextSource $ | context, | ||
&$ | defaultPreferences | ||
) | [static] |
User | $user | |
IContextSource | $context | |
array | $defaultPreferences |
Definition at line 919 of file Preferences.php.
References $defaultPreferences, $user, array(), as, IContextSource\getConfig(), and IContextSource\msg().
Referenced by getPreferences().
Preferences::$defaultPreferences = null [static, protected] |
Definition at line 50 of file Preferences.php.
Referenced by datetimePreferences(), editingPreferences(), filesPreferences(), getPreferences(), loadPreferenceValues(), profilePreferences(), rcPreferences(), renderingPreferences(), searchPreferences(), skinPreferences(), and watchlistPreferences().
Preferences::$saveBlacklist [static, private] |
array( 'realname', 'emailaddress', )
Definition at line 63 of file Preferences.php.
Referenced by getSaveBlacklist().
Preferences::$saveFilters [static, protected] |
array( 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ), 'cols' => array( 'Preferences', 'filterIntval' ), 'rows' => array( 'Preferences', 'filterIntval' ), 'rclimit' => array( 'Preferences', 'filterIntval' ), 'wllimit' => array( 'Preferences', 'filterIntval' ), 'searchlimit' => array( 'Preferences', 'filterIntval' ), )
Definition at line 53 of file Preferences.php.