MediaWiki  1.23.2
Preferences Class Reference

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. More...
 
static getPreferences ( $user, IContextSource $context)
 
static getSaveBlacklist ()
 
static getThumbSizes (IContextSource $context)
 
static getTimezoneOptions (IContextSource $context)
 
static loadOldSearchNs ( $user)
 
static miscPreferences ( $user, IContextSource $context, &$defaultPreferences)
 Dummy, kept for backwards-compatibility. More...
 
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. More...
 
static trySetUserEmail (User $user, $newaddr)
 Try to set a user's email address. More...
 
static tryUISubmit ( $formData, $form)
 
static validateSignature ( $signature, $alldata, $form)
 
static watchlistPreferences ( $user, IContextSource $context, &$defaultPreferences)
 

Static Public Attributes

static $defaultPreferences = null
 
static $saveFilters
 

Static Private Attributes

static $saveBlacklist
 

Detailed Description

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.

Member Function Documentation

◆ cleanSignature()

static Preferences::cleanSignature (   $signature,
  $alldata,
  $form 
)
static
Parameters
$signaturestring
$alldataarray
$formHTMLForm
Returns
string

Definition at line 1207 of file Preferences.php.

References $wgParser, and global.

◆ datetimePreferences()

static Preferences::datetimePreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static

◆ editingPreferences()

static Preferences::editingPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferencesArray

Definition at line 766 of file Preferences.php.

References $defaultPreferences, $user, array(), global, and IContextSource\msg().

Referenced by getPreferences().

◆ filesPreferences()

static Preferences::filesPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferencesArray

Definition at line 613 of file Preferences.php.

References $defaultPreferences, and array().

Referenced by getPreferences().

◆ filterIntval()

static Preferences::filterIntval (   $value,
  $alldata 
)
static
Parameters
$value
$alldata
Returns
int

Definition at line 1340 of file Preferences.php.

References $value.

◆ filterTimezoneInput()

static Preferences::filterTimezoneInput (   $tz,
  $alldata 
)
static
Parameters
$tz
$alldata
Returns
string

Definition at line 1349 of file Preferences.php.

◆ generateSkinOptions()

static Preferences::generateSkinOptions (   $user,
IContextSource  $context 
)
static
Parameters
$userUser The User object
$contextIContextSource
Returns
Array: text/links to display as key; $skinkey as value

Definition at line 1052 of file Preferences.php.

References $ret, $user, array(), as, Skin\getAllowedSkins(), IContextSource\getLanguage(), global, Linker\link(), Title\makeTitleSafe(), IContextSource\msg(), Title\newMainPage(), NS_USER, and text.

◆ getDateOptions()

static Preferences::getDateOptions ( IContextSource  $context)
static
Parameters
$contextIContextSource
Returns
array

Definition at line 1109 of file Preferences.php.

References $ret, array(), as, IContextSource\getLanguage(), global, IContextSource\msg(), and wfTimestampNow().

Referenced by datetimePreferences().

◆ getFormObject()

static Preferences::getFormObject (   $user,
IContextSource  $context,
  $formClass = 'PreferencesForm',
array  $remove = array() 
)
static
Parameters
$userUser
$contextIContextSource
$formClassstring
array$removearray of items to remove
Returns
HtmlForm

Definition at line 1226 of file Preferences.php.

References $name, $user, array(), as, getPreferences(), and IContextSource\msg().

Referenced by SpecialPreferences\execute().

◆ getImageSizes()

static Preferences::getImageSizes ( IContextSource  $context)
static
Parameters
$contextIContextSource
Returns
array

Definition at line 1144 of file Preferences.php.

References $ret, array(), as, global, and IContextSource\msg().

◆ getOptionFromUser()

static Preferences::getOptionFromUser (   $name,
  $info,
  $user 
)
static

Pull option from a user account.

Handles stuff like array-type preferences.

Parameters
$name
$info
$userUser
Returns
array|String

Definition at line 151 of file Preferences.php.

References $columns, $name, $options, $user, $value, array(), as, and HTMLFormField\flattenOptions().

Referenced by getPreferences().

◆ getPreferences()

◆ getSaveBlacklist()

static Preferences::getSaveBlacklist ( )
static
Returns
array

Definition at line 68 of file Preferences.php.

References $saveBlacklist.

