*/
/**
* Smarty {html_checkbox} function plugin
*
* File: function.html_checkbox.php
* Type: function
* Name: html_checkbox
* Purpose: Prints out a checkbox input
* Input:
* - name (optional) - string default "checkbox"
* - value (required) - string
* - checked (optional) - array default not set
* - id (optional) - checkbox id (name is default)
* - label (optional) - string for checkbox label
* Examples:
*
* {html_checkbox value=1 name=horst}
* {html_checkbox value=1 name=horst label="Select Horst"}
*
* @return string
* @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_checkbox($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$name = 'checkbox';
$value = null;
$selected = null;
$label = null;
$extra = '';
foreach($params as $_key => $_val) {
switch($_key) {
case 'name':
case 'id':
case 'value':
case 'label':
$$_key = $_val;
break;
case 'checked':
case 'selected':
$selected = (bool)$_val;
break;
default:
if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
trigger_error("html_checkbox: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
// assign default id
if (empty($id)) $id = $name;
$_output = '';
if ($label) $_output .= '