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
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
49 private $templatedir = '';
52 * The extension all the template files have
55 private $extension = 'tpl';
58 * Fields array that is used in this module
61 private $fields = array(
62 'templatedir' => array(REQ_YES
, 'fetch_sourcepath', false),
63 'extension' => array(REQ_YES
, null, false),
64 'pre_parse_hook' => array(REQ_NO
, null, false)
67 // ###################################################################
71 function __construct(&$registry)
73 $this->registry
=& $registry;
76 // ###################################################################
82 * @param string Field name
83 * @param mixed Value of the field
85 function set($name, $value)
87 $this->registry
->do_set($name, $value, 'template_fs');
90 // ###################################################################
96 * @param string Field name
98 * @return mixed Value of the field
100 function get($fieldname)
102 return $this->do_get($fieldname, 'template_fs');
105 // ###################################################################
107 * Takes an array of template names, loads them, and then stores a
108 * parsed version for optimum speed.
112 * @param array List of template names to be cached
114 function cache($namearray)
116 if (sizeof($this->cache
) > 0)
118 trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING
);
122 foreach ($namearray AS $name)
124 $template = $this->_load($name);
125 $template = $this->_parse($template);
126 $this->cache
["$name"] = $template;
127 $this->usage["$name"] = 0;
132 // ###################################################################
134 * Loads a template from the file system from the specified
135 * $templatedir with the file extension $extension
139 * @param string The name of the template call
141 function _load($name)
143 $this->registry
->check_isso_fields(get_class($this));
145 $path = $this->registry
->apppath
. $this->templatedir
. $name . '.' . $this->extension
;
148 if (($template = @file_get_contents($path)) !== false)
154 trigger_error("Could not load the template '$path'", E_USER_ERROR);
160 trigger_error("Could not load the template
'$path'", E_USER_ERROR);
166 /*=====================================================================*\
167 || ###################################################################
170 || ###################################################################
171 \*=====================================================================*/