Added visibility information to all the functions
[isso.git] / template_fs.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
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 * Framework registry object
47 * @var object
48 */
49 var $registry = null;
50
51 /**
52 * The path, from the path of the application, where templates are stored
53 * @var string
54 */
55 var $templatedir = '';
56
57 /**
58 * The extension all the template files have
59 * @var string
60 */
61 var $extension = 'tpl';
62
63 /**
64 * Constructor
65 */
66 function __construct(&$registry)
67 {
68 $this->registry =& $registry;
69 }
70
71 /**
72 * (PHP 4) Constructor
73 */
74 function Template_FS(&$registry)
75 {
76 $this->__construct($registry);
77 }
78
79 /**
80 * Takes an array of template names, loads them, and then stores
81 * a parsed version for optimum speed.
82 *
83 * @access public
84 *
85 * @param array List of template names to be cached
86 */
87 function cache($namearray)
88 {
89 if (sizeof($this->cache) > 0)
90 {
91 trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING);
92 }
93 else
94 {
95 foreach ($namearray AS $name)
96 {
97 $template = $this->_load($name);
98 $template = $this->_parse($template);
99 $this->cache["$name"] = $template;
100 $this->usage["$name"] = 0;
101 }
102 }
103 }
104
105 /**
106 * Loads a template from the file system from the specified $templatedir
107 * with the file extension $extension
108 *
109 * @access private
110 *
111 * @param string The name of the template call
112 */
113 function _load($name)
114 {
115 $path = $this->registry->apppath . $this->templatedir . $name . '.' . $this->extension;
116 if (is_file($path))
117 {
118 if (($template = @file_get_contents($path)) !== false)
119 {
120 return $template;
121 }
122 else
123 {
124 trigger_error("Could not load the template '$path'", E_USER_ERROR);
125 exit;
126 }
127 }
128 else
129 {
130 trigger_error("Could not load the template '$path'", E_USER_ERROR);
131 exit;
132 }
133 }
134 }
135
136 /*=====================================================================*\
137 || ###################################################################
138 || # $HeadURL$
139 || # $Id$
140 || ###################################################################
141 \*=====================================================================*/
142 ?>