2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
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
29 $this->load('template', null
);
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 Template_FS
extends Template
46 * The path, from the path of the application, where templates are stored
50 var $templatedir = '';
53 * The extension all the template files have
57 var $extension = 'tpl';
59 // ###################################################################
63 function __construct(&$registry)
65 $this->registry
=& $registry;
68 // ###################################################################
72 function Template_FS(&$registry)
74 $this->__construct($registry);
77 // ###################################################################
79 * Sets the template directory
83 * @param string The template directory
85 function setTemplateDir($path)
87 $this->templatedir
= $this->registry
->fetch_sourcepath($path);
90 // ###################################################################
92 * Sets the file extension
96 * @param string File extension
98 function setExtension($ext)
100 $this->extension
= $ext;
103 // ###################################################################
105 * Takes an array of template names, loads them, and then stores a
106 * parsed version for optimum speed.
110 * @param array List of template names to be cached
112 function cache($namearray)
114 if (sizeof($this->cache
) > 0)
116 trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING
);
120 foreach ($namearray AS $name)
122 $template = $this->_load($name);
123 $template = $this->_parse($template);
124 $this->cache
["$name"] = $template;
125 $this->usage
["$name"] = 0;
130 // ###################################################################
132 * Loads a template from the file system from the specified
133 * $templatedir with the file extension $extension
137 * @param string The name of the template call
139 function _load($name)
141 $path = $this->registry
->apppath
. $this->templatedir
. $name . '.' . $this->extension
;
144 if (($template = @file_get_contents($path)) !== false
)
150 trigger_error("Could not load the template '$path'", E_USER_ERROR
);
156 trigger_error("Could not load the template '$path'", E_USER_ERROR
);
162 /*=====================================================================*\
163 || ###################################################################
166 || ###################################################################
167 \*=====================================================================*/