diff --git a/change_log.txt b/change_log.txt index 9d79ff7d..9d65b5b1 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,9 @@ ===== SVN trunk ===== +13/12/2010 +- bugfix {$smarty.template} in child template did not return right content +- bugfix Smarty3 did not search the PHP include_path for template files + ===== Smarty 3.0.6 ===== 12/12/2010 diff --git a/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/libs/sysplugins/smarty_internal_compile_private_special_variable.php index f9a8535c..44910c34 100644 --- a/libs/sysplugins/smarty_internal_compile_private_special_variable.php +++ b/libs/sysplugins/smarty_internal_compile_private_special_variable.php @@ -56,7 +56,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C break; case 'template': - $_template_name = $compiler->template->template_resource; + $_template_name = basename($compiler->template->getTemplateFilepath()); return "'$_template_name'"; case 'current_dir': diff --git a/libs/sysplugins/smarty_internal_get_include_path.php b/libs/sysplugins/smarty_internal_get_include_path.php new file mode 100644 index 00000000..b9f19316 --- /dev/null +++ b/libs/sysplugins/smarty_internal_get_include_path.php @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index d361b4c6..f6df0d5d 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -593,17 +593,27 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { { if ($file == null) { $file = $this->resource_name; - } - foreach((array)$this->smarty->template_dir as $_template_dir) { - if (strpos('/\\', substr($_template_dir, -1)) === false) { - $_template_dir .= DS; - } - - $_filepath = $_template_dir . $file; - if (file_exists($_filepath)) - return $_filepath; - } - if (file_exists($file)) return $file; + } + // relative file name? + if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) { + foreach((array)$this->smarty->template_dir as $_template_dir) { + if (strpos('/\\', substr($_template_dir, -1)) === false) { + $_template_dir .= DS; + } + $_filepath = $_template_dir . $file; + if (file_exists($_filepath)) { + return $_filepath; + } + if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) { + // try PHP include_path + if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) { + return $_filepath; + } + } + } + } + // try absolute filepath + if (file_exists($file)) return $file; // no tpl file found if (!empty($this->smarty->default_template_handler_func)) { if (!is_callable($this->smarty->default_template_handler_func)) {