MediaWiki REL1_40
XmlSelect Class Reference

Class for generating HTML <select> or <datalist> elements. More...

Public Member Functions

 __construct ( $name=false, $id=false, $default=false)
 
 addOption ( $label, $value=false)
 
 addOptions ( $options)
 This accepts an array of form label => value label => ( label => value, label => value )
 
 getAttribute ( $name)
 
 getHTML ()
 
 setAttribute ( $name, $value)
 
 setDefault ( $default)
 
 setTagName ( $tagName)
 

Static Public Member Functions

static formatOptions ( $options, $default=false)
 This accepts an array of form: label => value label => ( label => value, label => value )
 
static parseOptionsMessage (string $msg)
 Parse labels and values out of a comma- and colon-separated list of options, such as is used for expiry and duration lists.
 

Protected Attributes

 $attributes = []
 
 $default = false
 
 $options = []
 
 $tagName = 'select'
 

Detailed Description

Class for generating HTML <select> or <datalist> elements.

Definition at line 28 of file XmlSelect.php.

Constructor & Destructor Documentation

◆ __construct()

XmlSelect::__construct ( $name = false,
$id = false,
$default = false )

Definition at line 34 of file XmlSelect.php.

References $default, and setAttribute().

Member Function Documentation

◆ addOption()

XmlSelect::addOption ( $label,
$value = false )
Parameters
string$label
string | int | float | false$valueIf not given, assumed equal to $label

Definition at line 82 of file XmlSelect.php.

◆ addOptions()

XmlSelect::addOptions ( $options)

This accepts an array of form label => value label => ( label => value, label => value )

Parameters
array$options

Definition at line 94 of file XmlSelect.php.

References $options.

◆ formatOptions()

static XmlSelect::formatOptions ( $options,
$default = false )
static

This accepts an array of form: label => value label => ( label => value, label => value )

Parameters
array$options
string | array | false$default
Returns
string

Definition at line 107 of file XmlSelect.php.

References $default, and $options.

◆ getAttribute()

XmlSelect::getAttribute ( $name)
Parameters
string$name
Returns
string|int|null

Definition at line 74 of file XmlSelect.php.

◆ getHTML()

XmlSelect::getHTML ( )
Returns
string

Definition at line 129 of file XmlSelect.php.

References $options.

◆ parseOptionsMessage()

static XmlSelect::parseOptionsMessage ( string $msg)
static

Parse labels and values out of a comma- and colon-separated list of options, such as is used for expiry and duration lists.

Documentation of the format is on translatewiki.net.

Since
1.35 string $msg The message to parse. string[] The options array, where keys are option labels (i.e. translations) and values are option values (i.e. untranslated).

Definition at line 148 of file XmlSelect.php.

References $options.

◆ setAttribute()

XmlSelect::setAttribute ( $name,
$value )
Parameters
string$name
string | int$value

Definition at line 66 of file XmlSelect.php.

Referenced by __construct().

◆ setDefault()

XmlSelect::setDefault ( $default)
Parameters
string | array$default

Definition at line 51 of file XmlSelect.php.

References $default.

◆ setTagName()

XmlSelect::setTagName ( $tagName)
Parameters
string | array$tagName

Definition at line 58 of file XmlSelect.php.

References $tagName.

Member Data Documentation

◆ $attributes

XmlSelect::$attributes = []
protected

Definition at line 32 of file XmlSelect.php.

◆ $default

XmlSelect::$default = false
protected

Definition at line 30 of file XmlSelect.php.

Referenced by __construct(), formatOptions(), and setDefault().

◆ $options

XmlSelect::$options = []
protected

Definition at line 29 of file XmlSelect.php.

Referenced by addOptions(), formatOptions(), getHTML(), and parseOptionsMessage().

◆ $tagName

XmlSelect::$tagName = 'select'
protected

Definition at line 31 of file XmlSelect.php.

Referenced by setTagName().


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