From dc40c5c29cb2d63b42c7b38d55ed9bb2d5820763 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 6 Dec 2006 05:21:41 +0000 Subject: [PATCH] Finished refactoring Template_FS --- template_fs.php | 58 +++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/template_fs.php b/template_fs.php index 043632b..96b525f 100644 --- a/template_fs.php +++ b/template_fs.php @@ -20,13 +20,13 @@ \*=====================================================================*/ /** -* File System Template System -* template_fs.php +* File System Template System (Template_Fs.php) * * @package ISSO */ -$this->load('template', null); +require_once('ISSO/Template.php'); +require_once('ISSO/Functions.php'); /** * File System Template System @@ -40,13 +40,13 @@ $this->load('template', null); * @package ISSO * */ -class Template_FS extends Template +class BSTemplate_FS extends BSTemplate { /** * The path, from the path of the application, where templates are stored * @var string */ - private $templatedir = ''; + private $templateDir = ''; /** * The extension all the template files have @@ -54,48 +54,26 @@ class Template_FS extends Template */ private $extension = 'tpl'; - /** - * Fields array that is used in this module - * @var array - */ - private $fields = array( - 'templatedir' => array(REQ_YES, 'fetch_sourcepath', false), - 'extension' => array(REQ_YES, null, false), - 'pre_parse_hook' => array(REQ_NO, null, false) - ); - // ################################################################### /** - * Constructor - */ - public function __construct(&$registry) - { - $this->registry =& $registry; - } - - // ################################################################### - /** - * Sets an ISSO field + * Sets the template directory name * - * @param string Field name - * @param mixed Value of the field + * @param string Template directory name */ - public function set($name, $value) + public function setTemplateDirectory($dir) { - $this->registry->do_set($name, $value, 'template_fs'); + $this->templateDir = BSFunctions::FetchSourcePath($dir); } // ################################################################### /** - * Gets an ISSO field - * - * @param string Field name + * Sets the file extension for the templates * - * @return mixed Value of the field + * @param string File extension */ - public function get($fieldname) + public function setExtension($ext) { - return $this->do_get($fieldname, 'template_fs'); + $this->extension = $ext; } // ################################################################### @@ -115,8 +93,8 @@ class Template_FS extends Template { foreach ($namearray AS $name) { - $template = $this->_load($name); - $template = $this->_parse($template); + $template = $this->_loadTemplate($name); + $template = $this->_parseTemplate($template); $this->cache["$name"] = $template; $this->usage["$name"] = 0; } @@ -130,11 +108,9 @@ class Template_FS extends Template * * @param string The name of the template call */ - private function _load($name) + private function _loadTemplate($name) { - $this->registry->check_isso_fields(get_class($this)); - - $path = $this->registry->apppath . $this->templatedir . $name . '.' . $this->extension; + $path = BSRegister::GetAppPath() . $this->templateDir . $name . '.' . $this->extension; if (is_file($path)) { if (($template = @file_get_contents($path)) !== false) -- 2.22.5