X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXml.php;h=0091513125ca68ee601dac526b532271fbba76cd;hb=15dc2f8eaafeb2ccfec848d4ce0770119494e067;hp=d0164331e138d95e69191882afc4dbab26b593f9;hpb=c6d1ceb90a9684fa0da758d88ba1e994fad4cffc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index d0164331e1..0091513125 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -225,7 +225,7 @@ class Xml { $selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode; $options = "\n"; foreach ( $languages as $code => $name ) { - $options .= Xml::option( "$code - $name", $code, $code == $selected ) . "\n"; + $options .= self::option( "$code - $name", $code, $code == $selected ) . "\n"; } $attrs = [ 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' ]; @@ -235,8 +235,8 @@ class Xml { $msg = wfMessage( 'yourlanguage' ); } return [ - Xml::label( $msg->text(), $attrs['id'] ), - Xml::tags( 'select', $attrs, $options ) + self::label( $msg->text(), $attrs['id'] ), + self::tags( 'select', $attrs, $options ) ]; } @@ -400,7 +400,7 @@ class Xml { $value = false, $attribs = [] ) { return [ - Xml::label( $label, $id, $attribs ), + self::label( $label, $id, $attribs ), self::input( $name, $size, $value, [ 'id' => $id ] + $attribs ) ]; } @@ -493,7 +493,8 @@ class Xml { } /** - * Build a drop-down box from a textual list. + * Build a drop-down box from a textual list. This is a wrapper + * for Xml::listDropDownOptions() plus the XmlSelect class. * * @param string $name Name and id for the drop-down * @param string $list Correctly formatted text (newline delimited) to be @@ -507,60 +508,91 @@ class Xml { public static function listDropDown( $name = '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) { - $optgroup = false; + $options = self::listDropDownOptions( $list, [ 'other' => $other ] ); + + $xmlSelect = new XmlSelect( $name, $name, $selected ); + $xmlSelect->addOptions( $options ); + + if ( $class ) { + $xmlSelect->setAttribute( 'class', $class ); + } + if ( $tabindex ) { + $xmlSelect->setAttribute( 'tabindex', $tabindex ); + } - $options = self::option( $other, 'other', $selected === 'other' ); + return $xmlSelect->getHTML(); + } + /** + * Build options for a drop-down box from a textual list. + * + * The result of this function can be passed to XmlSelect::addOptions() + * (to render a plain `