Index: temp_moodle_dev/moodle/lib/weblib.php =================================================================== RCS file: /usr/local/cvsroot/temp_moodle_dev/moodle/lib/weblib.php,v diff -u -r1.4 -r1.5 --- temp_moodle_dev/moodle/lib/weblib.php 11 Dec 2008 07:30:16 -0000 1.4 +++ temp_moodle_dev/moodle/lib/weblib.php 28 Oct 2009 07:32:06 -0000 1.5 @@ -101,7 +101,7 @@ */ $ALLOWED_PROTOCOLS = array('http', 'https', 'ftp', 'news', 'mailto', 'rtsp', 'teamspeak', 'gopher', 'mms', 'color', 'callto', 'cursor', 'text-align', 'font-size', 'font-weight', 'font-style', 'font-family', - 'border', 'margin', 'padding', 'background', 'text-decoration'); // CSS as well to get through kses + 'border', 'margin', 'padding', 'background', 'background-color', 'text-decoration'); // CSS as well to get through kses /// Functions @@ -848,7 +848,6 @@ die; } - /** * Given an array of values, output the HTML for a select element with those options. * Normally, you only need to use the first few parameters. @@ -867,9 +866,17 @@ * @param int $tabindex if give, sets the tabindex attribute on the <select> element. Default none. * @param string $id value to use for the id attribute of the <select> element. If none is given, * then a suitable one is constructed. + * @param mixed $listbox if false, display as a dropdown menu. If true, display as a list box. + * By default, the list box will have a number of rows equal to min(10, count($options)), but if + * $listbox is an integer, that number is used for size instead. + * @param boolean $multiple if true, enable multiple selections, else only 1 item can be selected. Used + * when $listbox display is enabled + * @param string $class value to use for the class attribute of the <select> element. If none is given, + * then a suitable one is constructed. */ function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='', - $nothingvalue='0', $return=false, $disabled=false, $tabindex=0, $id='') { + $nothingvalue='0', $return=false, $disabled=false, $tabindex=0, + $id='', $listbox=false, $multiple=false, $class='') { if ($nothing == 'choose') { $nothing = get_string('choose') .'...'; @@ -886,23 +893,49 @@ if ($id ==='') { $id = 'menu'.$name; - // name may contaion [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading + // name may contaion [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading $id = str_replace('[', '', $id); $id = str_replace(']', '', $id); } - $output = '' . "\n"; if ($nothing) { $output .= '