- fixed variables in 'file' attribute of {extend} tag

- fixed problems in modifiers (if mb string functions not present)
This commit is contained in:
Uwe.Tews
2009-04-11 08:47:28 +00:00
parent ba61f12384
commit c9b789ca32
7 changed files with 13 additions and 9 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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