From d8a95b1009c7a04ba725954698647d4c1ea89654 Mon Sep 17 00:00:00 2001 From: andrey Date: Tue, 20 Nov 2001 22:36:56 +0000 Subject: [PATCH] Various fixes and additions. --- NEWS | 4 ++++ Smarty.addons.php | 37 ++++++++++++++++++++++++++++------ Smarty_Compiler.class.php | 4 ++-- libs/Smarty_Compiler.class.php | 4 ++-- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 3ed61835..c33aaf28 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ + - fixed a bug that could cause parse error with quotes inside literal + blocks. (Andrei, Alexander Belonosov) + - added 'field_array' attribute to html_select_time function. (Andrei, + Michael Caplan) - made cache reading process more efficient. (Monte) - fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte) - update FAQ with mailing list Reply-To header FAQ. (Monte) diff --git a/Smarty.addons.php b/Smarty.addons.php index a6e56fdc..49221465 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -431,13 +431,18 @@ function smarty_func_html_select_time() /* Default values. */ $prefix = "Time_"; $time = time(); - $display_hours = true; + $display_hours = true; $display_minutes = true; $display_seconds = true; $display_meridian = true; - $use_24_hours = true; + $use_24_hours = true; $minute_interval = 1; $second_interval = 1; + /* Should the select boxes be part of an array when returned from PHP? + e.g. setting it to "birthday", would create "birthday[Hour]", + "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]". + Can be combined with prefix. */ + $field_array = null; extract(func_get_arg(0)); @@ -450,7 +455,12 @@ function smarty_func_html_select_time() $hour_fmt = $use_24_hours ? '%H' : '%I'; for ($i = 0; $i < count($hours); $i++) $hours[$i] = sprintf('%02d', $hours[$i]); - $html_result .= ''."\n"; + } else { + $html_result .= '"' . $prefix . 'Hour">'."\n"; + } $html_result .= smarty_func_html_options(array('output' => $hours, 'values' => $hours, 'selected' => strftime($hour_fmt, $time), @@ -463,7 +473,12 @@ function smarty_func_html_select_time() 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"; + } else { + $html_result .= '"' . $prefix . 'Minute">'."\n"; + } $html_result .= smarty_func_html_options(array('output' => $minutes, 'values' => $minutes, 'selected' => $selected, @@ -476,7 +491,12 @@ function smarty_func_html_select_time() 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"; + } else { + $html_result .= '"' . $prefix . 'Second">'."\n"; + } $html_result .= smarty_func_html_options(array('output' => $seconds, 'values' => $seconds, 'selected' => $selected, @@ -485,7 +505,12 @@ function smarty_func_html_select_time() } if ($display_meridian && !$use_24_hours) { - $html_result .= ''."\n"; + } else { + $html_result .= '"' . $prefix . 'Meridian">'."\n"; + } $html_result .= smarty_func_html_options(array('output' => array('AM', 'PM'), 'values' => array('am', 'pm'), 'selected' => strtolower(strftime('%p', $time)), diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 32a19fd5..c6cc0c6a 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -266,7 +266,7 @@ class Smarty_Compiler extends Smarty { case 'literal': list (,$literal_block) = each($this->_literal_blocks); $this->_current_line_no += substr_count($literal_block, "\n"); - return "\n"; + return "\n"; case 'php': if ($this->security && !$this->security_settings['PHP_TAGS']) { @@ -401,7 +401,7 @@ class Smarty_Compiler extends Smarty { function _compile_include_tag($tag_args) { $attrs = $this->_parse_attrs($tag_args); - $arg_list = array(); + $arg_list = array(); if (empty($attrs['file'])) { $this->_syntax_error("missing 'file' attribute in include tag"); diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 32a19fd5..c6cc0c6a 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -266,7 +266,7 @@ class Smarty_Compiler extends Smarty { case 'literal': list (,$literal_block) = each($this->_literal_blocks); $this->_current_line_no += substr_count($literal_block, "\n"); - return "\n"; + return "\n"; case 'php': if ($this->security && !$this->security_settings['PHP_TAGS']) { @@ -401,7 +401,7 @@ class Smarty_Compiler extends Smarty { function _compile_include_tag($tag_args) { $attrs = $this->_parse_attrs($tag_args); - $arg_list = array(); + $arg_list = array(); if (empty($attrs['file'])) { $this->_syntax_error("missing 'file' attribute in include tag");