diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index dde6a21d8a..fe72641fde 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2008-12-16 Esteban Sanchez + + * include/functions_html.php: Added missing documentation and fixed a + bit more. Added print_image() to prints an image HTML element. + 2008-12-12 Evi Vanoost * pandora_console/operation/agentes/datos_agente.php: Rewrite. Uses new diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 3945ec659d..28294b3d0e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -33,6 +33,8 @@ * @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). + * + * @return string HTML code if return parameter is true. */ function print_select ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $return = false, $multiple = false, $sort = true, $class = '', $disabled = false) { $output = "\n"; @@ -92,15 +94,20 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = * Prints an array of fields in a popup menu of a form based on a SQL query. * The first and second columns of the query will be used. * - * Based on choose_from_menu() from Moodle + * The element will have an id like: "password-$value". Based on choose_from_menu() from Moodle. * - * $sql SQL sentence, the first field will be the identifier of the option. + * @param string SQL sentence, the first field will be the identifier of the option. * The second field will be the shown value in the dropdown. - * $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 string Select form name + * @param string Current selected value. + * @param string Javascript onChange code. + * @param string Label when nothing is selected. + * @param string Value when nothing is selected + * @param bool Whether to return an output string or echo now (optional, echo by default). + * @param bool Whether to allow multiple selections or not. Single by default + * @param bool Whether to sort the options or not. Sorted by default. + * + * @return string HTML code if return parameter is true. */ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $return = false, $multiple = false, $sort = true) { @@ -119,14 +126,18 @@ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $noth /** * Render an input text element. Extended version, use print_input_text() to simplify. * - * @param string $name Input name. - * @param string $value Input value. - * @param string $alt Alternative HTML string. - * @param int $size Size of the input. - * @param int $maxlength Maximum length allowed. - * @param bool $disabled Disable the button (optional, button enabled by default). - * @param string $alt Alternative HTML string. - * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * @param string Input name. + * @param string Input value. + * @param string Input HTML id. + * @param string Alternative HTML string. + * @param int Size of the input. + * @param int Maximum length allowed. + * @param bool Disable the button (optional, button enabled by default). + * @param string Alternative HTML string. + * @param bool Whether to return an output string or echo now (optional, echo by default). + * @param bool Whether it is a password input or not. Not password by default. + * + * @return string HTML code if return parameter is true. */ function print_input_text_extended ($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return = false, $password = false) { static $idcounter = 0; @@ -169,15 +180,18 @@ function print_input_text_extended ($name, $value, $id, $alt, $size, $maxlength, /** * Render an input password element. + * + * The element will have an id like: "password-$name" * - * @param string $name Input name. - * @param string $value Input value. - * @param string $alt Alternative HTML string (optional). - * @param int $size Size of the input (optional). - * @param int $maxlength Maximum length allowed (optional). - * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * @param string Input name. + * @param string Input value. + * @param string Alternative HTML string (optional). + * @param int Size of the input (optional). + * @param int Maximum length allowed (optional). + * @param bool Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ - function print_input_password ($name, $value, $alt = '', $size = 50, $maxlength = 0, $return = false) { $output = print_input_text_extended ($name, $value, 'password-'.$name, $alt, $size, $maxlength, false, '', '', true, true); @@ -187,14 +201,18 @@ function print_input_password ($name, $value, $alt = '', $size = 50, $maxlength } /** - * Render an input text element. + * Render an input text element. + * + * The element will have an id like: "text-$name" * - * @param string $name Input name. - * @param string $value Input value. - * @param string $alt Alternative HTML string (optional). - * @param int $size Size of the input (optional). - * @param int $maxlength Maximum length allowed (optional). - * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * @param string Input name. + * @param string Input value. + * @param string Alternative HTML string (optional). + * @param int Size of the input (optional). + * @param int Maximum length allowed (optional). + * @param bool Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 0, $return = false) { $output = print_input_text_extended ($name, $value, 'text-'.$name, $alt, $size, $maxlength, false, '', '', true); @@ -206,12 +224,16 @@ function print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 0, /** * Render an input image element. + * + * The element will have an id like: "image-$name" * - * @param string $name Input name. - * @param string $src Image source. - * @param string $value Input value. - * @param string $style HTML style property. - * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * @param string Input name. + * @param string Image source. + * @param string Input value. + * @param string HTML style property. + * @param bool Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_input_image ($name, $src, $value, $style = '', $return = false) { $output = ''; @@ -223,10 +245,14 @@ function print_input_image ($name, $src, $value, $style = '', $return = false) { /** * Render an input hidden element. + * + * The element will have an id like: "hidden-$name" * - * @param string $name Input name. - * @param string $value Input value. - * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * @param string Input name. + * @param string Input value. + * @param bool Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_input_hidden ($name, $value, $return = false) { $output = ''; @@ -236,6 +262,19 @@ function print_input_hidden ($name, $value, $return = false) { echo $output; } +/** + * Render an submit input button element. + * + * The element will have an id like: "submit-$name" + * + * @param string Input label. + * @param string Input name. + * @param bool Whether to disable by default or not. Enabled by default. + * @param string Additional HTML attributes. + * @param bool Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. + */ function print_submit_button ($label = 'OK', $name = '', $disabled = false, $attributes = '', $return = false) { $output = ''; @@ -249,6 +288,19 @@ function print_submit_button ($label = 'OK', $name = '', $disabled = false, $att echo $output; } +/** + * Render an submit input button element. + * + * The element will have an id like: "button-$name" + * + * @param string Input label. + * @param string Input name. + * @param bool Whether to disable by default or not. Enabled by default. + * @param string Additional HTML attributes. + * @param bool Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. + */ function print_button ($label = 'OK', $name = '', $disabled = false, $script = '', $attributes = '', $return = false) { $output = ''; @@ -262,8 +314,18 @@ function print_button ($label = 'OK', $name = '', $disabled = false, $script = ' echo $output; } +/** + * Render an input textarea element. + * + * The element will have an id like: "textarea_$name" + * + * @param string Input name. + * @param string Input value. + * @param bool Whether to return an output string or echo now (optional, echo by default). * + * @return string HTML code if return parameter is true. + */ function print_textarea ($name, $rows, $columns, $value = '', $attributes = '', $return = false) { - $output = ''; @@ -295,6 +357,8 @@ function print_textarea ($name, $rows, $columns, $value = '', $attributes = '', * $table->id - Table ID (useful in JavaScript) * $table->headclass[] - An array of classes for each heading * @param bool $return whether to return an output string or echo now + * + * @return string HTML code if return parameter is true. */ function print_table (&$table, $return = false) { $output = ''; @@ -466,6 +530,8 @@ function print_table (&$table, $return = false) { * @param string $attributes Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_radio_button_extended ($name, $value, $label, $checkedvalue, $disabled, $script, $attributes, $return = false) { static $idcounter = 0; @@ -506,6 +572,8 @@ function print_radio_button_extended ($name, $value, $label, $checkedvalue, $dis * @param string $label Label to add after the radio button (optional). * @param string $checkedvalue Checked and selected value, the button will be selected if it matches $value (optional). * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_radio_button ($name, $value, $label = '', $checkedvalue = '', $return = false) { $output = print_radio_button_extended ($name, $value, $label, $checkedvalue, false, '', '', true); @@ -527,6 +595,8 @@ function print_radio_button ($name, $value, $label = '', $checkedvalue = '', $re * @param string $attributes Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_checkbox_extended ($name, $value, $checked, $disabled, $script, $attributes, $return = false) { static $idcounter = 0; @@ -557,6 +627,8 @@ function print_checkbox_extended ($name, $value, $checked, $disabled, $script, $ * @param string $value Input value. * @param string $checked Set the button to be marked (optional, unmarked by default). * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. */ function print_checkbox ($name, $value, $checked = false, $return = false) { $output = print_checkbox_extended ($name, $value, (bool) $checked, false, '', '', true); @@ -571,8 +643,8 @@ function print_checkbox ($name, $value, $checked = false, $return = false) { * * @param string $text Complete text to show in the tip * @param bool $return whether to return an output string or echo now - * - * @return + * + * @return string HTML code if return parameter is true. */ function print_help_tip ($text, $return = false) { $output = ' '.$text.''; @@ -582,11 +654,54 @@ function print_help_tip ($text, $return = false) { echo $output; } + +/** + * Prints an image HTML element. + * + * @param string Image source filename. + * @param array Array with optional HTML options to set. At this moment, the + * following options are supported: alt, style, title, width, height, class. + * + * @return string HTML code if return parameter is true. + */ +function print_image ($src, $return = false, $options = false) { + $output = ''.dame_nombre_real ($username).''; if ($return === false) { @@ -677,4 +792,4 @@ function print_username ($username, $return = false) { } return $string; } -?> \ No newline at end of file +?>