From 878d8ab5c5531b6c121a253dd4281e89693f5aa8 Mon Sep 17 00:00:00 2001 From: mohrt Date: Mon, 24 Feb 2003 15:36:34 +0000 Subject: [PATCH] added html_radios to distribution --- NEWS | 1 + libs/plugins/function.html_radios.php | 68 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 libs/plugins/function.html_radios.php diff --git a/NEWS b/NEWS index 2b065e93..1346c641 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - added html_radios to distribution (Christopher Kvarme, Monte) - fixed string_format modifier args (wrong order) (Paul Lockaby, Monte) - use tmp file for file writes, avoid file lock race (Monte) diff --git a/libs/plugins/function.html_radios.php b/libs/plugins/function.html_radios.php new file mode 100644 index 00000000..a6696b96 --- /dev/null +++ b/libs/plugins/function.html_radios.php @@ -0,0 +1,68 @@ + or   + * output[optional] -without this one the buttons don't have names + * Author: Christopher Kvarme + * --------------------------------------------------------------------------------------------- + */ +function smarty_function_html_radios($params, &$smarty) +{ + extract($params); + + $html_result = ''; + + settype($checked, 'array'); + if (isset($radios)) { + settype($radios, 'array'); + foreach ($radios as $key => $value) { + $html_result .= smarty_function_html_radios_optoutput($key, $value, $checked); + } + } else { + settype($output, 'array'); + settype($values, 'array'); + for ($i = 0, $for_max = count($output); $i < $for_max; $i++) { + if ($i < count($values)) { + $html_result .= smarty_function_html_radios_optoutput($values[$i], $output[$i], $checked, $name, $separator); + } else { + $html_result .= smarty_function_html_radios_optoutput($output[$i], $output[$i], $checked, $name, $separator); + } + } + } + + return $html_result; +} + +function smarty_function_html_radios_optoutput($key, $value, $checked, $name, $separator) { + if(!is_array($value)) { + $html_result = '' . "\n"; + foreach ($values as $key => $value) { + $optgroup_html .= smarty_function_html_radios_optoutput($key, $value, $checked); + } + $optgroup_html .= "\n"; + return $optgroup_html; +} + +/* vim: set expandtab: */ + +?>