MediaWiki
REL1_21
|
Helper class to keep track of options when mixing links and form elements. More...
Public Member Functions | |
add ($name, $default, $type=self::AUTO) | |
consumeValue ($name) | |
consumeValues ($names) | |
delete ($name) | |
fetchValuesFromRequest (WebRequest $r, $values=false) | |
getAllValues () | |
Format options to an array ( name => value) | |
getChangedValues () | |
Return options modified as an array ( name => value ) | |
getUnconsumedValues ($all=false) | |
Getting the data out for use. | |
getValue ($name) | |
Get the value for the given option name. | |
reset ($name) | |
Delete the option value. | |
setValue ($name, $value, $force=false) | |
Use to set the value of an option. | |
validateIntBounds ($name, $min, $max) | |
Validate and set an option integer value The value will be altered to fit in the range. | |
validateName ($name, $strict=false) | |
Verify the given option name exist. | |
ArrayAccess functions | |
Those function implements PHP ArrayAccess interface | |
offsetExists ($name) | |
Whether option exist. | |
offsetGet ($name) | |
Retrieve an option value. | |
offsetSet ($name, $value) | |
Set an option to given value. | |
offsetUnset ($name) | |
Delete the option. | |
Static Public Member Functions | |
static | guessType ($data) |
Used to find out which type the data is. | |
Public Attributes | |
Type constants | |
Used internally to map an option value to a WebRequest accessor | |
const | AUTO = -1 |
Mark value for automatic detection (for simple data types only) | |
const | STRING = 0 |
String type, maps guessType() to WebRequest::getText() | |
const | INT = 1 |
Integer type, maps guessType() to WebRequest::getInt() | |
const | BOOL = 2 |
Boolean type, maps guessType() to WebRequest::getBool() | |
const | INTNULL = 3 |
Integer type or null, maps to WebRequest::getIntOrNull() This is useful for the namespace selector. | |
Protected Member Functions | |
getValueReal ($option) | |
Protected Attributes | |
$options = array() |
Helper class to keep track of options when mixing links and form elements.
Definition at line 33 of file FormOptions.php.
FormOptions::add | ( | $ | name, |
$ | default, | ||
$ | type = self::AUTO |
||
) |
Definition at line 59 of file FormOptions.php.
References $name, array(), guessType(), and options().
Referenced by SpecialLog\execute(), and SpecialNewpages\setup().
FormOptions::consumeValue | ( | $ | name | ) |
string | $name | Option name |
MWException | If option does not exist. |
Definition at line 185 of file FormOptions.php.
References $name, getValueReal(), options(), and validateName().
FormOptions::consumeValues | ( | $ | names | ) |
array | $names | array of option names |
Definition at line 197 of file FormOptions.php.
References $name, $out, array(), as, getValueReal(), options(), and validateName().
FormOptions::delete | ( | $ | name | ) |
Definition at line 74 of file FormOptions.php.
References $name, options(), and validateName().
FormOptions::fetchValuesFromRequest | ( | WebRequest $ | r, |
$ | values = false |
||
) |
Definition at line 284 of file FormOptions.php.
References $name, $value, as, WebRequest\getBool(), WebRequest\getInt(), WebRequest\getIntOrNull(), WebRequest\getText(), and options().
Referenced by SpecialNewpages\setup().
Format options to an array ( name => value)
Definition at line 272 of file FormOptions.php.
References $name, array(), as, getValueReal(), and options().
FormOptions::getUnconsumedValues | ( | $ | all = false | ) |
Getting the data out for use.
$all | Boolean: whether to include unchanged options (default: false) |
Definition at line 238 of file FormOptions.php.
References $name, array(), as, getValueReal(), and options().
FormOptions::getValue | ( | $ | name | ) |
Get the value for the given option name.
Internally use getValueReal()
string | $name | option name |
Definition at line 149 of file FormOptions.php.
References $name, getValueReal(), options(), and validateName().
Referenced by offsetGet(), and SpecialLog\show().
FormOptions::getValueReal | ( | $ | option | ) | [protected] |
array | $option | array structure describing the option |
Definition at line 160 of file FormOptions.php.
Referenced by consumeValue(), consumeValues(), getAllValues(), getUnconsumedValues(), getValue(), and validateIntBounds().
static FormOptions::guessType | ( | $ | data | ) | [static] |
Used to find out which type the data is.
All types are defined in the 'Type constants' section of this class Please note we do not support detection of INTNULL MediaWiki type which will be assumed as INT if the data is an integer.
$data | Mixed: value to guess type for |
MWException | |
MWException | Unsupported datatype |
Definition at line 90 of file FormOptions.php.
References BOOL, INT, and STRING.
Referenced by add().
FormOptions::offsetExists | ( | $ | name | ) |
FormOptions::offsetGet | ( | $ | name | ) |
Retrieve an option value.
Definition at line 328 of file FormOptions.php.
References $name, and getValue().
FormOptions::offsetSet | ( | $ | name, |
$ | value | ||
) |
Set an option to given value.
Definition at line 332 of file FormOptions.php.
References $name, $value, and setValue().
FormOptions::offsetUnset | ( | $ | name | ) |
FormOptions::reset | ( | $ | name | ) |
Delete the option value.
This will make future calls to getValue() return the default value.
string | $name | option name |
Definition at line 174 of file FormOptions.php.
References $name, options(), and validateName().
Referenced by SpecialRecentChanges\buildMainQueryConds().
FormOptions::setValue | ( | $ | name, |
$ | value, | ||
$ | force = false |
||
) |
Use to set the value of an option.
string | $name | option name |
$value | Mixed: value for the option | |
$force | Boolean: whether to set the value when it is equivalent to the default value for this option (default false). |
Definition at line 131 of file FormOptions.php.
References $name, $value, options(), and validateName().
Referenced by offsetSet(), SpecialLog\parseParams(), SpecialNewpages\setup(), and validateIntBounds().
FormOptions::validateIntBounds | ( | $ | name, |
$ | min, | ||
$ | max | ||
) |
Validate and set an option integer value The value will be altered to fit in the range.
string | $name | option name |
int | $min | minimum value |
int | $max | maximum value |
MWException | |
MWException | Option is not of type int |
Definition at line 220 of file FormOptions.php.
References $name, $value, getValueReal(), options(), setValue(), and validateName().
Referenced by SpecialNewpages\setup().
FormOptions::validateName | ( | $ | name, |
$ | strict = false |
||
) |
Verify the given option name exist.
string | $name | option name |
$strict | Boolean: throw an exception when the option does not exist (default false) |
MWException |
Definition at line 112 of file FormOptions.php.
References $name, and options().
Referenced by consumeValue(), consumeValues(), delete(), getValue(), reset(), setValue(), and validateIntBounds().
Definition at line 55 of file FormOptions.php.
const FormOptions::AUTO = -1 |
Mark value for automatic detection (for simple data types only)
Definition at line 39 of file FormOptions.php.
const FormOptions::BOOL = 2 |
Boolean type, maps guessType() to WebRequest::getBool()
Definition at line 45 of file FormOptions.php.
Referenced by FormOptionsTest\assertGuessBoolean(), and guessType().
const FormOptions::INT = 1 |
Integer type, maps guessType() to WebRequest::getInt()
Definition at line 43 of file FormOptions.php.
Referenced by guessType(), and FormOptionsInitializationTest\testAddIntegers().
const FormOptions::INTNULL = 3 |
Integer type or null, maps to WebRequest::getIntOrNull() This is useful for the namespace selector.
Definition at line 49 of file FormOptions.php.
Referenced by SpecialLog\execute(), and SpecialRecentChanges\getDefaultOptions().
const FormOptions::STRING = 0 |
String type, maps guessType() to WebRequest::getText()
Definition at line 41 of file FormOptions.php.
Referenced by guessType(), and FormOptionsInitializationTest\testAddStringOption().