On full page generators, don't show the navigation
[isso.git] / template_fs.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * File System Template System
24 * template_fs.php
25 *
26 * @package ISSO
27 */
28
29 $this->load('template', null);
30
31 /**
32 * File System Template System
33 *
34 * This framework merely replaces the template loading functions with
35 * file-system based ones.
36 *
37 * @author Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
39 * @version $Revision$
40 * @package ISSO
41 *
42 */
43 class Template_FS extends Template
44 {
45 /**
46 * The path, from the path of the application, where templates are stored
47 * @var string
48 * @access private
49 */
50 var $templatedir = '';
51
52 /**
53 * The extension all the template files have
54 * @var string
55 * @access private
56 */
57 var $extension = 'tpl';
58
59 /**
60 * Fields array that is used in this module
61 * @var array
62 * @access private
63 */
64 var $fields = array(
65 'templatedir' => array(REQ_YES, 'fetch_sourcepath', false),
66 'extension' => array(REQ_YES, null, false),
67 'pre_parse_hook' => array(REQ_NO, null, false)
68 );
69
70 // ###################################################################
71 /**
72 * Constructor
73 */
74 function __construct(&$registry)
75 {
76 $this->registry =& $registry;
77 }
78
79 // ###################################################################
80 /**
81 * (PHP 4) Constructor
82 */
83 function Template_FS(&$registry)
84 {
85 $this->__construct($registry);
86 }
87
88 // ###################################################################
89 /**
90 * Sets an ISSO field
91 *
92 * @access public
93 *
94 * @param string Field name
95 * @param mixed Value of the field
96 */
97 function set($name, $value)
98 {
99 $this->registry->do_set($name, $value, 'template_fs');
100 }
101
102 // ###################################################################
103 /**
104 * Gets an ISSO field
105 *
106 * @access public
107 *
108 * @param string Field name
109 *
110 * @return mixed Value of the field
111 */
112 function get($fieldname)
113 {
114 return $this->do_get($fieldname, 'template_fs');
115 }
116
117 // ###################################################################
118 /**
119 * Takes an array of template names, loads them, and then stores a
120 * parsed version for optimum speed.
121 *
122 * @access public
123 *
124 * @param array List of template names to be cached
125 */
126 function cache($namearray)
127 {
128 if (sizeof($this->cache) > 0)
129 {
130 trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING);
131 }
132 else
133 {
134 foreach ($namearray AS $name)
135 {
136 $template = $this->_load($name);
137 $template = $this->_parse($template);
138 $this->cache["$name"] = $template;
139 $this->usage["$name"] = 0;
140 }
141 }
142 }
143
144 // ###################################################################
145 /**
146 * Loads a template from the file system from the specified
147 * $templatedir with the file extension $extension
148 *
149 * @access private
150 *
151 * @param string The name of the template call
152 */
153 function _load($name)
154 {
155 $this->registry->check_isso_fields(get_class($this));
156
157 $path = $this->registry->apppath . $this->templatedir . $name . '.' . $this->extension;
158 if (is_file($path))
159 {
160 if (($template = @file_get_contents($path)) !== false)
161 {
162 return $template;
163 }
164 else
165 {
166 trigger_error("Could not load the template '$path'", E_USER_ERROR);
167 exit;
168 }
169 }
170 else
171 {
172 trigger_error("Could not load the template '$path'", E_USER_ERROR);
173 exit;
174 }
175 }
176 }
177
178 /*=====================================================================*\
179 || ###################################################################
180 || # $HeadURL$
181 || # $Id$
182 || ###################################################################
183 \*=====================================================================*/
184 ?>