MDL-20638 importing latest smarty 2.6.26

This commit is contained in:
Petr Skoda
2009-11-17 08:45:54 +00:00
parent 8bcf4b5749
commit 5953ae1d30
69 changed files with 929 additions and 517 deletions
+13 -7
View File
@@ -48,6 +48,7 @@ function smarty_function_html_radios($params, &$smarty)
$selected = null;
$separator = '';
$labels = true;
$label_ids = false;
$output = null;
$extra = '';
@@ -68,6 +69,7 @@ function smarty_function_html_radios($params, &$smarty)
break;
case 'labels':
case 'label_ids':
$$_key = (bool)$_val;
break;
@@ -106,13 +108,13 @@ function smarty_function_html_radios($params, &$smarty)
if (isset($options)) {
foreach ($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, $label_ids);
} else {
foreach ($values as $_i=>$_key) {
$_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, $label_ids);
}
}
@@ -125,19 +127,23 @@ function smarty_function_html_radios($params, &$smarty)
}
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, $label_ids) {
$_output = '';
if ($labels) {
$_id = smarty_function_escape_special_chars($name . '_' . $value);
$_output .= '<label for="' . $_id . '">';
if($label_ids) {
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
$_output .= '<label for="' . $_id . '">';
} else {
$_output .= '<label>';
}
}
$_output .= '<input type="radio" name="'
. smarty_function_escape_special_chars($name) . '" value="'
. smarty_function_escape_special_chars($value) . '"';
if ($labels) $_output .= ' id="' . $_id . '"';
if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
if ($value==$selected) {
if ((string)$value==$selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;