Upgraded to latest version of Smarty 2.6.9
This commit is contained in:
@@ -9,28 +9,29 @@
|
||||
/**
|
||||
* Smarty {html_checkboxes} function plugin
|
||||
*
|
||||
* File: function.html_checkboxes.php<br />
|
||||
* Type: function<br />
|
||||
* Name: html_checkboxes<br />
|
||||
* Date: 24.Feb.2003<br />
|
||||
* Purpose: Prints out a list of checkbox input types<br />
|
||||
* Input:<br />
|
||||
* File: function.html_checkboxes.php<br>
|
||||
* Type: function<br>
|
||||
* Name: html_checkboxes<br>
|
||||
* Date: 24.Feb.2003<br>
|
||||
* Purpose: Prints out a list of checkbox input types<br>
|
||||
* Input:<br>
|
||||
* - name (optional) - string default "checkbox"
|
||||
* - values (required) - 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
|
||||
* - separator (optional) - ie <br> or
|
||||
* - output (optional) - the output next to each checkbox
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* Examples:
|
||||
* <pre>
|
||||
* {html_checkboxes values=$ids output=$names}
|
||||
* {html_checkboxes values=$ids name='box' separator='<br />' output=$names}
|
||||
* {html_checkboxes values=$ids checked=$checked separator='<br />' output=$names}
|
||||
* {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
|
||||
* </pre>
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <[email protected]>
|
||||
* @author credits to Monte Ohrt <monte@ispi.net>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
* @param array
|
||||
* @param Smarty
|
||||
@@ -81,6 +82,9 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
|
||||
case 'assign':
|
||||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
@@ -95,23 +99,27 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
||||
return ''; /* raise error here? */
|
||||
|
||||
settype($selected, 'array');
|
||||
$_html_result = '';
|
||||
$_html_result = array();
|
||||
|
||||
if (is_array($options)) {
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
$_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
|
||||
|
||||
} else {
|
||||
foreach ($values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
if(!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n",$_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,7 +135,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
$_output .= $separator . "\n";
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user