From 55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 10 Nov 2005 12:47:19 +0000 Subject: Initial import of prado framework --- framework/Web/UI/TTemplateManager.php | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 framework/Web/UI/TTemplateManager.php (limited to 'framework/Web/UI/TTemplateManager.php') diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php new file mode 100644 index 00000000..2f8ae688 --- /dev/null +++ b/framework/Web/UI/TTemplateManager.php @@ -0,0 +1,66 @@ +_application=$application; + } + + /** + * @return string id of this module + */ + public function getID() + { + return $this->_id; + } + + /** + * @param string id of this module + */ + public function setID($value) + { + $this->_id=$value; + } + + public function loadTemplateByClassName($className) + { + $class=new ReflectionClass($className); + $tplFile=dirname($class->getFileName()).'/'.$className.self::TEMPLATE_FILE_EXT; + return $this->loadTemplateByFileName($tplFile); + } + + public function loadTemplateByFileName($fileName) + { + if(is_file($fileName)) + { + if(($cache=$this->_application->getCache())===null) + return new TTemplate(file_get_contents($fileName)); + else + { + $array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); + if(is_array($array)) + { + list($template,$timestamp)=$array; + if(filemtime($fileName)<$timestamp) + return $template; + } + $template=new TTemplate(file_get_contents($fileName)); + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,time())); + return $template; + } + } + else + return null; + } +} + +?> \ No newline at end of file -- cgit v1.2.3