From 9ca56c40ea367143070ea9814a1453dada8f71ed Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Mon, 10 Dec 2018 09:20:06 +0100 Subject: [PATCH] Added a new color input and a debug function Former-commit-id: 657724102e35c49465119d2ef75e3363d4d0d878 --- pandora_console/include/functions_html.php | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 932e8a3457..1a589306d6 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -97,6 +97,15 @@ function hd ($var, $file = '', $oneline = false) { html_debug_print ($var, $file, $oneline); } +function debug () { + $args_num = func_num_args(); + $arg_list = func_get_args(); + + for ($i = 0; $i < $args_num; $i++) { + html_debug_print($arg_list[$i], true); + } +} + function html_f2str($function, $params) { ob_start(); @@ -1338,6 +1347,36 @@ function html_print_input_hidden_extended($name, $value, $id, $return = false, $ echo $output; } +/** + * Render a color input element. + * + * The element will have an id like: "hidden-$name" + * + * @param string $name Input name. + * @param int $value Input value. Decimal representation of the color's hexadecimal value. + * @param string $class Set the class of input. + * @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 html_print_input_color ($name, $value, $class = false, $return = false) { + $attr_type = 'type="color"'; + $attr_id = 'id="color-' . htmlspecialchars($name, ENT_QUOTES) . '"'; + $attr_name = 'name="' . htmlspecialchars($name, ENT_QUOTES) . '"'; + $attr_value = 'value="' . htmlspecialchars($value, ENT_QUOTES) . '"'; + $attr_class = 'class="' . ($class !== false ? htmlspecialchars($class, ENT_QUOTES) : "") . '"'; + + $output = ''; + + if ($return) return $output; + echo $output; +} + /** * Render an submit input button element. *