mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
- bugfix {$smarty.template} in child template did not return right content
- bugfix Smarty3 did not search the PHP include_path for template files
This commit is contained in:
@@ -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
|
||||
|
@@ -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':
|
||||
|
44
libs/sysplugins/smarty_internal_get_include_path.php
Normal file
44
libs/sysplugins/smarty_internal_get_include_path.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty read include path plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Monte Ohrt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Read Include Path Class
|
||||
*/
|
||||
class Smarty_Internal_Get_Include_Path {
|
||||
/**
|
||||
* Return full file path from PHP include_path
|
||||
*
|
||||
* @param string $filepath filepath
|
||||
* @return mixed full filepath or false
|
||||
*/
|
||||
public static function getIncludePath($filepath)
|
||||
{
|
||||
static $_path_array = null;
|
||||
|
||||
if(!isset($_path_array)) {
|
||||
$_ini_include_path = ini_get('include_path');
|
||||
|
||||
if(strstr($_ini_include_path,';')) {
|
||||
// windows pathnames
|
||||
$_path_array = explode(';',$_ini_include_path);
|
||||
} else {
|
||||
$_path_array = explode(':',$_ini_include_path);
|
||||
}
|
||||
}
|
||||
foreach ($_path_array as $_include_path) {
|
||||
if (file_exists($_include_path . DS . $filepath)) {
|
||||
return $_include_path . DS . $filepath;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user