mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 03:44:26 +02:00
- fixed variables in 'file' attribute of {extend} tag
- fixed problems in modifiers (if mb string functions not present)
This commit is contained in:
@@ -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
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user