+++ /dev/null
-<?php\r
-/**\r
- * Smarty plugin\r
- * @package Smarty\r
- * @subpackage plugins\r
- */\r
-\r
-\r
-/**\r
- * Smarty {html_radios} function plugin\r
- *\r
- * File: function.html_radios.php<br>\r
- * Type: function<br>\r
- * Name: html_radios<br>\r
- * Date: 24.Feb.2003<br>\r
- * Purpose: Prints out a list of radio input types<br>\r
- * Input:<br>\r
- * - name (optional) - string default "radio"\r
- * - values (required) - array\r
- * - options (optional) - associative array\r
- * - checked (optional) - array default not set\r
- * - separator (optional) - ie <br> or \r
- * - output (optional) - without this one the buttons don't have names\r
- * Examples:\r
- * <pre>\r
- * {html_radios values=$ids output=$names}\r
- * {html_radios values=$ids name='box' separator='<br>' output=$names}\r
- * {html_radios values=$ids checked=$checked separator='<br>' output=$names}\r
- * </pre>\r
- * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}\r
- * (Smarty online manual)\r
- * @author Christopher Kvarme <christopher.kvarme@flashjab.com>\r
- * @author credits to Monte Ohrt <monte@ispi.net>\r
- * @version 1.0\r
- * @param array\r
- * @param Smarty\r
- * @return string\r
- * @uses smarty_function_escape_special_chars()\r
- */\r
-function smarty_function_html_radios($params, &$smarty)\r
-{\r
- require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');\r
- \r
- $name = 'radio';\r
- $values = null;\r
- $options = null;\r
- $selected = null;\r
- $separator = '';\r
- $labels = true;\r
- $output = null;\r
- $extra = '';\r
-\r
- foreach($params as $_key => $_val) {\r
- switch($_key) {\r
- case 'name':\r
- case 'separator':\r
- $$_key = (string)$_val;\r
- break;\r
-\r
- case 'checked':\r
- case 'selected':\r
- if(is_array($_val)) {\r
- $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);\r
- } else {\r
- $selected = (string)$_val;\r
- }\r
- break;\r
-\r
- case 'labels':\r
- $$_key = (bool)$_val;\r
- break;\r
-\r
- case 'options':\r
- $$_key = (array)$_val;\r
- break;\r
-\r
- case 'values':\r
- case 'output':\r
- $$_key = array_values((array)$_val);\r
- break;\r
-\r
- case 'radios':\r
- $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);\r
- $options = (array)$_val;\r
- break;\r
-\r
-\r
- default:\r
- if(!is_array($_val)) {\r
- $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';\r
- } else {\r
- $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);\r
- }\r
- break;\r
- }\r
- }\r
-\r
- if (!isset($options) && !isset($values))\r
- return ''; /* raise error here? */\r
-\r
- $_html_result = '';\r
-\r
- if (isset($options) && is_array($options)) {\r
-\r
- foreach ((array)$options as $_key=>$_val)\r
- $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);\r
-\r
- } else {\r
-\r
- foreach ((array)$values as $_i=>$_key) {\r
- $_val = isset($output[$_i]) ? $output[$_i] : '';\r
- $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);\r
- }\r
-\r
- }\r
-\r
- return $_html_result;\r
-\r
-}\r
-\r
-function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {\r
- $_output = '';\r
- if ($labels) $_output .= '<label>';\r
- $_output .= '<input type="radio" name="'\r
- . smarty_function_escape_special_chars($name) . '" value="'\r
- . smarty_function_escape_special_chars($value) . '"';\r
-\r
- if ($value==$selected) {\r
- $_output .= ' checked="checked"';\r
- }\r
- $_output .= $extra . ' />' . $output;\r
- if ($labels) $_output .= '</label>';\r
- $_output .= $separator . "\n";\r
-\r
- return $_output;\r
-}\r
-\r
-?>\r