X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXml.php;h=7dcd4a4327590016ef99d9dc459715d128c0792d;hb=0535765366fc2bc72e84bacb0b14e5a2a790ee94;hp=d0164331e138d95e69191882afc4dbab26b593f9;hpb=1abc89fc7651e122ca53fe874eecb89f30b5ba35;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index d0164331e1..7dcd4a4327 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -160,8 +160,9 @@ class Xml { } /** - * @param int $year - * @param int $month + * @param int|string $year Use '' or 0 to start with no year preselected. + * @param int|string $month A month in the 1..12 range. Use '', 0 or -1 to start with no month + * preselected. * @return string Formatted HTML */ public static function dateMenu( $year, $month ) { @@ -225,7 +226,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 +236,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 +401,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 +494,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 +509,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 `