MediaWiki master
MediaWiki\Xml\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

string int[] $attributes = []
 
string array false $default = false
 
array[] $options = []
 
string array $tagName = 'select'
 

Detailed Description

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

Definition at line 30 of file XmlSelect.php.

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ addOption()

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

Definition at line 88 of file XmlSelect.php.

◆ addOptions()

MediaWiki\Xml\XmlSelect::addOptions ( $options)

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

Parameters
array$options

Definition at line 100 of file XmlSelect.php.

References MediaWiki\Xml\XmlSelect\$options.

◆ formatOptions()

static MediaWiki\Xml\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 113 of file XmlSelect.php.

References MediaWiki\Xml\XmlSelect\$default, MediaWiki\Xml\XmlSelect\$options, MediaWiki\Xml\XmlSelect\formatOptions(), and MediaWiki\Xml\Xml\option().

Referenced by MediaWiki\Xml\XmlSelect\formatOptions(), and MediaWiki\Xml\XmlSelect\getHTML().

◆ getAttribute()

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

Definition at line 80 of file XmlSelect.php.

◆ getHTML()

MediaWiki\Xml\XmlSelect::getHTML ( )
Returns
string

Definition at line 135 of file XmlSelect.php.

References MediaWiki\Xml\XmlSelect\$options, and MediaWiki\Xml\XmlSelect\formatOptions().

◆ parseOptionsMessage()

static MediaWiki\Xml\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 154 of file XmlSelect.php.

References MediaWiki\Xml\XmlSelect\$options.

◆ setAttribute()

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

Definition at line 72 of file XmlSelect.php.

Referenced by MediaWiki\Xml\XmlSelect\__construct().

◆ setDefault()

MediaWiki\Xml\XmlSelect::setDefault ( $default)
Parameters
string | array$default

Definition at line 57 of file XmlSelect.php.

References MediaWiki\Xml\XmlSelect\$default.

◆ setTagName()

MediaWiki\Xml\XmlSelect::setTagName ( $tagName)
Parameters
string | array$tagName

Definition at line 64 of file XmlSelect.php.

References MediaWiki\Xml\XmlSelect\$tagName.

Member Data Documentation

◆ $attributes

string int [] MediaWiki\Xml\XmlSelect::$attributes = []
protected

Definition at line 38 of file XmlSelect.php.

◆ $default

string array false MediaWiki\Xml\XmlSelect::$default = false
protected

◆ $options

array [] MediaWiki\Xml\XmlSelect::$options = []
protected

◆ $tagName

string array MediaWiki\Xml\XmlSelect::$tagName = 'select'
protected

Definition at line 36 of file XmlSelect.php.

Referenced by MediaWiki\Xml\XmlSelect\setTagName().


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