- fixed problem with directory setter methodes

This commit is contained in:
Uwe.Tews
2009-04-29 17:56:56 +00:00
parent 4c794a3d70
commit d7093433ae
4 changed files with 34 additions and 29 deletions

View File

@@ -1,3 +1,6 @@
04/29/2009
- fixed problem with directory setter methodes
04/28/2009 04/28/2009
- the {function} tag can no longer overwrite standard smarty tags - the {function} tag can no longer overwrite standard smarty tags
- inherit functions defined by the {fuction} tag into subtemplates - inherit functions defined by the {fuction} tag into subtemplates

View File

@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
// config var settings // config var settings
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other. public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file.
// config vars // config vars
public $config_vars = array(); public $config_vars = array();
// assigned tpl vars // assigned tpl vars
@@ -355,7 +355,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/ */
public function setTemplateDir($template_dir) public function setTemplateDir($template_dir)
{ {
$this->smarty->template_dir = (array)$template_dir; $this->template_dir = (array)$template_dir;
return; return;
} }
/** /**
@@ -365,8 +365,8 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/ */
public function addTemplateDir($template_dir) public function addTemplateDir($template_dir)
{ {
$this->smarty->template_dir = array_merge((array)$this->smarty->template_dir, (array)$template_dir); $this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir);
$this->smarty->template_dir = array_unique($this->smarty->template_dir); $this->template_dir = array_unique($this->template_dir);
return; return;
} }
/** /**
@@ -376,7 +376,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/ */
public function setCompileDir($compile_dir) public function setCompileDir($compile_dir)
{ {
$this->smarty->compile_dir = $compile_dir; $this->compile_dir = $compile_dir;
return; return;
} }
/** /**
@@ -386,7 +386,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/ */
public function setCacheDir($cache_dir) public function setCacheDir($cache_dir)
{ {
$this->smarty->cache_dir = $cache_dir; $this->cache_dir = $cache_dir;
return; return;
} }
/** /**
@@ -394,7 +394,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/ */
public function enableCaching() public function enableCaching()
{ {
$this->smarty->caching = true; $this->caching = true;
return; return;
} }
/** /**
@@ -404,7 +404,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/ */
public function setCachingLifetime($lifetime) public function setCachingLifetime($lifetime)
{ {
$this->smarty->caching_lifetime = $lifetime; $this->caching_lifetime = $lifetime;
return; return;
} }
/** /**
@@ -445,8 +445,8 @@ class Smarty extends Smarty_Internal_TemplateBase {
// loop through plugin dirs and find the plugin // loop through plugin dirs and find the plugin
foreach((array)$this->plugins_dir as $plugin_dir) { foreach((array)$this->plugins_dir as $plugin_dir) {
if (file_exists($plugin_dir . $plugin_filename)) { if (file_exists($plugin_dir . $plugin_filename)) {
require_once($plugin_dir . $plugin_filename); require_once($plugin_dir . $plugin_filename);
return true; return true;
} }
} }
// no plugin loaded // no plugin loaded

View File

@@ -47,22 +47,22 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase {
$this->compiler->trigger_template_error("\"" . $matches[0] . "\" missing name attribute"); $this->compiler->trigger_template_error("\"" . $matches[0] . "\" missing name attribute");
} else { } else {
// compile block content // compile block content
$tpl = $this->smarty->createTemplate('string:' . $matches[3]); $_tpl = $this->smarty->createTemplate('string:' . $matches[3]);
$tpl->suppressHeader = true; $_tpl->suppressHeader = true;
$compiled_content = $tpl->getCompiledTemplate(); $_compiled_content = $_tpl->getCompiledTemplate();
$tpl->suppressHeader = false; unset($_tpl);
$_name = trim($_match[3], "\"'"); $_name = trim($_match[3], "\"'");
if (isset($this->compiler->template->block_data[$_name])) { if (isset($this->compiler->template->block_data[$_name])) {
if ($this->compiler->template->block_data[$_name]['mode'] == 'prepend') { if ($this->compiler->template->block_data[$_name]['mode'] == 'prepend') {
$this->compiler->template->block_data[$_name]['compiled'] .= $compiled_content; $this->compiler->template->block_data[$_name]['compiled'] .= $_compiled_content;
$this->compiler->template->block_data[$_name]['source'] .= $matches[3]; $this->compiler->template->block_data[$_name]['source'] .= $matches[3];
} elseif ($this->compiler->template->block_data[$_name]['mode'] == 'append') { } elseif ($this->compiler->template->block_data[$_name]['mode'] == 'append') {
$this->compiler->template->block_data[$_name]['compiled'] = $compiled_content . $this->compiler->template->block_data[$_name]['compiled']; $this->compiler->template->block_data[$_name]['compiled'] = $_compiled_content . $this->compiler->template->block_data[$_name]['compiled'];
$this->compiler->template->block_data[$_name]['source'] = $matches[3] . $this->compiler->template->block_data[$_name]['source']; $this->compiler->template->block_data[$_name]['source'] = $matches[3] . $this->compiler->template->block_data[$_name]['source'];
} }
} else { } else {
$this->compiler->template->block_data[$_name]['compiled'] = $compiled_content; $this->compiler->template->block_data[$_name]['compiled'] = $_compiled_content;
$this->compiler->template->block_data[$_name]['source'] = $matches[3]; $this->compiler->template->block_data[$_name]['source'] = $matches[3];
} }
// if (isset($this->compiler->template->block_data[$_name]['mode'])) { // if (isset($this->compiler->template->block_data[$_name]['mode'])) {

View File

@@ -199,17 +199,19 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
if ($this->mustCompile) { if ($this->mustCompile) {
return true; return true;
} }
// read compiled template if ($this->smarty->compile_check) {
if ($this->compiled_template !== true && file_exists($this->getCompiledFilepath())) { // read compiled template to check file dependencies
$this->compiled_template = !$this->isEvaluated() ? file_get_contents($this->getCompiledFilepath()):''; if ($this->compiled_template !== true && file_exists($this->getCompiledFilepath())) {
$found = preg_match('~\<\?php /\*(.*)\*/ \?\>~', $this->compiled_template, $matches); $this->compiled_template = !$this->isEvaluated() ? file_get_contents($this->getCompiledFilepath()):'';
if ($found) { $found = preg_match('~\<\?php /\*(.*)\*/ \?\>~', $this->compiled_template, $matches);
$_properties = unserialize($matches[1]); if ($found) {
if (!empty($_properties['file_dependency'])) { $_properties = unserialize($matches[1]);
foreach ($_properties['file_dependency'] as $file_to_check) { if (!empty($_properties['file_dependency'])) {
If (filemtime($file_to_check[0]) != $file_to_check[1]) { foreach ($_properties['file_dependency'] as $file_to_check) {
$this->mustCompile = true; If (filemtime($file_to_check[0]) != $file_to_check[1]) {
return $this->mustCompile; $this->mustCompile = true;
return $this->mustCompile;
}
} }
} }
} }
@@ -379,7 +381,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
$this->rendered_content = null; $this->rendered_content = null;
return $this->isCached; return $this->isCached;
} }
if (!empty($this->properties['file_dependency'])) { if (!empty($this->properties['file_dependency']) && $this->smarty->compile_check) {
foreach ($this->properties['file_dependency'] as $file_to_check) { foreach ($this->properties['file_dependency'] as $file_to_check) {
If (filemtime($file_to_check[0]) > $this->getCachedTimestamp()) { If (filemtime($file_to_check[0]) > $this->getCachedTimestamp()) {
$this->rendered_content = null; $this->rendered_content = null;