X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FXml.php;h=7dcd4a4327590016ef99d9dc459715d128c0792d;hb=55c51f36a4869614d870dac5d870638ec58a95ff;hp=16a5a9ddecc8a608801e38bc8c542d36244bed81;hpb=0c2d09e312f0f577e5376dd57c5675087bb17244;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index 16a5a9ddec..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 ) { @@ -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 `