2008-09-03 Esteban Sanchez <estebans@artica.es>

* include/functions_html.php: Fixed a typo error in print_textarea 
        that cause not showing the value given.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1076 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2008-09-03 15:19:31 +00:00
parent 77f3ff1ea1
commit 1a79ab28ee
2 changed files with 20 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2008-09-03 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Fixed a typo error in print_textarea
that cause not showing the value given.
2008-09-03 Sancho Lerena <slerena@artica.es>
* include/functions_reporting_pdf.php: Moved to contrib branch.

View File

@ -23,14 +23,17 @@
*
* Based on choose_from_menu() from Moodle
*
* $fields Array with dropdown values. Example: $fields["value"] = "label"
* $name Select form name
* $selected Current selected value.
* $script Javascript onChange code.
* $nothing Label when nothing is selected.
* $nothing_value Value when nothing is selected
* @param array $fields Array with dropdown values. Example: $fields["value"] = "label"
* @param string $name Select form name
* @param variant $selected Current selected value.
* @param string $script Javascript onChange code.
* @param string $nothing Label when nothing is selected.
* @param variant $nothing_value Value when nothing is selected
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
* @param bool $multiple Set the input to allow multiple selections (optional, single selection by default).
* @param bool $sort Whether to sort the options or not (optional, unsorted by default).
*/
function print_select ($fields, $name, $selected = '', $script = '', $nothing = 'select', $nothing_value = '0', $return = false, $multiple = false) {
function print_select ($fields, $name, $selected = '', $script = '', $nothing = 'select', $nothing_value = '0', $return = false, $multiple = false, $sort = true) {
$output = "\n";
$attributes = ($script) ? 'onchange="'. $script .'"' : '';
@ -49,7 +52,8 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
}
if (!empty ($fields)) {
asort ($fields);
if ($sort)
asort ($fields);
foreach ($fields as $value => $label) {
$output .= ' <option value="'. $value .'"';
if ($value == $selected) {
@ -85,7 +89,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
* $nothing Label when nothing is selected.
* $nothing_value Value when nothing is selected
*/
function print_select_from_sql ($sql, $name, $selected = '', $script = '', $nothing = 'select', $nothing_value = '0', $return = false, $multiple = false) {
function print_select_from_sql ($sql, $name, $selected = '', $script = '', $nothing = 'select', $nothing_value = '0', $return = false, $multiple = false, $sort = true) {
$fields = array ();
$result = mysql_query ($sql);
@ -98,7 +102,7 @@ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $noth
$fields[$row[0]] = $row[1];
}
$output = print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, true, $multiple);
$output = print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, true, $multiple, $sort);
if ($return)
return $output;
@ -237,7 +241,7 @@ function print_button ($label = 'OK', $name = '', $disabled = false, $script = '
}
function print_textarea ($name, $rows, $columns, $value = '', $attributes = '', $return = false) {
$output = '<textarea name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' />';
$output = '<textarea name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' >';
$output .= $value;
$output .= '</textarea>';