From d7093433aee46c4d65c0f1920daf9a9a6260eaeb Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Wed, 29 Apr 2009 17:56:56 +0000 Subject: [PATCH] - fixed problem with directory setter methodes --- change_log.txt | 3 +++ libs/Smarty.class.php | 20 ++++++++-------- libs/sysplugins/internal.compile_extend.php | 14 +++++------ libs/sysplugins/internal.template.php | 26 +++++++++++---------- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/change_log.txt b/change_log.txt index 4cb655c4..51fdd5bc 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +04/29/2009 +- fixed problem with directory setter methodes + 04/28/2009 - the {function} tag can no longer overwrite standard smarty tags - inherit functions defined by the {fuction} tag into subtemplates diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index be2f9f14..d7cdc2c5 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase { // config var settings 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_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 public $config_vars = array(); // assigned tpl vars @@ -355,7 +355,7 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function setTemplateDir($template_dir) { - $this->smarty->template_dir = (array)$template_dir; + $this->template_dir = (array)$template_dir; return; } /** @@ -365,8 +365,8 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function addTemplateDir($template_dir) { - $this->smarty->template_dir = array_merge((array)$this->smarty->template_dir, (array)$template_dir); - $this->smarty->template_dir = array_unique($this->smarty->template_dir); + $this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir); + $this->template_dir = array_unique($this->template_dir); return; } /** @@ -376,7 +376,7 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function setCompileDir($compile_dir) { - $this->smarty->compile_dir = $compile_dir; + $this->compile_dir = $compile_dir; return; } /** @@ -386,7 +386,7 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function setCacheDir($cache_dir) { - $this->smarty->cache_dir = $cache_dir; + $this->cache_dir = $cache_dir; return; } /** @@ -394,7 +394,7 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function enableCaching() { - $this->smarty->caching = true; + $this->caching = true; return; } /** @@ -404,7 +404,7 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function setCachingLifetime($lifetime) { - $this->smarty->caching_lifetime = $lifetime; + $this->caching_lifetime = $lifetime; return; } /** @@ -445,8 +445,8 @@ class Smarty extends Smarty_Internal_TemplateBase { // loop through plugin dirs and find the plugin foreach((array)$this->plugins_dir as $plugin_dir) { if (file_exists($plugin_dir . $plugin_filename)) { - require_once($plugin_dir . $plugin_filename); - return true; + require_once($plugin_dir . $plugin_filename); + return true; } } // no plugin loaded diff --git a/libs/sysplugins/internal.compile_extend.php b/libs/sysplugins/internal.compile_extend.php index 3adc5a1d..c5914e2e 100644 --- a/libs/sysplugins/internal.compile_extend.php +++ b/libs/sysplugins/internal.compile_extend.php @@ -47,22 +47,22 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { $this->compiler->trigger_template_error("\"" . $matches[0] . "\" missing name attribute"); } else { // compile block content - $tpl = $this->smarty->createTemplate('string:' . $matches[3]); - $tpl->suppressHeader = true; - $compiled_content = $tpl->getCompiledTemplate(); - $tpl->suppressHeader = false; + $_tpl = $this->smarty->createTemplate('string:' . $matches[3]); + $_tpl->suppressHeader = true; + $_compiled_content = $_tpl->getCompiledTemplate(); + unset($_tpl); $_name = trim($_match[3], "\"'"); if (isset($this->compiler->template->block_data[$_name])) { 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]; } 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']; } } 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]; } // if (isset($this->compiler->template->block_data[$_name]['mode'])) { diff --git a/libs/sysplugins/internal.template.php b/libs/sysplugins/internal.template.php index 378ac098..b8b5e1e6 100644 --- a/libs/sysplugins/internal.template.php +++ b/libs/sysplugins/internal.template.php @@ -199,17 +199,19 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { if ($this->mustCompile) { return true; } - // read compiled template - if ($this->compiled_template !== true && file_exists($this->getCompiledFilepath())) { - $this->compiled_template = !$this->isEvaluated() ? file_get_contents($this->getCompiledFilepath()):''; - $found = preg_match('~\<\?php /\*(.*)\*/ \?\>~', $this->compiled_template, $matches); - if ($found) { - $_properties = unserialize($matches[1]); - if (!empty($_properties['file_dependency'])) { - foreach ($_properties['file_dependency'] as $file_to_check) { - If (filemtime($file_to_check[0]) != $file_to_check[1]) { - $this->mustCompile = true; - return $this->mustCompile; + if ($this->smarty->compile_check) { + // read compiled template to check file dependencies + if ($this->compiled_template !== true && file_exists($this->getCompiledFilepath())) { + $this->compiled_template = !$this->isEvaluated() ? file_get_contents($this->getCompiledFilepath()):''; + $found = preg_match('~\<\?php /\*(.*)\*/ \?\>~', $this->compiled_template, $matches); + if ($found) { + $_properties = unserialize($matches[1]); + if (!empty($_properties['file_dependency'])) { + foreach ($_properties['file_dependency'] as $file_to_check) { + If (filemtime($file_to_check[0]) != $file_to_check[1]) { + $this->mustCompile = true; + return $this->mustCompile; + } } } } @@ -379,7 +381,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { $this->rendered_content = null; 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) { If (filemtime($file_to_check[0]) > $this->getCachedTimestamp()) { $this->rendered_content = null;