4 * Smarty Template Resource Base Object
7 * @subpackage TemplateResources
10 abstract class Smarty_Template_Resource_Base
17 public $filepath = null;
24 public $timestamp = false;
31 public $exists = false;
34 * Template Compile Id (Smarty_Internal_Template::$compile_id)
38 public $compile_id = null;
41 * Compiled Content Loaded
45 public $processed = false;
48 * unique function name for compiled template code
55 * flag if template does contain nocache code sections
59 public $has_nocache_code = false;
62 * resource file dependency
66 public $file_dependency = array();
73 public $content = null;
80 public $required_plugins = array();
83 * Included subtemplates
87 public $includes = array();
90 * Flag if this is a cache resource
94 public $isCache = false;
99 * @param Smarty_Internal_Template $_template template object
101 abstract public function process(Smarty_Internal_Template $_template);
104 * get rendered template content by calling compiled or cached template code
106 * @param \Smarty_Internal_Template $_template
107 * @param string $unifunc function with template code
111 public function getRenderedTemplateCode(Smarty_Internal_Template $_template, $unifunc = null)
113 $smarty = &$_template->smarty;
114 $_template->isRenderingCache = $this->isCache;
115 $level = ob_get_level();
117 if (!isset($unifunc)) {
118 $unifunc = $this->unifunc;
120 if (empty($unifunc) || !function_exists($unifunc)) {
121 throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
123 if ($_template->startRenderCallbacks) {
124 foreach ($_template->startRenderCallbacks as $callback) {
125 call_user_func($callback, $_template);
128 $unifunc($_template);
129 foreach ($_template->endRenderCallbacks as $callback) {
130 call_user_func($callback, $_template);
132 $_template->isRenderingCache = false;
134 catch (Exception $e) {
135 $_template->isRenderingCache = false;
136 while (ob_get_level() > $level) {
139 if (isset($smarty->security_policy)) {
140 $smarty->security_policy->endTemplate();
147 * Get compiled time stamp
151 public function getTimeStamp()
153 if ($this->exists && !$this->timestamp) {
154 $this->timestamp = filemtime($this->filepath);
156 return $this->timestamp;