Referenced by User\getOptionKinds().

◆ getThumbSizes()

static Preferences::getThumbSizes ( IContextSource  $context)
static
Parameters
$contextIContextSource
Returns
array

Definition at line 1162 of file Preferences.php.

References $ret, $size, array(), as, global, and IContextSource\msg().

◆ getTimezoneOptions()

static Preferences::getTimezoneOptions ( IContextSource  $context)
static
Parameters
$contextIContextSource
Returns
array

Definition at line 1265 of file Preferences.php.

References $timestamp, $value, array(), as, MWTimestamp\getLocalInstance(), global, IContextSource\msg(), and text.

Referenced by datetimePreferences().

◆ loadOldSearchNs()

static Preferences::loadOldSearchNs (   $user)
static
Deprecated:
in 1.19
Parameters
$userUser
Returns
array

Definition at line 1490 of file Preferences.php.

References $name, $user, array(), as, SearchEngine\searchableNamespaces(), and wfDeprecated().

◆ miscPreferences()

static Preferences::miscPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static

Dummy, kept for backwards-compatibility.

Definition at line 1044 of file Preferences.php.

Referenced by getPreferences().

◆ profilePreferences()

◆ rcPreferences()

static Preferences::rcPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferencesArray

Definition at line 854 of file Preferences.php.

References $defaultPreferences, $user, array(), global, and IContextSource\msg().

Referenced by getPreferences().

◆ renderingPreferences()

static Preferences::renderingPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferencesArray

Definition at line 707 of file Preferences.php.

References $defaultPreferences, $value, array(), as, global, and IContextSource\msg().

Referenced by getPreferences().

◆ searchPreferences()

static Preferences::searchPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferencesArray

Definition at line 1015 of file Preferences.php.

References $defaultPreferences, $name, $wgContLang, array(), as, global, and IContextSource\msg().

Referenced by getPreferences().

◆ skinPreferences()

static Preferences::skinPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferences
Returns
void

Definition at line 570 of file Preferences.php.

References $defaultPreferences, $user, array(), IContextSource\getLanguage(), global, Linker\link(), Title\makeTitleSafe(), IContextSource\msg(), and NS_USER.

Referenced by getPreferences().

◆ tryFormSubmit()

static Preferences::tryFormSubmit (   $formData,
  $form 
)
static

Handle the form submission if everything validated properly.

Parameters
$formData
$formPreferencesForm
Returns
bool|Status|string

Definition at line 1383 of file Preferences.php.

References $form, $name, $user, $value, array(), as, global, Status\newFatal(), and wfRunHooks().

Referenced by tryUISubmit().

◆ trySetUserEmail()

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.

Deprecated:
in 1.20; use User::setEmailWithConfirmation() instead.
Parameters
$userUser
string$newaddrNew email address
Returns
Array (true on success or Status on failure, info string)

Definition at line 1474 of file Preferences.php.

References $user, array(), and wfDeprecated().

◆ tryUISubmit()

static Preferences::tryUISubmit (   $formData,
  $form 
)
static
Parameters
$formData
$formPreferencesForm
Returns
Status

Definition at line 1443 of file Preferences.php.

References $form, $res, array(), MediaWiki\getTitle(), Status\newGood(), and tryFormSubmit().

◆ validateSignature()

static Preferences::validateSignature (   $signature,
  $alldata,
  $form 
)
static
Parameters
$signaturestring
$alldataarray
$formHTMLForm
Returns
bool|string

Definition at line 1182 of file Preferences.php.

References $form, $wgParser, array(), Xml\element(), false, and global.

◆ watchlistPreferences()

static Preferences::watchlistPreferences (   $user,
IContextSource  $context,
$defaultPreferences 
)
static
Parameters
$userUser
$contextIContextSource
$defaultPreferences

Definition at line 911 of file Preferences.php.

References $defaultPreferences, $user, array(), as, global, and IContextSource\msg().

Referenced by getPreferences().

Member Data Documentation

◆ $defaultPreferences

◆ $saveBlacklist

Preferences::$saveBlacklist
staticprivate
Initial value:
'realname',
'emailaddress',
)

Definition at line 60 of file Preferences.php.

Referenced by getSaveBlacklist().

◆ $saveFilters

Preferences::$saveFilters
static
Initial value:
'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 50 of file Preferences.php.


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.