diff --git a/NEWS b/NEWS index 080e50fc..a1629034 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - added html_select_time custom function. (Andrei) + Version 1.3.1pl1 -------------- - bug fix, recovered missing _syntax_error function diff --git a/Smarty.addons.php b/Smarty.addons.php index 1c270c1b..04bc3a03 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -267,7 +267,8 @@ function smarty_func_html_select_date() if ($display_days) { $days = range(1, 31); - array_walk($days, create_function('&$x', '$x = sprintf("'.$day_format.'", $x);')); + for ($i = 0; $i < count($days); $i++) + $days[$i] = sprintf($day_format, $days[$i]); $html_result .= ''."\n"; + $html_result .= smarty_func_html_options(array('output' => $hours, + 'values' => $hours, + 'selected' => strftime($hour_fmt, $time), + 'print_result' => false)); + $html_result .= "\n"; + } + + if ($display_minutes) { + $all_minutes = range(0, 59); + for ($i = 0; $i < count($all_minutes); $i+= $minute_interval) + $minutes[] = sprintf('%02d', $all_minutes[$i]); + $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval); + $html_result .= '\n"; + } + + if ($display_seconds) { + $all_seconds = range(0, 59); + for ($i = 0; $i < count($all_seconds); $i+= $second_interval) + $seconds[] = sprintf('%02d', $all_seconds[$i]); + $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval); + $html_result .= '\n"; + } + + if (!$display_24_hours) { + $html_result .= '\n"; + } + + print $html_result; +} + + /*======================================================================*\ Function: smarty_func_math Purpose: allow math computations in template @@ -351,16 +425,16 @@ function smarty_func_math() { Purpose: fetch file, web or ftp data and display results \*======================================================================*/ function smarty_func_fetch() { - extract(func_get_arg(0)); + extract(func_get_arg(0)); - if(empty($file)) { - trigger_error("parameter 'file' cannot be empty"); - return; - } - readfile($file); + if (empty($file)) { + trigger_error("parameter 'file' cannot be empty"); + return; + } + + readfile($file); } - /* vim: set expandtab: */ ?> diff --git a/Smarty.class.php b/Smarty.class.php index cd8d2d43..8e925698 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -85,6 +85,7 @@ class Smarty var $custom_funcs = array( 'html_options' => 'smarty_func_html_options', 'html_select_date' => 'smarty_func_html_select_date', + 'html_select_time' => 'smarty_func_html_select_time', 'math' => 'smarty_func_math', 'fetch' => 'smarty_func_fetch' ); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index cd8d2d43..8e925698 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -85,6 +85,7 @@ class Smarty var $custom_funcs = array( 'html_options' => 'smarty_func_html_options', 'html_select_date' => 'smarty_func_html_select_date', + 'html_select_time' => 'smarty_func_html_select_time', 'math' => 'smarty_func_math', 'fetch' => 'smarty_func_fetch' );