Fixed faulty documentation.
[isso.git] / template_fs.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 if (!$this->is_loaded('template'))
14 {
15 $this->locate('template');
16 }
17
18 $OBJECT = 'File-Based Template System';
19 $CLASS = 'FS_Template';
20 $OBJ = 'template';
21
22 /**
23 * File System Template System
24 *
25 * This framework merely replaces the template loading functions with
26 * file-system based ones.
27 *
28 * @author Iris Studios, Inc.
29 * @copyright Copyright ©2003 - [#]year[#], Iris Studios, Inc.
30 * @version $Revision$
31 *
32 */
33 class FS_Template extends DB_Template
34 {
35 /**
36 * Global environment variables
37 *
38 * @var templatedir Directory name that houses the templates
39 * @var extension The extension used on template files
40 */
41 var $templatedir = '';
42 var $extension = 'tpl';
43
44 /**
45 * Takes an array of template names, loads them, and then stores
46 * a parsed version for optimum speed.
47 *
48 * @param array List of template names to be cached
49 */
50 function cache($namearray)
51 {
52 if (sizeof($this->cache) > 0)
53 {
54 trigger_error('You cannot cache templates more than once per initialization', ERR_ALERT);
55 }
56 else
57 {
58 foreach ($namearray AS $name)
59 {
60 $template = $this->_load($name);
61 $template = $this->_parse($template);
62 $this->cache["$name"] = $template;
63 $this->usage["$name"] = 0;
64 }
65 }
66 }
67
68 /**
69 * Loads a template from the file system from the specified $templatedir
70 * with the file extension $extension
71 *
72 * @param str The name of the template call
73 */
74 function _load($name)
75 {
76 global $_isso;
77
78 $path = $_isso->apppath . $this->templatedir . $name . '.' . $this->extension;
79 if (is_file($path))
80 {
81 if (($template = @file_get_contents($path)) !== false)
82 {
83 return $template;
84 }
85 else
86 {
87 trigger_error("Could not load the template '$path'", ERR_FATAL);
88 exit;
89 }
90 }
91 else
92 {
93 trigger_error("Could not load the template '$path'", ERR_FATAL);
94 exit;
95 }
96 }
97 }
98
99 /*=====================================================================*\
100 || ###################################################################
101 || # $HeadURL$
102 || # $Id$
103 || ###################################################################
104 \*=====================================================================*/
105 ?>