MediaWiki  REL1_19
FormOptions Class Reference

Helper class to keep track of options when mixing links and form elements. More...

Inheritance diagram for FormOptions:

List of all members.

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

See also:
http://php.net/manual/en/class.arrayaccess.php
 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()

Detailed Description

Helper class to keep track of options when mixing links and form elements.

Todo:
This badly need some examples and tests :-)

Copyright © 2008, Niklas Laxstiröm

Copyright © 2011, Antoine Musso

Author:
Niklas Laxström
Antoine Musso

Definition at line 14 of file FormOptions.php.


Member Function Documentation

FormOptions::add ( name,
default,
type = self::AUTO 
)

Definition at line 40 of file FormOptions.php.

References guessType().

Referenced by SpecialLog\execute(), and FormOptionsTest\setUp().

Here is the call graph for this function:

Here is the caller graph for this function:

Todo:
Document
Parameters:
$nameString: option name
Returns:
null

Definition at line 163 of file FormOptions.php.

References getValueReal(), and validateName().

Here is the call graph for this function:

Todo:
Document
Parameters:
$namesArray: array of option names
Returns:
null

Definition at line 175 of file FormOptions.php.

References $out, getValueReal(), and validateName().

Here is the call graph for this function:

FormOptions::delete ( name)

Definition at line 55 of file FormOptions.php.

References validateName().

Here is the call graph for this function:

Definition at line 261 of file FormOptions.php.

References WebRequest\getBool(), WebRequest\getInt(), WebRequest\getIntOrNull(), and WebRequest\getText().

Here is the call graph for this function:

Format options to an array ( name => value)

Returns:
Array

Definition at line 249 of file FormOptions.php.

References getValueReal().

Here is the call graph for this function:

Return options modified as an array ( name => value )

Returns:
Array

Definition at line 233 of file FormOptions.php.

Getting the data out for use.

Parameters:
$allBoolean: whether to include unchanged options (default: false)
Returns:
Array

Definition at line 215 of file FormOptions.php.

References getValueReal().

Here is the call graph for this function:

FormOptions::getValue ( name)

Get the value for the given option name.

Internally use getValueReal()

Parameters:
$nameString: option name
Returns:
Mixed

Definition at line 128 of file FormOptions.php.

References getValueReal(), and validateName().

Referenced by offsetGet(), and SpecialLog\show().

Here is the call graph for this function:

Here is the caller graph for this function:

FormOptions::getValueReal ( option) [protected]
Todo:
Document
Parameters:
$optionArray: array structure describing the option
Returns:
Mixed. Value or the default value if it is null

Definition at line 139 of file FormOptions.php.

Referenced by consumeValue(), consumeValues(), getAllValues(), getUnconsumedValues(), getValue(), and validateIntBounds().

Here is the caller graph for this function:

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.

Parameters:
$dataMixed: value to guess type for
Exceptions:
MWExceptionUnsupported datatype
Returns:
Type constant

Definition at line 70 of file FormOptions.php.

References BOOL, INT, and STRING.

Referenced by add(), and FormOptionsTest\guess().

Here is the caller graph for this function:

Whether option exist.

Definition at line 295 of file FormOptions.php.

Retrieve an option value.

Definition at line 299 of file FormOptions.php.

References getValue().

Here is the call graph for this function:

FormOptions::offsetSet ( name,
value 
)

Set an option to given value.

Definition at line 303 of file FormOptions.php.

References setValue().

Here is the call graph for this function:

Delete the option.

Definition at line 307 of file FormOptions.php.

FormOptions::reset ( name)

Delete the option value.

This will make future calls to getValue() return the default value.

Parameters:
$nameString: option name
Returns:
null

Definition at line 153 of file FormOptions.php.

References validateName().

Referenced by SpecialRecentChanges\buildMainQueryConds().

Here is the call graph for this function:

Here is the caller graph for this function:

FormOptions::setValue ( name,
value,
force = false 
)

Use to set the value of an option.

Parameters:
$nameString: option name
$valueMixed: value for the option
$forceBoolean: whether to set the value when it is equivalent to the default value for this option (default false).
Returns:
null

Definition at line 110 of file FormOptions.php.

References validateName().

Referenced by offsetSet(), SpecialLog\parseParams(), and validateIntBounds().

Here is the call graph for this function:

Here is the caller graph for this function:

FormOptions::validateIntBounds ( name,
min,
max 
)

Validate and set an option integer value The value will be altered to fit in the range.

Parameters:
$nameString: option name
$minInt: minimum value
$maxInt: maximum value
Exceptions:
MWExceptionOption is not of type int
Returns:
null

Definition at line 197 of file FormOptions.php.

References getValueReal(), setValue(), and validateName().

Here is the call graph for this function:

FormOptions::validateName ( name,
strict = false 
)

Verify the given option name exist.

Parameters:
$nameString: option name
$strictBoolean: throw an exception when the option does not exist (default false)
Returns:
Boolean: true if option exist, false otherwise

Definition at line 91 of file FormOptions.php.

Referenced by consumeValue(), consumeValues(), delete(), getValue(), reset(), setValue(), and validateIntBounds().

Here is the caller graph for this function:


Member Data Documentation

FormOptions::$options = array() [protected]
Todo:
Document!

Definition at line 36 of file FormOptions.php.

const FormOptions::AUTO = -1

Mark value for automatic detection (for simple data types only)

Definition at line 20 of file FormOptions.php.

Integer type or null, maps to WebRequest::getIntOrNull() This is useful for the namespace selector.

Definition at line 30 of file FormOptions.php.

Referenced by SpecialLog\execute(), SpecialWhatLinksHere\execute(), SpecialRecentChanges\getDefaultOptions(), and FormOptionsTest\setUp().


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