1 |
joko |
1.1 |
<?php |
2 |
|
|
/** |
3 |
|
|
* This file contains the Application::ComponentRegistry class. |
4 |
|
|
* |
5 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
joko |
1.2 |
* @package org.netfrag.glib |
7 |
|
|
* @name Application::ComponentRegistry |
8 |
|
|
* |
9 |
joko |
1.1 |
*/ |
10 |
|
|
|
11 |
|
|
/** |
12 |
joko |
1.4 |
* <b>Cvs-Log:</b> |
13 |
|
|
* |
14 |
|
|
* <pre> |
15 |
joko |
1.5 |
* $Id: ComponentRegistry.php,v 1.4 2003/03/11 01:22:22 joko Exp $ |
16 |
joko |
1.2 |
* |
17 |
|
|
* $Log: ComponentRegistry.php,v $ |
18 |
joko |
1.5 |
* Revision 1.4 2003/03/11 01:22:22 joko |
19 |
|
|
* + fixed metadata for phpDocumentor |
20 |
|
|
* |
21 |
joko |
1.4 |
* Revision 1.3 2003/03/10 23:25:02 joko |
22 |
|
|
* + fixed metadata for phpDocumentor |
23 |
|
|
* |
24 |
joko |
1.3 |
* Revision 1.2 2003/03/05 18:54:42 joko |
25 |
|
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
26 |
|
|
* |
27 |
joko |
1.2 |
* Revision 1.1 2003/03/01 15:29:11 joko |
28 |
|
|
* + initial commit |
29 |
joko |
1.4 |
* </pre> |
30 |
joko |
1.1 |
* |
31 |
|
|
*/ |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/** |
35 |
|
|
* This provides an infrastructure for having |
36 |
|
|
* components to be registered with. |
37 |
|
|
* |
38 |
|
|
* These components could be something which make up |
39 |
|
|
* parts, areas or pages on a large website (the level above |
40 |
|
|
* the widget-layer) or just simple plugins or shared code. |
41 |
|
|
* (similar to m$'s dll/com-system, but very lightweight) |
42 |
|
|
* |
43 |
|
|
* Currently, we are registering "Views" with this thing. |
44 |
|
|
* These "Views" should represent the "Views" in the MVC Model. |
45 |
|
|
* "Views" are components made up of phpHtmlLib widgets. |
46 |
|
|
* |
47 |
|
|
* They currently live in the "Page::" namespace, which should be |
48 |
|
|
* migrated to the "View::" namespace to actually represent this |
49 |
|
|
* stuff conveniently 1:1 in userspace. |
50 |
|
|
* |
51 |
|
|
* references: |
52 |
joko |
1.5 |
* - package=org.netfrag.glib, module=DesignPattern::MVC |
53 |
|
|
* - package=lib.admin.frontend, module=TsBackend: $this->_mvc->add_view( ... ) |
54 |
joko |
1.1 |
* |
55 |
|
|
* |
56 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
57 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
58 |
|
|
* @license GNU LGPL (GNU Lesser General Public License) |
59 |
|
|
* |
60 |
joko |
1.2 |
* @link http://www.netfrag.org/~joko/ |
61 |
|
|
* @link http://www.gnu.org/licenses/lgpl.txt |
62 |
joko |
1.1 |
* |
63 |
|
|
* @package org.netfrag.glib |
64 |
joko |
1.2 |
* @subpackage Application |
65 |
|
|
* @name Application::ComponentRegistry |
66 |
joko |
1.1 |
* |
67 |
joko |
1.3 |
* @todo (o) Be able to *persistently* register new components. |
68 |
joko |
1.1 |
* By now the declaration (read-only) is included on each request. |
69 |
|
|
* No caching or similar stuff occours at this level!!! |
70 |
|
|
* |
71 |
|
|
*/ |
72 |
|
|
class Application_ComponentRegistry { |
73 |
|
|
|
74 |
|
|
/** |
75 |
|
|
* This var holds the locator metadata hash |
76 |
|
|
* that is used to feed metadata to a per-query-instance |
77 |
|
|
* of a Data::Driver::Proxy object. |
78 |
|
|
* |
79 |
|
|
*/ |
80 |
|
|
var $_regdb = NULL; |
81 |
|
|
|
82 |
|
|
var $_registry = NULL; |
83 |
|
|
var $_mode = NULL; |
84 |
|
|
|
85 |
|
|
|
86 |
|
|
/** |
87 |
|
|
* The constructor may be used to pass in the |
88 |
|
|
* complete registry as a payload chunk. |
89 |
|
|
* |
90 |
|
|
* @param registry |
91 |
|
|
*/ |
92 |
|
|
function Application_ComponentRegistry($registry = null, $mode = null) { |
93 |
|
|
|
94 |
|
|
$this->_registry = &$registry; |
95 |
|
|
|
96 |
|
|
if ($mode) { |
97 |
|
|
$this->set_mode($mode); |
98 |
|
|
|
99 |
|
|
// autodetect mode |
100 |
|
|
} else { |
101 |
|
|
|
102 |
|
|
if ($registry) { |
103 |
|
|
$this->set_mode('REGDB_PAYLOAD'); |
104 |
|
|
} else { |
105 |
|
|
$this->set_mode('REGDB_CONSTANT'); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
$this->read_regdb(); |
111 |
|
|
|
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
function set_mode( $mode ) { |
115 |
|
|
$this->_mode = $mode; |
116 |
|
|
return $this->_mode; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
function get_mode() { |
120 |
|
|
return $this->_mode; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
function read_regdb() { |
124 |
|
|
switch ($this->get_mode()) { |
125 |
|
|
case 'REGDB_LOCAL': |
126 |
|
|
$this->_regdb = &$this->_registry; |
127 |
|
|
break; |
128 |
|
|
case 'REGDB_CONSTANT': |
129 |
|
|
$this->_regdb = COMPONENT_regdb; |
130 |
|
|
break; |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
function getComponentByTopic($name) { |
136 |
|
|
|
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
function getComponentByPage($name) { |
140 |
|
|
|
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
|
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
?> |