cvs: smarty / NEWS /libs/plugins function.html_checkboxes.php function.html_radios.php
| From: | Messju Mohr | Date: | Fri, 21 Mar 2003 08:20:12 +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-487@lists.php.net to get a copy of this message | ||
messju Fri Mar 21 03:20:12 2003 EDT
Modified files:
/smarty NEWS
/smarty/libs/plugins function.html_checkboxes.php
function.html_radios.php
Log:
html_radios and html_checkboxes accept "selected" instead of "checked"
optionally now
Index: smarty/NEWS
diff -u smarty/NEWS:1.323 smarty/NEWS:1.324
--- smarty/NEWS:1.323 Fri Mar 21 03:17:44 2003
+++ smarty/NEWS Fri Mar 21 03:20:12 2003
@@ -1,3 +1,5 @@
+ - made html_radios and html_checkboxes accept "selected" instead
+ of "checked" optionally. (messju)
- made compile_id ignored in clear_cache, made order of
auto_file_name $cache_id.$compile_id again, applied the the new
variable-naming-scheme for cache_file_handing functions (messju)
Index: smarty/libs/plugins/function.html_checkboxes.php
diff -u smarty/libs/plugins/function.html_checkboxes.php:1.6
smarty/libs/plugins/function.html_checkboxes.php:1.7
--- smarty/libs/plugins/function.html_checkboxes.php:1.6 Wed Mar 19 17:58:23 2003
+++ smarty/libs/plugins/function.html_checkboxes.php Fri Mar 21 03:20:12 2003
@@ -29,7 +29,7 @@
$name = 'checkbox';
$values = null;
$options = null;
- $checked = null;
+ $selected = null;
$separator = '';
$output = null;
@@ -48,8 +48,12 @@
case 'values':
case 'output':
- case 'checked':
$$_key = array_values((array)$_val);
+ break;
+
+ case 'checked':
+ case 'selected':
+ $selected = array_values((array)$_val);
break;
case 'checkboxes':
@@ -66,19 +70,19 @@
if (!isset($options) && !isset($values))
return ''; /* raise error here? */
- settype($checked, 'array');
+ settype($selected, 'array');
$_html_result = '';
if (is_array($options)) {
foreach ($options as $_key=>$_val)
- $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $checked,
$extra, $separator);
+ $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected,
$extra, $separator);
} 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);
+ $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected,
$extra, $separator);
}
}
@@ -87,12 +91,12 @@
}
-function smarty_function_html_checkboxes_output($name, $value, $output, $checked, $extra,
$separator) {
+function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra,
$separator) {
$_output = '<input type="checkbox" name="'
. smarty_function_escape_special_chars($name) . '[]" value="'
. smarty_function_escape_special_chars($value) . '"';
- if (in_array($value, $checked)) {
+ if (in_array($value, $selected)) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output . $separator . "\n";
Index: smarty/libs/plugins/function.html_radios.php
diff -u smarty/libs/plugins/function.html_radios.php:1.11
smarty/libs/plugins/function.html_radios.php:1.12
--- smarty/libs/plugins/function.html_radios.php:1.11 Wed Mar 19 17:58:23 2003
+++ smarty/libs/plugins/function.html_radios.php Fri Mar 21 03:20:12 2003
@@ -29,7 +29,7 @@
$name = 'radio';
$values = null;
$options = null;
- $checked = null;
+ $selected = null;
$separator = '';
$output = null;
$extra = '';
@@ -38,11 +38,15 @@
switch($_key) {
case 'name':
case 'separator':
+ $$_key = (string)$_val;
+ break;
+
case 'checked':
+ case 'selected':
if(is_array($_val)) {
- $smarty->trigger_error('html_radios: the "checked" attribute cannot be an
array', E_USER_WARNING);
+ $smarty->trigger_error('html_radios: the "' . $_key . '" attribute
cannot be an array', E_USER_WARNING);
} else {
- $$_key = (string)$_val;
+ $selected = (string)$_val;
}
break;
@@ -75,13 +79,13 @@
if (isset($options) && is_array($options)) {
foreach ((array)$options as $_key=>$_val)
- $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra,
$separator);
+ $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra,
$separator);
} 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, $selected, $extra,
$separator);
}
}
@@ -90,12 +94,12 @@
}
-function smarty_function_html_radios_output($name, $value, $output, $checked, $extra, $separator) {
+function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator)
{
$_output = '<input type="radio" name="'
. smarty_function_escape_special_chars($name) . '" value="'
. smarty_function_escape_special_chars($value) . '"';
- if ($value==$checked) {
+ if ($value==$selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output . $separator . "\n";