From 51609351f2c4b5082b7e6f0744cd3811c325303f Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 11 Oct 2016 14:01:29 +0200 Subject: * initial template --- lib/smarty/sysplugins/smarty_resource_custom.php | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 lib/smarty/sysplugins/smarty_resource_custom.php (limited to 'lib/smarty/sysplugins/smarty_resource_custom.php') diff --git a/lib/smarty/sysplugins/smarty_resource_custom.php b/lib/smarty/sysplugins/smarty_resource_custom.php new file mode 100644 index 0000000..9ec1f35 --- /dev/null +++ b/lib/smarty/sysplugins/smarty_resource_custom.php @@ -0,0 +1,96 @@ +filepath = strtolower($source->type . ':' . $source->name); + $source->uid = sha1($source->type . ':' . $source->name); + + $mtime = $this->fetchTimestamp($source->name); + if ($mtime !== null) { + $source->timestamp = $mtime; + } else { + $this->fetch($source->name, $content, $timestamp); + $source->timestamp = isset($timestamp) ? $timestamp : false; + if( isset($content) ) + $source->content = $content; + } + $source->exists = !!$source->timestamp; + } + + /** + * Load template's source into current template object + * + * @param Smarty_Template_Source $source source object + * @return string template source + * @throws SmartyException if source cannot be loaded + */ + public function getContent(Smarty_Template_Source $source) + { + $this->fetch($source->name, $content, $timestamp); + if (isset($content)) { + return $content; + } + + throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); + } + + /** + * Determine basename for compiled filename + * + * @param Smarty_Template_Source $source source object + * @return string resource's basename + */ + protected function getBasename(Smarty_Template_Source $source) + { + return basename($source->name); + } + +} + +?> \ No newline at end of file -- cgit v1.2.3