2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * File System Template System (Template_Fs.php)
28 require_once('ISSO/Template.php');
29 require_once('ISSO/Functions.php');
32 * File System Template System
34 * This framework merely replaces the template loading functions with
35 * file-system based ones.
38 * @copyright Copyright ©2002 - [#]year[#], Blue Static
43 class BSTemplate_FS
extends BSTemplate
46 * The path, from the path of the application, where templates are stored
49 private $templateDir = '';
52 * The extension all the template files have
55 private $extension = 'tpl';
57 // ###################################################################
59 * Sets the template directory name
61 * @param string Template directory name
63 public function setTemplateDirectory($dir)
65 $this->templateDir
= BSFunctions
::FetchSourcePath($dir);
68 // ###################################################################
70 * Sets the file extension for the templates
72 * @param string File extension
74 public function setExtension($ext)
76 $this->extension
= $ext;
79 // ###################################################################
81 * Takes an array of template names, loads them, and then stores a
82 * parsed version for optimum speed.
84 * @param array List of template names to be cached
86 public function cache($namearray)
88 if (sizeof($this->cache
) > 0)
90 trigger_error('You cannot cache templates more than once per initialization');
94 foreach ($namearray AS $name)
96 $template = $this->_loadTemplate($name);
97 $template = $this->_parseTemplate($template);
98 $this->cache
["$name"] = $template;
99 $this->usage["$name"] = 0;
104 // ###################################################################
106 * Loads a template from the file system from the specified
107 * $templatedir with the file extension $extension
109 * @param string The name of the template call
111 private function _loadTemplate($name)
113 $path = BSRegister
::GetAppPath() . $this->templateDir
. $name . '.' . $this->extension
;
116 if (($template = @file_get_contents($path)) !== false)
122 trigger_error("Could not load the template '$path'");
128 trigger_error("Could not load the template
'$path'");
134 /*=====================================================================*\
135 || ###################################################################
138 || ###################################################################
139 \*=====================================================================*/