diff options
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_resource_php.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_internal_resource_php.php | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php b/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php index 7463c2960..62680625c 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php @@ -9,9 +9,15 @@ * @author Uwe Tews * @author Rodney Rehm */ -class Smarty_Internal_Resource_PHP extends Smarty_Resource_Uncompiled +class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File { /** + * Flag that it's an uncompiled resource + * + * @var bool + */ + public $uncompiled = true; + /** * container for short_open_tag directive's value before executing PHP templates * * @var string @@ -19,50 +25,20 @@ class Smarty_Internal_Resource_PHP extends Smarty_Resource_Uncompiled protected $short_open_tag; /** - * Create a new PHP Resource - - */ - public function __construct() - { - $this->short_open_tag = ini_get('short_open_tag'); - } - - /** - * populate Source Object with meta data from Resource + * Resource does implement populateCompiledFilepath() method * - * @param Smarty_Template_Source $source source object - * @param Smarty_Internal_Template $_template template object - * - * @return void + * @var bool */ - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) - { - $source->filepath = $this->buildFilepath($source, $_template); - - if ($source->filepath !== false) { - if (is_object($source->smarty->security_policy)) { - $source->smarty->security_policy->isTrustedResourceDir($source->filepath); - } + public $hasCompiledHandler = true; - $source->uid = sha1($source->filepath); - if ($source->smarty->compile_check) { - $source->timestamp = @filemtime($source->filepath); - $source->exists = !!$source->timestamp; - } - } - } /** - * populate Source Object with timestamp and exists from Resource - * - * @param Smarty_Template_Source $source source object - * - * @return void + * Create a new PHP Resource + */ - public function populateTimestamp(Smarty_Template_Source $source) + public function __construct() { - $source->timestamp = @filemtime($source->filepath); - $source->exists = !!$source->timestamp; + $this->short_open_tag = ini_get('short_open_tag'); } /** @@ -75,7 +51,7 @@ class Smarty_Internal_Resource_PHP extends Smarty_Resource_Uncompiled */ public function getContent(Smarty_Template_Source $source) { - if ($source->timestamp) { + if ($source->exists) { return ''; } throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); @@ -96,7 +72,7 @@ class Smarty_Internal_Resource_PHP extends Smarty_Resource_Uncompiled throw new SmartyException("PHP templates are disabled"); } if (!$source->exists) { - if ($_template->parent instanceof Smarty_Internal_Template) { + if (isset($_template->parent) && $_template->parent->_objType == 2) { $parent_resource = " in '{$_template->parent->template_resource}'"; } else { $parent_resource = ''; @@ -116,4 +92,17 @@ class Smarty_Internal_Resource_PHP extends Smarty_Resource_Uncompiled include($source->filepath); ini_set('short_open_tag', $this->short_open_tag); } + + /** + * populate compiled object with compiled filepath + * + * @param Smarty_Template_Compiled $compiled compiled object + * @param Smarty_Internal_Template $_template template object (is ignored) + */ + public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template) + { + $compiled->filepath = false; + $compiled->timestamp = false; + $compiled->exists = false; + } } |