From c9b789ca329a020f7ccf7aec4be9c33f5abe0c6a Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Sat, 11 Apr 2009 08:47:28 +0000 Subject: [PATCH] - fixed variables in 'file' attribute of {extend} tag - fixed problems in modifiers (if mb string functions not present) --- change_log.txt | 4 ++++ libs/Smarty.class.php | 4 +--- libs/plugins/modifier.regex_replace.php | 4 ++-- libs/plugins/modifier.strip.php | 2 +- libs/plugins/modifier.strip_tags.php | 2 +- libs/plugins/modifier.truncate.php | 2 +- libs/sysplugins/internal.compile_extend.php | 4 +++- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/change_log.txt b/change_log.txt index 1eceade8..e2d8e8e3 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,7 @@ +04/11/2009 +- fixed variables in 'file' attribute of {extend} tag +- fixed problems in modifiers (if mb string functions not present) + 04/10/2009 - check if mb string functions available otherwise fallback to normal string functions - added global variable scope SMARTY_GLOBAL_SCOPE diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 32c5f4dd..206d6a90 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -166,8 +166,6 @@ class Smarty extends Smarty_Internal_TemplateBase { public $_smarty_vars = array(); // start time for execution time calculation public $start_time = 0; - // set default time zone - public $set_timezone = true; // has multibyte string functions? public $has_mb = false; /** @@ -179,7 +177,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->has_mb = true; mb_internal_encoding($this->resource_char_set); } - if ($this->set_timezone and function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) { + if (function_exists("date_default_timezone_set")) { date_default_timezone_set(date_default_timezone_get()); } $this->start_time = $this->_get_time(); diff --git a/libs/plugins/modifier.regex_replace.php b/libs/plugins/modifier.regex_replace.php index c2ca0b4e..914602e5 100644 --- a/libs/plugins/modifier.regex_replace.php +++ b/libs/plugins/modifier.regex_replace.php @@ -34,7 +34,7 @@ function smarty_modifier_regex_replace($string, $search, $replace) if ($smarty->has_mb) { return mb_ereg_replace($search, $replace, $string); } else { - return ereg_replace($search, $replace, $string); + return preg_replace($search, $replace, $string); } } @@ -52,7 +52,7 @@ function _smarty_regex_replace_check($search) $search = substr($search, 0, $pos); if (mb_preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { /* remove eval-modifier from $search */ - $search = substr($search, 0, - strlen($match[1])) . ereg_replace('![e\s]+!', '', $match[1]); + $search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); } } return $search; diff --git a/libs/plugins/modifier.strip.php b/libs/plugins/modifier.strip.php index 35eb98be..08f7b106 100644 --- a/libs/plugins/modifier.strip.php +++ b/libs/plugins/modifier.strip.php @@ -29,7 +29,7 @@ function smarty_modifier_strip($text, $replace = ' ') if ($smarty->has_mb) { return mb_ereg_replace('!\s+!', $replace, $text, 'p'); } else { - return ereg_replace('!\s+!', $replace, $text, 'p'); + return preg_replace('!\s+!', $replace, $text); } } diff --git a/libs/plugins/modifier.strip_tags.php b/libs/plugins/modifier.strip_tags.php index cfc0929c..f93953b8 100644 --- a/libs/plugins/modifier.strip_tags.php +++ b/libs/plugins/modifier.strip_tags.php @@ -26,7 +26,7 @@ function smarty_modifier_strip_tags($string, $replace_with_space = true) if ($smarty->has_mb) { return mb_ereg_replace('!<[^>]*?>!', ' ', $string, 'p'); } else { - return ereg_replace('!<[^>]*?>!', ' ', $string, 'p'); + return preg_replace('!<[^>]*?>!', ' ', $string); } } else { return strip_tags($string); diff --git a/libs/plugins/modifier.truncate.php b/libs/plugins/modifier.truncate.php index 5e382a6d..f8a6c1bb 100644 --- a/libs/plugins/modifier.truncate.php +++ b/libs/plugins/modifier.truncate.php @@ -49,7 +49,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', if (strlen($string) > $length) { $length -= min($length, strlen($etc)); if (!$break_words && !$middle) { - $string = ereg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1), 'p'); + $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); } if (!$middle) { return substr($string, 0, $length) . $etc; diff --git a/libs/sysplugins/internal.compile_extend.php b/libs/sysplugins/internal.compile_extend.php index fd3ca125..5536fb17 100644 --- a/libs/sysplugins/internal.compile_extend.php +++ b/libs/sysplugins/internal.compile_extend.php @@ -26,7 +26,9 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { $this->required_attributes = array('file'); // check and get attributes $_attr = $this->_get_attributes($args); - $include_file = trim($_attr['file'], "'"); + $_smarty_tpl = $compiler->template; +// $include_file = ''; + eval('$include_file = '.$_attr['file'].';'); // create template object $_template = new Smarty_Template ($include_file, $compiler->template); // save file dependency