X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FXmlSelect.php;h=89f2f41cb876284d488fd5c6a464d31e6d4b6f2e;hp=78f476452f80d3c6504206081475eefe2d56b0d8;hb=24ae4318b36f88f2dd43db5989074b65776e2cf8;hpb=e36845aac66286ad9912d5d44ee7d226e7c4f616 diff --git a/includes/XmlSelect.php b/includes/XmlSelect.php index 78f476452f..89f2f41cb8 100644 --- a/includes/XmlSelect.php +++ b/includes/XmlSelect.php @@ -21,12 +21,13 @@ */ /** - * Class for generating HTML or elements. */ class XmlSelect { - protected $options = array(); + protected $options = []; protected $default = false; - protected $attributes = array(); + protected $tagName = 'select'; + protected $attributes = []; public function __construct( $name = false, $id = false, $default = false ) { if ( $name ) { @@ -49,6 +50,13 @@ class XmlSelect { $this->default = $default; } + /** + * @param string|array $tagName + */ + public function setTagName( $tagName ) { + $this->tagName = $tagName; + } + /** * @param string $name * @param string $value @@ -75,7 +83,7 @@ class XmlSelect { */ public function addOption( $label, $value = false ) { $value = $value !== false ? $value : $label; - $this->options[] = array( $label => $value ); + $this->options[] = [ $label => $value ]; } /** @@ -104,7 +112,7 @@ class XmlSelect { foreach ( $options as $label => $value ) { if ( is_array( $value ) ) { $contents = self::formatOptions( $value, $default ); - $data .= Html::rawElement( 'optgroup', array( 'label' => $label ), $contents ) . "\n"; + $data .= Html::rawElement( 'optgroup', [ 'label' => $label ], $contents ) . "\n"; } else { // If $default is an array, then the