From b98c95a9041efe07e8209be62306d99605560f03 Mon Sep 17 00:00:00 2001 From: mohrt Date: Fri, 8 Jul 2005 13:36:34 +0000 Subject: [PATCH] added passthru attribute feature to html_select_date --- NEWS | 2 ++ libs/plugins/function.html_select_date.php | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 79954545..7cc3a18d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - add passthru attribute feature to html_select_date (kills, + monte) - add "middle" parameter to truncate (monte) - make form input label ids optional (monte) - add error message for empty if/elseif statements (eykanal, diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php index 243dbc9e..d8c334ae 100644 --- a/libs/plugins/function.html_select_date.php +++ b/libs/plugins/function.html_select_date.php @@ -34,6 +34,7 @@ */ function smarty_function_html_select_date($params, &$smarty) { + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); require_once $smarty->_get_plugin_filepath('shared','make_timestamp'); require_once $smarty->_get_plugin_filepath('function','html_options'); /* Default values. */ @@ -78,6 +79,7 @@ function smarty_function_html_select_date($params, &$smarty) $day_empty = null; $month_empty = null; $year_empty = null; + $extra_attrs = ''; foreach ($params as $_key=>$_value) { switch ($_key) { @@ -119,8 +121,12 @@ function smarty_function_html_select_date($params, &$smarty) break; default: - $smarty->trigger_error("[html_select_date] unknown parameter $_key", E_USER_WARNING); - + if(!is_array($_value)) { + $extra_attrs .= ' '.$_key.'="'.smarty_function_escape_special_chars($_value).'"'; + } else { + $smarty->trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; } } @@ -194,7 +200,7 @@ function smarty_function_html_select_date($params, &$smarty) if (null !== $all_extra){ $month_result .= ' ' . $all_extra; } - $month_result .= '>'."\n"; + $month_result .= $extra_attrs . '>'."\n"; $month_result .= smarty_function_html_options(array('output' => $month_names, 'values' => $month_values, @@ -230,7 +236,7 @@ function smarty_function_html_select_date($params, &$smarty) if (null !== $day_extra){ $day_result .= ' ' . $day_extra; } - $day_result .= '>'."\n"; + $day_result .= $extra_attrs . '>'."\n"; $day_result .= smarty_function_html_options(array('output' => $days, 'values' => $day_values, 'selected' => $time[2], @@ -276,7 +282,7 @@ function smarty_function_html_select_date($params, &$smarty) if (null !== $year_extra){ $year_result .= ' ' . $year_extra; } - $year_result .= '>'."\n"; + $year_result .= $extra_attrs . '>'."\n"; $year_result .= smarty_function_html_options(array('output' => $years, 'values' => $yearvals, 'selected' => $time[0],