mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
renamed "checkbox" and "radios" to "options" in {html_checkboxes} and {html_radios}
This commit is contained in:
4
NEWS
4
NEWS
@@ -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
|
- html_checkboxes and html_radios passthru all unknown paramters now
|
||||||
additionally their output is now XHTML compliant (messju)
|
additionally their output is now XHTML compliant (messju)
|
||||||
- html_options passthru all unknown paramters now (messju)
|
- html_options passthru all unknown paramters now (messju)
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Purpose: Prints out a list of checkbox input types
|
* Purpose: Prints out a list of checkbox input types
|
||||||
* Input: name (optional) - string default "checkbox"
|
* Input: name (optional) - string default "checkbox"
|
||||||
* values (required) - array
|
* values (required) - array
|
||||||
* checkboxes (optional) - associative array
|
* options (optional) - associative array
|
||||||
* checked (optional) - array default not set
|
* checked (optional) - array default not set
|
||||||
* separator (optional) - ie <br> or
|
* separator (optional) - ie <br> or
|
||||||
* output (optional) - without this one the buttons don't have names
|
* output (optional) - without this one the buttons don't have names
|
||||||
@@ -28,7 +28,7 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||||||
|
|
||||||
$name = 'checkbox';
|
$name = 'checkbox';
|
||||||
$values = null;
|
$values = null;
|
||||||
$checkboxes = null;
|
$options = null;
|
||||||
$checked = null;
|
$checked = null;
|
||||||
$separator = '';
|
$separator = '';
|
||||||
$output = null;
|
$output = null;
|
||||||
@@ -39,41 +39,46 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||||||
switch($_key) {
|
switch($_key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
case 'separator':
|
case 'separator':
|
||||||
$$_key = $_val;
|
$$_key = $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'checkboxes':
|
case 'options':
|
||||||
$$_key = (array)$_val;
|
$$_key = (array)$_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'values':
|
case 'values':
|
||||||
case 'output':
|
case 'output':
|
||||||
case 'checked':
|
case 'checked':
|
||||||
$$_key = array_values((array)$_val);
|
$$_key = array_values((array)$_val);
|
||||||
break;
|
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:
|
default:
|
||||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($checkboxes) && !isset($values))
|
if (!isset($options) && !isset($values))
|
||||||
return ''; /* raise error here? */
|
return ''; /* raise error here? */
|
||||||
|
|
||||||
settype($checked, 'array');
|
settype($checked, 'array');
|
||||||
$_html_result = '';
|
$_html_result = '';
|
||||||
|
|
||||||
if (is_array($checkboxes)) {
|
if (is_array($options)) {
|
||||||
|
|
||||||
foreach ($checkboxes as $_key=>$_val)
|
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, $checked, $extra, $separator);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
foreach ($values as $_i=>$_key) {
|
foreach ($values as $_i=>$_key) {
|
||||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
$_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, $checked, $extra, $separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Purpose: Prints out a list of radio input types
|
* Purpose: Prints out a list of radio input types
|
||||||
* Input: name (optional) - string default "radio"
|
* Input: name (optional) - string default "radio"
|
||||||
* values (required) - array
|
* values (required) - array
|
||||||
* radios (optional) - associative array
|
* options (optional) - associative array
|
||||||
* checked (optional) - array default not set
|
* checked (optional) - array default not set
|
||||||
* separator (optional) - ie <br> or
|
* separator (optional) - ie <br> or
|
||||||
* output (optional) - without this one the buttons don't have names
|
* output (optional) - without this one the buttons don't have names
|
||||||
@@ -28,7 +28,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
|
|
||||||
$name = 'radio';
|
$name = 'radio';
|
||||||
$values = null;
|
$values = null;
|
||||||
$radios = null;
|
$options = null;
|
||||||
$checked = null;
|
$checked = null;
|
||||||
$separator = '';
|
$separator = '';
|
||||||
$output = null;
|
$output = null;
|
||||||
@@ -42,7 +42,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
$$_key = (string)$_val;
|
$$_key = (string)$_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'radios':
|
case 'options':
|
||||||
$$_key = (array)$_val;
|
$$_key = (array)$_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -51,20 +51,26 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
$$_key = array_values((array)$_val);
|
$$_key = array_values((array)$_val);
|
||||||
break;
|
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:
|
default:
|
||||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($radios) && !isset($values))
|
if (!isset($options) && !isset($values))
|
||||||
return ''; /* raise error here? */
|
return ''; /* raise error here? */
|
||||||
|
|
||||||
$_html_result = '';
|
$_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);
|
$_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $checked, $extra, $separator);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user