Removing @see declarations
[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 if (!$this->is_loaded('template'))
30 {
31 $this->locate('template');
32 }
33
34 $OBJECT = 'File-Based Template System';
35 $CLASS = 'FS_Template';
36 $OBJ = 'template';
37
38 /**
39 * File System Template System
40 *
41 * This framework merely replaces the template loading functions with
42 * file-system based ones.
43 *
44 * @author Iris Studios, Inc.
45 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
46 * @version $Revision$
47 * @package ISSO
48 *
49 */
50 class FS_Template extends DB_Template
51 {
52 /**
53 * The path, from the path of the application, where templates are stored
54 * @var string
55 */
56 var $templatedir = '';
57
58 /**
59 * The extension all the template files have
60 * @var string
61 */
62 var $extension = 'tpl';
63
64 /**
65 * Takes an array of template names, loads them, and then stores
66 * a parsed version for optimum speed.
67 *
68 * @param array List of template names to be cached
69 */
70 function cache($namearray)
71 {
72 if (sizeof($this->cache) > 0)
73 {
74 trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING);
75 }
76 else
77 {
78 foreach ($namearray AS $name)
79 {
80 $template = $this->_load($name);
81 $template = $this->_parse($template);
82 $this->cache["$name"] = $template;
83 $this->usage["$name"] = 0;
84 }
85 }
86 }
87
88 /**
89 * Loads a template from the file system from the specified $templatedir
90 * with the file extension $extension
91 *
92 * @param string The name of the template call
93 */
94 function _load($name)
95 {
96 global $_isso;
97
98 $path = $_isso->apppath . $this->templatedir . $name . '.' . $this->extension;
99 if (is_file($path))
100 {
101 if (($template = @file_get_contents($path)) !== false)
102 {
103 return $template;
104 }
105 else
106 {
107 trigger_error("Could not load the template '$path'", E_USER_ERROR);
108 exit;
109 }
110 }
111 else
112 {
113 trigger_error("Could not load the template '$path'", E_USER_ERROR);
114 exit;
115 }
116 }
117 }
118
119 /*=====================================================================*\
120 || ###################################################################
121 || # $HeadURL$
122 || # $Id$
123 || ###################################################################
124 \*=====================================================================*/
125 ?>