removed tabs, fixed indentiation

This commit is contained in:
messju
2003-12-09 19:30:29 +00:00
parent a4c032295e
commit 37575a1982
3 changed files with 212 additions and 212 deletions

View File

@@ -39,97 +39,97 @@
*/ */
function smarty_function_html_checkboxes($params, &$smarty) function smarty_function_html_checkboxes($params, &$smarty)
{ {
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
$name = 'checkbox'; $name = 'checkbox';
$values = null; $values = null;
$options = null; $options = null;
$selected = null; $selected = null;
$separator = ''; $separator = '';
$labels = true; $labels = true;
$output = null; $output = null;
$extra = '';
foreach($params as $_key => $_val) {
switch($_key) {
case 'name':
case 'separator':
$$_key = $_val;
break;
case 'labels': $extra = '';
$$_key = (bool)$_val;
break;
case 'options': foreach($params as $_key => $_val) {
$$_key = (array)$_val; switch($_key) {
break; case 'name':
case 'separator':
$$_key = $_val;
break;
case 'values': case 'labels':
case 'output': $$_key = (bool)$_val;
$$_key = array_values((array)$_val); break;
break;
case 'checked': case 'options':
case 'selected': $$_key = (array)$_val;
$selected = array_values((array)$_val); break;
break;
case 'checkboxes': case 'values':
$smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); case 'output':
$options = (array)$_val; $$_key = array_values((array)$_val);
break; break;
default: case 'checked':
if(!is_array($_val)) { case 'selected':
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; $selected = array_values((array)$_val);
} else { break;
$smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (!isset($options) && !isset($values)) case 'checkboxes':
return ''; /* raise error here? */ $smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
$options = (array)$_val;
break;
settype($selected, 'array'); default:
$_html_result = ''; if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
$smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (is_array($options)) { if (!isset($options) && !isset($values))
return ''; /* raise error here? */
foreach ($options as $_key=>$_val) settype($selected, 'array');
$_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); $_html_result = '';
if (is_array($options)) {
foreach ($options as $_key=>$_val)
$_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} 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, $selected, $extra, $separator, $labels); $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} }
} }
return $_html_result; return $_html_result;
} }
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
$_output = ''; $_output = '';
if ($labels) $_output .= '<label>'; if ($labels) $_output .= '<label>';
$_output .= '<input type="checkbox" name="' $_output .= '<input type="checkbox" name="'
. smarty_function_escape_special_chars($name) . '[]" value="' . smarty_function_escape_special_chars($name) . '[]" value="'
. smarty_function_escape_special_chars($value) . '"'; . smarty_function_escape_special_chars($value) . '"';
if (in_array($value, $selected)) { if (in_array($value, $selected)) {
$_output .= ' checked="checked"'; $_output .= ' checked="checked"';
} }
$_output .= $extra . ' />' . $output; $_output .= $extra . ' />' . $output;
if ($labels) $_output .= '</label>'; if ($labels) $_output .= '</label>';
$_output .= $separator . "\n"; $_output .= $separator . "\n";
return $_output; return $_output;
} }
?> ?>

View File

