cvs: smarty / NEWS /libs/plugins function.html_checkboxes.php function.html_radios.php
| From: | Messju Mohr | Date: | Tue, 18 Mar 2003 08:59:00 +0000 |
| Subject: | cvs: smarty / NEWS /libs/plugins function.html_checkboxes.php function.html_radios.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-470@lists.php.net to get a copy of this message | ||
messju Tue Mar 18 03:59:00 2003 EDT
Modified files:
/smarty NEWS
/smarty/libs/plugins function.html_checkboxes.php
function.html_radios.php
Log:
renamed "checkbox" and "radios" to "options" in {html_checkboxes}
and {html_radios}
Index: smarty/NEWS diff -u smarty/NEWS:1.314 smarty/NEWS:1.315 --- smarty/NEWS:1.314 Mon Mar 17 19:01:41 2003 +++ smarty/NEWS Tue Mar 18 03:59:00 2003 @@ -1,3 +1,7 @@ + - html_checkboxes now expect the options as attribute "options" instead + of "checkboxes. html_radios expect "options" instead of "radios". + cleaned up indentiation (messju) + - fixed too greedy str_replace in trimwhitespace outputfilter (messju) - html_checkboxes and html_radios passthru all unknown paramters now additionally their output is now XHTML compliant (messju) - html_options passthru all unknown paramters now (messju) Index: smarty/libs/plugins/function.html_checkboxes.php diff -u smarty/libs/plugins/function.html_checkboxes.php:1.4 smarty/libs/plugins/function.html_checkboxes.php:1.5 --- smarty/libs/plugins/function.html_checkboxes.php:1.4 Mon Mar 17 19:01:41 2003 +++ smarty/libs/plugins/function.html_checkboxes.php Tue Mar 18 03:59:00 2003 @@ -5,13 +5,13 @@ * ------------------------------------------------------------- * File: function.html_checkboxes.php * Type: function - * Name: html_checkboxes + * Name: html_checkboxes * Version: 1.0 * Date: 24.Feb.2003 * Purpose: Prints out a list of checkbox input types * Input: name (optional) - string default "checkbox" * values (required) - array - * checkboxes (optional) - associative array + * options (optional) - associative array * checked (optional) - array default not set * separator (optional) - ie <br> or * output (optional) - without this one the buttons don't have names @@ -25,74 +25,79 @@ function smarty_function_html_checkboxes($params, &$smarty) { require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); - + $name = 'checkbox'; $values = null; - $checkboxes = null; + $options = null; $checked = null; $separator = ''; $output = null; - + $extra = ''; - - foreach($params as $_key => $_val) { + + foreach($params as $_key => $_val) { switch($_key) { case 'name': case 'separator': - $$_key = $_val; - break; + $$_key = $_val; + break; - case 'checkboxes': - $$_key = (array)$_val; - break; + case 'options': + $$_key = (array)$_val; + break; case 'values': case 'output': case 'checked': - $$_key = array_values((array)$_val); - break; + $$_key = array_values((array)$_val); + break; + + case 'checkboxes': + $smarty->trigger_error('the use of the "checkboxes"-attribute is deprecated. use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; default: - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - break; + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"'; + break; } } - if (!isset($checkboxes) && !isset($values)) + if (!isset($options) && !isset($values)) return ''; /* raise error here? */ settype($checked, 'array'); $_html_result = ''; - if (is_array($checkboxes)) { + if (is_array($options)) { + + foreach ($options as $_key=>$_val) + $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); - foreach ($checkboxes as $_key=>$_val) - $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); - - } else { + } else { foreach ($values as $_i=>$_key) { - $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); + $_val = isset($output[$_i]) ? $output[$_i] : ''; + $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); } } return $_html_result; - + } function smarty_function_html_checkboxes_output($name, $value, $output, $checked, $extra, $separator) { - $_output = '<input type="checkbox" name="' - . smarty_function_escape_special_chars($name) . '[]" value="' + $_output = '<input type="checkbox" name="' + . smarty_function_escape_special_chars($name) . '[]" value="' . smarty_function_escape_special_chars($value) . '"'; - + if (in_array($value, $checked)) { $_output .= ' checked="checked"'; } $_output .= $extra . ' />' . $output . $separator . "\n"; - - return $_output; + + return $_output; } ?> Index: smarty/libs/plugins/function.html_radios.php diff -u smarty/libs/plugins/function.html_radios.php:1.7 smarty/libs/plugins/function.html_radios.php:1.8 --- smarty/libs/plugins/function.html_radios.php:1.7 Mon Mar 17 19:01:41 2003 +++ smarty/libs/plugins/function.html_radios.php Tue Mar 18 03:59:00 2003 @@ -5,13 +5,13 @@ * ------------------------------------------------------------- * File: function.html_radios.php * Type: function - * Name: html_radios + * Name: html_radios * Version: 1.0 * Date: 24.Feb.2003 * Purpose: Prints out a list of radio input types * Input: name (optional) - string default "radio" * values (required) - array - * radios (optional) - associative array + * options (optional) - associative array * checked (optional) - array default not set * separator (optional) - ie <br> or * output (optional) - without this one the buttons don't have names @@ -28,13 +28,13 @@ $name = 'radio'; $values = null; - $radios = null; + $options = null; $checked = null; $separator = ''; $output = null; $extra = ''; - - foreach($params as $_key => $_val) { + + foreach($params as $_key => $_val) { switch($_key) { case 'name': case 'separator': @@ -42,55 +42,61 @@ $$_key = (string)$_val; break; - case 'radios': + case 'options': $$_key = (array)$_val; break; case 'values': case 'output': - $$_key = array_values((array)$_val); + $$_key = array_values((array)$_val); break; + case 'radios': + $smarty->trigger_error('the use of the "radios"-attribute is deprecated. use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; + + default: - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - break; + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"'; + break; } } - if (!isset($radios) && !isset($values)) + if (!isset($options) && !isset($values)) return ''; /* raise error here? */ $_html_result = ''; - if (isset($radios) && is_array($radios)) { + if (isset($options) && is_array($options)) { - foreach ((array)$radios as $_key=>$_val) + foreach ((array)$options as $_key=>$_val) $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator); - - } else { + + } else { foreach ((array)$values as $_i=>$_key) { $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator); + $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator); } } return $_html_result; - + } function smarty_function_html_radios_output($name, $value, $output, $checked, $extra, $separator) { - $_output = '<input type="radio" name="' - . smarty_function_escape_special_chars($name) . '" value="' + $_output = '<input type="radio" name="' + . smarty_function_escape_special_chars($name) . '" value="' . smarty_function_escape_special_chars($value) . '"'; if ($value==$checked) { $_output .= ' checked="checked"'; } $_output .= $extra . ' />' . $output . $separator . "\n"; - - return $_output; + + return $_output; } ?>
Index: smarty/NEWS diff -u smarty/NEWS:1.314 smarty/NEWS:1.315 --- smarty/NEWS:1.314 Mon Mar 17 19:01:41 2003 +++ smarty/NEWS Tue Mar 18 03:59:00 2003 @@ -1,3 +1,7 @@ + - html_checkboxes now expect the options as attribute "options" instead + of "checkboxes. html_radios expect "options" instead of "radios". + cleaned up indentiation (messju) + - fixed too greedy str_replace in trimwhitespace outputfilter (messju) - html_checkboxes and html_radios passthru all unknown paramters now additionally their output is now XHTML compliant (messju) - html_options passthru all unknown paramters now (messju) Index: smarty/libs/plugins/function.html_checkboxes.php diff -u smarty/libs/plugins/function.html_checkboxes.php:1.4 smarty/libs/plugins/function.html_checkboxes.php:1.5 --- smarty/libs/plugins/function.html_checkboxes.php:1.4 Mon Mar 17 19:01:41 2003 +++ smarty/libs/plugins/function.html_checkboxes.php Tue Mar 18 03:59:00 2003 @@ -5,13 +5,13 @@ * ------------------------------------------------------------- * File: function.html_checkboxes.php * Type: function - * Name: html_checkboxes + * Name: html_checkboxes * Version: 1.0 * Date: 24.Feb.2003 * Purpose: Prints out a list of checkbox input types * Input: name (optional) - string default "checkbox" * values (required) - array - * checkboxes (optional) - associative array + * options (optional) - associative array * checked (optional) - array default not set * separator (optional) - ie <br> or * output (optional) - without this one the buttons don't have names @@ -25,74 +25,79 @@ function smarty_function_html_checkboxes($params, &$smarty) { require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); - + $name = 'checkbox'; $values = null; - $checkboxes = null; + $options = null; $checked = null; $separator = ''; $output = null; - + $extra = ''; - - foreach($params as $_key => $_val) { + + foreach($params as $_key => $_val) { switch($_key) { case 'name': case 'separator': - $$_key = $_val; - break; + $$_key = $_val; + break; - case 'checkboxes': - $$_key = (array)$_val; - break; + case 'options': + $$_key = (array)$_val; + break; case 'values': case 'output': case 'checked': - $$_key = array_values((array)$_val); - break; + $$_key = array_values((array)$_val); + break; + + case 'checkboxes': + $smarty->trigger_error('the use of the "checkboxes"-attribute is deprecated. use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; default: - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - break; + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"'; + break; } } - if (!isset($checkboxes) && !isset($values)) + if (!isset($options) && !isset($values)) return ''; /* raise error here? */ settype($checked, 'array'); $_html_result = ''; - if (is_array($checkboxes)) { + if (is_array($options)) { + + foreach ($options as $_key=>$_val) + $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); - foreach ($checkboxes as $_key=>$_val) - $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); - - } else { + } else { foreach ($values as $_i=>$_key) { - $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); + $_val = isset($output[$_i]) ? $output[$_i] : ''; + $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked, $extra, $separator); } } return $_html_result; - + } function smarty_function_html_checkboxes_output($name, $value, $output, $checked, $extra, $separator) { - $_output = '<input type="checkbox" name="' - . smarty_function_escape_special_chars($name) . '[]" value="' + $_output = '<input type="checkbox" name="' + . smarty_function_escape_special_chars($name) . '[]" value="' . smarty_function_escape_special_chars($value) . '"'; - + if (in_array($value, $checked)) { $_output .= ' checked="checked"'; } $_output .= $extra . ' />' . $output . $separator . "\n"; - - return $_output; + + return $_output; } ?> Index: smarty/libs/plugins/function.html_radios.php diff -u smarty/libs/plugins/function.html_radios.php:1.7 smarty/libs/plugins/function.html_radios.php:1.8 --- smarty/libs/plugins/function.html_radios.php:1.7 Mon Mar 17 19:01:41 2003 +++ smarty/libs/plugins/function.html_radios.php Tue Mar 18 03:59:00 2003 @@ -5,13 +5,13 @@ * ------------------------------------------------------------- * File: function.html_radios.php * Type: function - * Name: html_radios + * Name: html_radios * Version: 1.0 * Date: 24.Feb.2003 * Purpose: Prints out a list of radio input types * Input: name (optional) - string default "radio" * values (required) - array - * radios (optional) - associative array + * options (optional) - associative array * checked (optional) - array default not set * separator (optional) - ie <br> or * output (optional) - without this one the buttons don't have names @@ -28,13 +28,13 @@ $name = 'radio'; $values = null; - $radios = null; + $options = null; $checked = null; $separator = ''; $output = null; $extra = ''; - - foreach($params as $_key => $_val) { + + foreach($params as $_key => $_val) { switch($_key) { case 'name': case 'separator': @@ -42,55 +42,61 @@ $$_key = (string)$_val; break; - case 'radios': + case 'options': $$_key = (array)$_val; break; case 'values': case 'output': - $$_key = array_values((array)$_val); + $$_key = array_values((array)$_val); break; + case 'radios': + $smarty->trigger_error('the use of the "radios"-attribute is deprecated. use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; + + default: - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - break; + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"'; + break; } } - if (!isset($radios) && !isset($values)) + if (!isset($options) && !isset($values)) return ''; /* raise error here? */ $_html_result = ''; - if (isset($radios) && is_array($radios)) { + if (isset($options) && is_array($options)) { - foreach ((array)$radios as $_key=>$_val) + foreach ((array)$options as $_key=>$_val) $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator); - - } else { + + } else { foreach ((array)$values as $_i=>$_key) { $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator); + $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator); } } return $_html_result; - + } function smarty_function_html_radios_output($name, $value, $output, $checked, $extra, $separator) { - $_output = '<input type="radio" name="' - . smarty_function_escape_special_chars($name) . '" value="' + $_output = '<input type="radio" name="' + . smarty_function_escape_special_chars($name) . '" value="' . smarty_function_escape_special_chars($value) . '"'; if ($value==$checked) { $_output .= ' checked="checked"'; } $_output .= $extra . ' />' . $output . $separator . "\n"; - - return $_output; + + return $_output; } ?>