From 81f50710ed1a69aca54d74583f69424ee8e63bd0 Mon Sep 17 00:00:00 2001 From: andrey Date: Tue, 9 Jan 2001 17:50:51 +0000 Subject: [PATCH] *** empty log message *** --- Smarty.addons.php | 6 +++--- Smarty.class.php | 26 ++++++++++++++------------ libs/Smarty.class.php | 26 ++++++++++++++------------ 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Smarty.addons.php b/Smarty.addons.php index c6a1f2e7..db63f02c 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -76,13 +76,13 @@ function smarty_mod_spacify($string, $spacify_char = ' ') } -function smarty_mod_date_format($string, $format) +function smarty_mod_date_format($string, $format="%b %e, %Y") { return strftime($format, $string); } -function smarty_mod_string_format($string, $format="%b %e, %Y") +function smarty_mod_string_format($string, $format) { return sprintf($format, $string); } @@ -92,7 +92,7 @@ function smarty_mod_replace($string, $search, $replace) return str_replace($search, $replace, $string); } -function smarty_mod_strip_tags($string, $replace_with_space = false) +function smarty_mod_strip_tags($string, $replace_with_space = true) { if ($replace_with_space) return preg_replace('!<[^>]*?>!', ' ', $string); diff --git a/Smarty.class.php b/Smarty.class.php index 0c37edbe..cdf0b20d 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -391,7 +391,7 @@ class Smarty (?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\' ]+))+ ) (?:\s+(.*))? - /x', $template_tag, $match); + /xs', $template_tag, $match); list(, $tag_command, $tag_args) = $match; /* If the tag name matches a variable or section property definition, @@ -592,6 +592,8 @@ class Smarty if (isset($attrs['show'])) { $show_check_code = "{$section_props}['show'] && "; + } else { + $output .= "{$section_props}['show'] = {$section_props}['loop'] > 0;\n"; } $output .= "if ($loop_check_code $show_check_code true): "; @@ -858,9 +860,9 @@ class Smarty function _parse_var($var_expr) { - $custom_mods = explode('|', substr($var_expr, 1)); + $modifiers = explode('|', substr($var_expr, 1)); - $sections = explode('/', array_shift($custom_mods)); + $sections = explode('/', array_shift($modifiers)); $var_name = array_pop($sections); $output = "\$$var_name"; @@ -869,42 +871,42 @@ class Smarty $output .= "[\$_sections['$section']['properties']['index']]"; } - $this->_parse_modifiers($output, $custom_mods); + $this->_parse_modifiers($output, $modifiers); return $output; } function _parse_conf_var($conf_var_expr) { - $custom_mods = explode('|', $conf_var_expr); + $modifiers = explode('|', $conf_var_expr); - $var_name = substr(array_shift($custom_mods), 1, -1); + $var_name = substr(array_shift($modifiers), 1, -1); $output = "\$_config['$var_name']"; - $this->_parse_modifiers($output, $custom_mods); + $this->_parse_modifiers($output, $modifiers); return $output; } function _parse_section_prop($section_prop_expr) { - $custom_mods = explode('|', $section_prop_expr); + $modifiers = explode('|', $section_prop_expr); - preg_match('!%(\w+)\.(\w+)%!', array_shift($custom_mods), $match); + preg_match('!%(\w+)\.(\w+)%!', array_shift($modifiers), $match); $section_name = $match[1]; $prop_name = $match[2]; $output = "\$_sections['$section_name']['properties']['$prop_name']"; - $this->_parse_modifiers($output, $custom_mods); + $this->_parse_modifiers($output, $modifiers); return $output; } - function _parse_modifiers(&$output, $custom_mods) + function _parse_modifiers(&$output, $modifiers) { - foreach ($custom_mods as $modifier) { + foreach ($modifiers as $modifier) { $modifier = explode(':', $modifier); $modifier_name = array_shift($modifier); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 0c37edbe..cdf0b20d 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -391,7 +391,7 @@ class Smarty (?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\' ]+))+ ) (?:\s+(.*))? - /x', $template_tag, $match); + /xs', $template_tag, $match); list(, $tag_command, $tag_args) = $match; /* If the tag name matches a variable or section property definition, @@ -592,6 +592,8 @@ class Smarty if (isset($attrs['show'])) { $show_check_code = "{$section_props}['show'] && "; + } else { + $output .= "{$section_props}['show'] = {$section_props}['loop'] > 0;\n"; } $output .= "if ($loop_check_code $show_check_code true): "; @@ -858,9 +860,9 @@ class Smarty function _parse_var($var_expr) { - $custom_mods = explode('|', substr($var_expr, 1)); + $modifiers = explode('|', substr($var_expr, 1)); - $sections = explode('/', array_shift($custom_mods)); + $sections = explode('/', array_shift($modifiers)); $var_name = array_pop($sections); $output = "\$$var_name"; @@ -869,42 +871,42 @@ class Smarty $output .= "[\$_sections['$section']['properties']['index']]"; } - $this->_parse_modifiers($output, $custom_mods); + $this->_parse_modifiers($output, $modifiers); return $output; } function _parse_conf_var($conf_var_expr) { - $custom_mods = explode('|', $conf_var_expr); + $modifiers = explode('|', $conf_var_expr); - $var_name = substr(array_shift($custom_mods), 1, -1); + $var_name = substr(array_shift($modifiers), 1, -1); $output = "\$_config['$var_name']"; - $this->_parse_modifiers($output, $custom_mods); + $this->_parse_modifiers($output, $modifiers); return $output; } function _parse_section_prop($section_prop_expr) { - $custom_mods = explode('|', $section_prop_expr); + $modifiers = explode('|', $section_prop_expr); - preg_match('!%(\w+)\.(\w+)%!', array_shift($custom_mods), $match); + preg_match('!%(\w+)\.(\w+)%!', array_shift($modifiers), $match); $section_name = $match[1]; $prop_name = $match[2]; $output = "\$_sections['$section_name']['properties']['$prop_name']"; - $this->_parse_modifiers($output, $custom_mods); + $this->_parse_modifiers($output, $modifiers); return $output; } - function _parse_modifiers(&$output, $custom_mods) + function _parse_modifiers(&$output, $modifiers) { - foreach ($custom_mods as $modifier) { + foreach ($modifiers as $modifier) { $modifier = explode(':', $modifier); $modifier_name = array_shift($modifier);