Various fixes and additions.

This commit is contained in:
andrey
2001-11-20 22:36:56 +00:00
parent 7cebdd11ac
commit d8a95b1009
4 changed files with 39 additions and 10 deletions

4
NEWS
View File

@@ -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) - made cache reading process more efficient. (Monte)
- fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte) - fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte)
- update FAQ with mailing list Reply-To header FAQ. (Monte) - update FAQ with mailing list Reply-To header FAQ. (Monte)

View File

@@ -431,13 +431,18 @@ function smarty_func_html_select_time()
/* Default values. */ /* Default values. */
$prefix = "Time_"; $prefix = "Time_";
$time = time(); $time = time();
$display_hours = true; $display_hours = true;
$display_minutes = true; $display_minutes = true;
$display_seconds = true; $display_seconds = true;
$display_meridian = true; $display_meridian = true;
$use_24_hours = true; $use_24_hours = true;
$minute_interval = 1; $minute_interval = 1;
$second_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)); extract(func_get_arg(0));
@@ -450,7 +455,12 @@ function smarty_func_html_select_time()
$hour_fmt = $use_24_hours ? '%H' : '%I'; $hour_fmt = $use_24_hours ? '%H' : '%I';
for ($i = 0; $i < count($hours); $i++) for ($i = 0; $i < count($hours); $i++)
$hours[$i] = sprintf('%02d', $hours[$i]); $hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name="'.$prefix.'Hour">'."\n"; $html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]">'."\n";
} else {
$html_result .= '"' . $prefix . 'Hour">'."\n";
}
$html_result .= smarty_func_html_options(array('output' => $hours, $html_result .= smarty_func_html_options(array('output' => $hours,
'values' => $hours, 'values' => $hours,
'selected' => strftime($hour_fmt, $time), '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) for ($i = 0; $i < count($all_minutes); $i+= $minute_interval)
$minutes[] = sprintf('%02d', $all_minutes[$i]); $minutes[] = sprintf('%02d', $all_minutes[$i]);
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval); $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
$html_result .= '<select name="'.$prefix.'Minute">'."\n"; $html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Minute]">'."\n";
} else {
$html_result .= '"' . $prefix . 'Minute">'."\n";
}
$html_result .= smarty_func_html_options(array('output' => $minutes, $html_result .= smarty_func_html_options(array('output' => $minutes,
'values' => $minutes, 'values' => $minutes,
'selected' => $selected, 'selected' => $selected,
@@ -476,7 +491,12 @@ function smarty_func_html_select_time()
for ($i = 0; $i < count($all_seconds); $i+= $second_interval) for ($i = 0; $i < count($all_seconds); $i+= $second_interval)
$seconds[] = sprintf('%02d', $all_seconds[$i]); $seconds[] = sprintf('%02d', $all_seconds[$i]);
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval); $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
$html_result .= '<select name="'.$prefix.'Second">'."\n"; $html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Second]">'."\n";
} else {
$html_result .= '"' . $prefix . 'Second">'."\n";
}
$html_result .= smarty_func_html_options(array('output' => $seconds, $html_result .= smarty_func_html_options(array('output' => $seconds,
'values' => $seconds, 'values' => $seconds,
'selected' => $selected, 'selected' => $selected,
@@ -485,7 +505,12 @@ function smarty_func_html_select_time()
} }
if ($display_meridian && !$use_24_hours) { if ($display_meridian && !$use_24_hours) {
$html_result .= '<select name="'.$prefix.'Meridian">'."\n"; $html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]">'."\n";
} else {
$html_result .= '"' . $prefix . 'Meridian">'."\n";
}
$html_result .= smarty_func_html_options(array('output' => array('AM', 'PM'), $html_result .= smarty_func_html_options(array('output' => array('AM', 'PM'),
'values' => array('am', 'pm'), 'values' => array('am', 'pm'),
'selected' => strtolower(strftime('%p', $time)), 'selected' => strtolower(strftime('%p', $time)),

View File

@@ -266,7 +266,7 @@ class Smarty_Compiler extends Smarty {
case 'literal': case 'literal':
list (,$literal_block) = each($this->_literal_blocks); list (,$literal_block) = each($this->_literal_blocks);
$this->_current_line_no += substr_count($literal_block, "\n"); $this->_current_line_no += substr_count($literal_block, "\n");
return "<?php echo '".str_replace("'","\'",$literal_block)."'; ?>\n"; return "<?php echo '".str_replace("'", "\'", str_replace("\\", "\\\\", $literal_block))."'; ?>\n";
case 'php': case 'php':
if ($this->security && !$this->security_settings['PHP_TAGS']) { if ($this->security && !$this->security_settings['PHP_TAGS']) {
@@ -401,7 +401,7 @@ class Smarty_Compiler extends Smarty {
function _compile_include_tag($tag_args) function _compile_include_tag($tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$arg_list = array(); $arg_list = array();
if (empty($attrs['file'])) { if (empty($attrs['file'])) {
$this->_syntax_error("missing 'file' attribute in include tag"); $this->_syntax_error("missing 'file' attribute in include tag");

View File

@@ -266,7 +266,7 @@ class Smarty_Compiler extends Smarty {
case 'literal': case 'literal':
list (,$literal_block) = each($this->_literal_blocks); list (,$literal_block) = each($this->_literal_blocks);
$this->_current_line_no += substr_count($literal_block, "\n"); $this->_current_line_no += substr_count($literal_block, "\n");
return "<?php echo '".str_replace("'","\'",$literal_block)."'; ?>\n"; return "<?php echo '".str_replace("'", "\'", str_replace("\\", "\\\\", $literal_block))."'; ?>\n";
case 'php': case 'php':
if ($this->security && !$this->security_settings['PHP_TAGS']) { if ($this->security && !$this->security_settings['PHP_TAGS']) {
@@ -401,7 +401,7 @@ class Smarty_Compiler extends Smarty {
function _compile_include_tag($tag_args) function _compile_include_tag($tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$arg_list = array(); $arg_list = array();
if (empty($attrs['file'])) { if (empty($attrs['file'])) {
$this->_syntax_error("missing 'file' attribute in include tag"); $this->_syntax_error("missing 'file' attribute in include tag");