2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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.
37 * @author Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
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';
60 * Fields array that is used in this module
65 'templatedir' => array(REQ_YES
, 'fetch_sourcepath', false),
66 'extension' => array(REQ_YES
, null, false)
69 // ###################################################################
73 function __construct(&$registry)
75 $this->registry
=& $registry;
78 // ###################################################################
82 function Template_FS(&$registry)
84 $this->__construct($registry);
87 // ###################################################################
93 * @param string Field name
94 * @param mixed Value of the field
96 function set($name, $value)
98 $this->registry
->do_set($name, $value, 'template_fs');
101 // ###################################################################
107 * @param string Field name
109 * @return mixed Value of the field
111 function get($fieldname)
113 return $this->do_get($fieldname, 'template_fs');
116 // ###################################################################
118 * Takes an array of template names, loads them, and then stores a
119 * parsed version for optimum speed.
123 * @param array List of template names to be cached
125 function cache($namearray)
127 if (sizeof($this->cache
) > 0)
129 trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING
);
133 foreach ($namearray AS $name)
135 $template = $this->_load($name);
136 $template = $this->_parse($template);
137 $this->cache
["$name"] = $template;
138 $this->usage["$name"] = 0;
143 // ###################################################################
145 * Loads a template from the file system from the specified
146 * $templatedir with the file extension $extension
150 * @param string The name of the template call
152 function _load($name)
154 $this->registry
->check_isso_fields(get_class($this));
156 $path = $this->registry
->apppath
. $this->templatedir
. $name . '.' . $this->extension
;
159 if (($template = @file_get_contents($path)) !== false)
165 trigger_error("Could not load the template '$path'", E_USER_ERROR);
171 trigger_error("Could not load the template
'$path'", E_USER_ERROR);
177 /*=====================================================================*\
178 || ###################################################################
181 || ###################################################################
182 \*=====================================================================*/