]> src.bluestatic.org Git - isso.git/blob - Register.php
Removing unused stuff from the kernel so we can see what still needs to be moved
[isso.git] / Register.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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 * ISSO Registry (Register.php)
24 *
25 * @package ISSO
26 */
27
28 // TODO - rename
29 require_once('ISSO/Functions.php');
30
31 /**
32 * Register Class
33 *
34 * This is an ISSO registry class. It holds all of the ISSO system variables as well
35 * as serving as an object registry that is avaliable in the global scope to prevent
36 * globalization of variables.
37 *
38 * @author Blue Static
39 * @copyright Copyright ©2002 - [#]year[#], Blue Static
40 * @version $Revision$
41 * @package ISSO
42 *
43 */
44 class BSRegister
45 {
46 /**
47 * Application name
48 * @var string
49 */
50 private $application = 'Unknown ISSO Project';
51
52 /**
53 * Application path
54 * @var string
55 */
56 private $appPath;
57
58 /**
59 * Application version
60 * @var string
61 */
62 private $appVersion;
63
64 /**
65 * Web path
66 * @var string
67 */
68 private $webPath;
69
70 /**
71 * Debug mode?
72 * @var bool
73 */
74 private $debug = false;
75
76 /**
77 * The master registry list
78 * @var array
79 */
80 private $registry = array();
81
82 // ###################################################################
83 /**
84 * Sets the application name
85 *
86 * @param string Application name
87 */
88 public function setApplication($name)
89 {
90 $this->application = $name;
91 }
92
93 // ###################################################################
94 /**
95 * Gets the application name
96 *
97 * @return string Application name
98 */
99 public function getApplication()
100 {
101 return $this->application;
102 }
103
104 // ###################################################################
105 /**
106 * Sets the application's working path
107 *
108 * @param string Path
109 */
110 public function setAppPath($path)
111 {
112 $this->appPath = BSFunctions::FetchSourcePath($path);
113 }
114
115 // ###################################################################
116 /**
117 * Returns the path to the application
118 *
119 * @return string Application path
120 */
121 public function getAppPath()
122 {
123 return $this->appPath;
124 }
125
126 // ###################################################################
127 /**
128 * Sets the application version
129 *
130 * @param string Application version
131 */
132 public function setAppVersion($vers)
133 {
134 $this->appVersion = $vers;
135 }
136
137 // ###################################################################
138 /**
139 * Gets the application version
140 *
141 * @return string Application version
142 */
143 public function getAppVersion()
144 {
145 return $this->appVersion;
146 }
147
148 // ###################################################################
149 /**
150 * Sets the application's web path, which is the full path from the
151 * server's web root
152 *
153 * @param string Path
154 */
155 public function setWebPath($path)
156 {
157 $this->webPath = BSFunctions::FetchSourcePath($path);
158 }
159
160 // ###################################################################
161 /**
162 * Returns the web path to the application
163 *
164 * @return string Application's web path
165 */
166 public function getWebPath()
167 {
168 return $this->webPath;
169 }
170
171 // ###################################################################
172 /**
173 * Sets the debug state
174 *
175 * @param bool Debug mode on?
176 */
177 public function setDebug($debug)
178 {
179 $this->debug = $debug;
180 }
181
182 // ###################################################################
183 /**
184 * Gets the debug mode state
185 *
186 * @return bool Debug mode on?
187 */
188 public function getDebug()
189 {
190 return $this->debug;
191 }
192
193 // ###################################################################
194 /**
195 * Registers a value in the master registry. You cannot overwrite
196 * values. You must first unregister() them if you wish to do so.
197 *
198 * @param string Registry key
199 * @param mixed Value to register
200 */
201 public function register($key, $value)
202 {
203 if (isset($this->registry["$key"]))
204 {
205 trigger_error('Cannot overwrite a key in the registry');
206 return;
207 }
208
209 $this->registry["$key"] = $value;
210 }
211
212 // ###################################################################
213 /**
214 * Unregisters a value from the registry. This removes all traces of
215 * it from this object.
216 *
217 * @param string Registry key
218 */
219 public function unregister($key)
220 {
221 if (!isset($this->registry["$key"]))
222 {
223 trigger_error('You cannot unregister a key that does not exist');
224 return;
225 }
226
227 unset($this->registry["$key"]);
228 }
229
230 // ###################################################################
231 /**
232 * This gets a value from the registry with a specific key
233 *
234 * @param string The key
235 *
236 * @return mixed Value in the registry for key
237 */
238 public function get($key)
239 {
240 if (!isset($this->registry["$key"]))
241 {
242 trigger_error('Cannot access the registry with a non-existent key');
243 return;
244 }
245
246 return $this->registry["$key"];
247 }
248
249 // ###################################################################
250 /**
251 * Returns the entire registry stack
252 *
253 * @return array Complete registry
254 */
255 public function getAll()
256 {
257 return $this->registry;
258 }
259 }
260
261 /*=====================================================================*\
262 || ###################################################################
263 || # $HeadURL$
264 || # $Id$
265 || ###################################################################
266 \*=====================================================================*/
267 ?>