X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXmlSelect.php;h=5d7406c64d3c10045f192a301ab2906db67797cb;hb=9d00d8783e9d74343fc0ea34ab228ce70684e4e4;hp=78f476452f80d3c6504206081475eefe2d56b0d8;hpb=1271bb75c60f98720a24ed1bac13a48f2181fb00;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/XmlSelect.php b/includes/XmlSelect.php index 78f476452f..5d7406c64d 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 @@ -62,11 +70,7 @@ class XmlSelect { * @return string|null */ public function getAttribute( $name ) { - if ( isset( $this->attributes[$name] ) ) { - return $this->attributes[$name]; - } else { - return null; - } + return $this->attributes[$name] ?? null; } /** @@ -75,7 +79,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 +108,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