@@ -28,89 +28,89 @@
*/ */
function smarty_function_html_options($params, &$smarty) function smarty_function_html_options($params, &$smarty)
{ {
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
$name = null;
$values = null;
$options = null;
$selected = array();
$output = null;
$extra = '';
foreach($params as $_key => $_val) {
switch($_key) {
case 'name':
$$_key = (string)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'selected':
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
default:
if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
$smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (!isset($options) && !isset($values))
return ''; /* raise error here? */
$_html_result = '';
if (is_array($options)) {
foreach ($options as $_key=>$_val)
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
} else { $name = null;
$values = null;
$options = null;
$selected = array();
$output = null;
$extra = '';
foreach($params as $_key => $_val) {
switch($_key) {
case 'name':
$$_key = (string)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'selected':
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
default:
if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
$smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
foreach ((array)$values as $_i=>$_key) { if (!isset($options) && !isset($values))
$_val = isset($output[$_i]) ? $output[$_i] : ''; return ''; /* raise error here? */
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
}
} $_html_result = '';
if(!empty($name)) { if (is_array($options)) {
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
} foreach ($options as $_key=>$_val)
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
return $_html_result; } else {
foreach ((array)$values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
}
}
if(!empty($name)) {
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
}
return $_html_result;
} }
function smarty_function_html_options_optoutput($key, $value, $selected) { function smarty_function_html_options_optoutput($key, $value, $selected) {
if(!is_array($value)) { if(!is_array($value)) {
$_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' . $_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
smarty_function_escape_special_chars($key) . '"'; smarty_function_escape_special_chars($key) . '"';
if (in_array($key, $selected)) if (in_array($key, $selected))
$_html_result .= ' selected="selected"'; $_html_result .= ' selected="selected"';
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n"; $_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
} else { } else {
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected); $_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
} }
return $_html_result; return $_html_result;
} }
function smarty_function_html_options_optgroup($key, $values, $selected) { function smarty_function_html_options_optgroup($key, $values, $selected) {
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected); $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
} }
$optgroup_html .= "</optgroup>\n"; $optgroup_html .= "</optgroup>\n";
return $optgroup_html; return $optgroup_html;
} }
/* vim: set expandtab: */ /* vim: set expandtab: */

View File

@@ -39,100 +39,100 @@
*/ */
function smarty_function_html_radios($params, &$smarty) function smarty_function_html_radios($params, &$smarty)
{ {
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
$name = 'radio'; $name = 'radio';
$values = null; $values = null;
$options = null; $options = null;
$selected = null; $selected = null;
$separator = ''; $separator = '';
$labels = true; $labels = true;
$output = null; $output = null;
$extra = ''; $extra = '';
foreach($params as $_key => $_val) { foreach($params as $_key => $_val) {
switch($_key) { switch($_key) {
case 'name': case 'name':
case 'separator': case 'separator':
$$_key = (string)$_val; $$_key = (string)$_val;
break; break;
case 'checked': case 'checked':
case 'selected': case 'selected':
if(is_array($_val)) { if(is_array($_val)) {
$smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
} else { } else {
$selected = (string)$_val; $selected = (string)$_val;
} }
break; break;
case 'labels': case 'labels':
$$_key = (bool)$_val; $$_key = (bool)$_val;
break; break;
case 'options': case 'options':
$$_key = (array)$_val; $$_key = (array)$_val;
break; break;
case 'values': case 'values':
case 'output': case 'output':
$$_key = array_values((array)$_val); $$_key = array_values((array)$_val);
break; break;
case 'radios': case 'radios':
$smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING); $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
$options = (array)$_val; $options = (array)$_val;
break; break;
default: default:
if(!is_array($_val)) { if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else { } else {
$smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
} }
break; break;
} }
} }
if (!isset($options) && !isset($values)) if (!isset($options) && !isset($values))
return ''; /* raise error here? */ return ''; /* raise error here? */
$_html_result = ''; $_html_result = '';
if (isset($options) && is_array($options)) { if (isset($options) && is_array($options)) {
foreach ((array)$options as $_key=>$_val) foreach ((array)$options as $_key=>$_val)
$_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} else { } else {
foreach ((array)$values as $_i=>$_key) { foreach ((array)$values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : ''; $_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} }
} }
return $_html_result; return $_html_result;
} }
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) { function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {
$_output = ''; $_output = '';
if ($labels) $_output .= '<label>'; if ($labels) $_output .= '<label>';
$_output .= '<input type="radio" name="' $_output .= '<input type="radio" name="'
. smarty_function_escape_special_chars($name) . '" value="' . smarty_function_escape_special_chars($name) . '" value="'
. smarty_function_escape_special_chars($value) . '"'; . smarty_function_escape_special_chars($value) . '"';
if ($value==$selected) { if ($value==$selected) {
$_output .= ' checked="checked"'; $_output .= ' checked="checked"';
} }
$_output .= $extra . ' />' . $output; $_output .= $extra . ' />' . $output;
if ($labels) $_output .= '</label>'; if ($labels) $_output .= '</label>';
$_output .= $separator . "\n"; $_output .= $separator . "\n";
return $_output; return $_output;
} }
?> ?>