/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Fri Apr 4 02:22:37 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.8: +5 -2 lines
minor fix: querySchema now issues argument

1 <?
2 /*
3 ## -----------------------------------------------------------------------------
4 ## $Id: AbstractExplorer.php,v 1.8 2003/04/04 01:16:03 jonen Exp $
5 ## -----------------------------------------------------------------------------
6 ## $Log: AbstractExplorer.php,v $
7 ## Revision 1.8 2003/04/04 01:16:03 jonen
8 ## + integrated different mode's for 'DataItem'
9 ##
10 ## Revision 1.7 2003/03/29 07:49:55 joko
11 ## show boxes in DEBUG-mode only!
12 ##
13 ## Revision 1.6 2003/03/28 06:42:37 joko
14 ## fix: propagating rpc-debugging-options to constants here
15 ##
16 ## Revision 1.5 2003/03/27 01:24:29 jonen
17 ## + enabled navigation ecom (only list yet)
18 ##
19 ## Revision 1.4 2003/03/20 08:02:11 jonen
20 ## + purged code
21 ##
22 ## Revision 1.3 2003/03/20 07:54:52 jonen
23 ## + added docu
24 ##
25 ## Revision 1.2 2003/03/20 07:44:31 jonen
26 ## + removed dumper
27 ##
28 ## Revision 1.1 2003/03/20 03:48:46 jonen
29 ## + initial commit
30 ##
31 ## Revision 1.1 2003/03/08 02:36:17 cvsmax
32 ## + moved from *.inc
33 ## + mungled namespace with WebExplorer
34 ##
35 ## Revision 1.3 2003/03/03 22:25:21 joko
36 ## fixed minor typos
37 ## namespace mungling
38 ##
39 ## Revision 1.2 2003/03/02 00:48:49 cvsmax
40 ## + set up gui module registry
41 ## - purged old/sample code
42 ##
43 ## Revision 1.1 2003/03/01 22:57:32 cvsmax
44 ## + inital commit
45 ##
46 ##
47 ## -----------------------------------------------------------------------------
48 */
49
50 /**
51 * WebExplorer::AbstractExplorer - this can be simple compared to a container,
52 * which modular GUI classes can be register, manipulated and rendered...
53 *
54 * @author Sebastian Utz <seut@tunemedia.de>
55 * @package org.netfrag.app
56 * @name WebExplorer::AbstractExplorer
57 */
58
59
60 class WebExplorer_AbstractExplorer {
61
62 /**
63 * container holds meta information of data locators
64 */
65 var $_data_locators = array();
66
67 /**
68 * container for registered modules
69 */
70 var $_module = array();
71
72 /**
73 * container holds references to each ecom
74 */
75 var $_ecom = array();
76
77 /**
78 * holds the whole page state
79 */
80 var $_state = array();
81
82 /**
83 * holds state variables only needed for explorer
84 */
85 var $_e_state = array();
86
87
88 function WebExplorer_AbstractExplorer($data_locators=array()) {
89 $this->_data_locators = $data_locators;
90 $this->init_default_gui_modules();
91
92 $this->set_e_state();
93 //print "State: " . Dumper($this->_state) ."<br>";
94 $div = html_div();
95 $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
96 $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
97 if (constants::get('DEBUG')) {
98 print $div->render();
99 }
100 //$this->init_state();
101 }
102
103
104 function add_data_locator($label, $args) {
105 $this->_data_locators[$label] = $args;
106 }
107
108 function set_data_locator($label, $new_args=array() ) {
109 global $app;
110 //print Dumper($app) . "<br>";
111 if($label == "rpc") {
112 $rpcinfo = $app->getConfig("rpcinfo");
113 define('RPC_HOSTNAME', $rpcinfo[Host]);
114 define('RPC_PORT', $rpcinfo[Port]);
115 define('RPC_DEBUG', $rpcinfo[DEBUG]);
116 define('RPC_TRACE', $rpcinfo[TRACE]);
117 define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
118 } else {
119 user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");
120 }
121 }
122
123 function get_data_locator($label) {
124 }
125
126 function get_page_state() {
127 $requestTracker = mkObject("Application::Request::Tracker");
128 $this->_state = $requestTracker->getPointer();
129 }
130
131 function set_e_state() {
132 $this->get_page_state();
133 $this->_e_state = $this->_state[options][options];
134 }
135
136
137 function set_page_state() {
138 user_error("AbstractExplorer::set_page_state - please implement me....");
139 }
140
141
142 function init_default_gui_modules() {
143 //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
144 $this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") );
145 $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );
146 $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );
147 }
148
149 function register_source_module($label, $args) {
150 $this->_module['source'][$label] = $args;
151 }
152
153 function register_gui_module($abstract_type, $ecom_type, $args) {
154 $this->_module['gui'][$ecom_type][$abstract_type] = $args;
155 }
156
157 function &get_ecom($label) {
158 //return "Hello World";
159 $this->_load_ecom($label);
160 return $this->_ecom[$label];
161 }
162
163 function _load_ecoms() {
164 foreach($this->_e_state[ecoms] as $label => $val) {
165 $this->_load_ecom($label);
166 }
167 }
168
169 function _load_ecom($label) {
170 $val = $this->_e_state['ecoms'][$label];
171 // find right gui module
172 $com_type = $val['ecom_type'];
173 $abstract_type = $val['ecom_abstract_type'];
174 $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];
175 if(!$gui_module) {
176 user_error("AbstractExplorer::_load_component - No GUI module found for abstract type $val[ecom_abstract_type] ecom type $val[ecom_type] !");
177 return;
178 }
179 // get arguments needed for gui module
180 $args = $this->_prepare_component_args($label);
181 //print Dumper($args);
182
183 // get GUI module
184 $ecom = php::mkComponent($gui_module, $args);
185 //print Dumper($ecom);
186
187 // get phphtmllib GUI object
188 $gui_ecom = &$ecom->get();
189
190 // add hidden vars, needed for explorer control
191 $hidden_items = $this->_get_hidden_items($label);
192 if(is_array($hidden_items) ) {
193 $ecom->add_hidden_items($hidden_items);
194 //print "Hidden: " . Dumper($hidden_items);
195 }
196
197 $this->_ecom[$label] = &$gui_ecom;
198 }
199
200 function _get_hidden_items($label) {
201 $ecom_state = $this->_e_state['ecoms'][$label];
202 if($ecom_state['ecom_type'] == "data") {
203 if($ecom_state['ecom_abstract_type'] == "list") {
204 $hidden_items = array(
205 'ecl' => $label,
206 'ecat' => "item",
207 'ecmod' => "view",
208 );
209 }
210 elseif($ecom_state['ecom_abstract_type'] == "item") {
211 $hidden_items = array(
212 'ecl' => $label,
213 'ecat' => "item",
214 'ecmod' => "view",
215 );
216 /*
217 if($ecom_state['ecom_mode'] == "view") {
218 $hidden_items['ecmod'] = "edit";
219 }
220 elseif($ecom_state['ecom_mode'] == "edit") {
221 $hidden_items['ecmod'] = "edit";
222 }
223 */
224 }
225 $hidden_items['ap'] = "explorer";
226 }
227 return $hidden_items;
228 }
229
230 function _prepare_component_args($label) {
231 $val = $this->_e_state['ecoms'][$label];
232 $this->set_data_locator($val['ecom_data_locator_key']);
233 // switch component type
234 if($val['ecom_type'] == "data") {
235 // switch abstract type
236 if($val['ecom_abstract_type'] == "list") {
237 if($val['ecom_data_locator_key'] == "rpc") {
238 //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
239 $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
240 } else {
241 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
242 }
243 $args = array(
244 'caption' => "Liste",
245 'orderby' => "Guid",
246 'options' => array(
247 'data_locator_meta' => $data_locator_meta,
248 'decode' => 1,
249 'decode_args' => array(
250 'seperator' => "_",
251 'form' => 1,
252 ),
253 ),
254 );
255 // switch abstract type
256 } elseif ($val['ecom_abstract_type'] == "item") {
257 if($val['ecom_data_locator_key'] == "rpc") {
258 //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
259 $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);
260 } else {
261 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
262 }
263 if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
264 print "Mode: $val[ecom_mode]<br>";
265 $args = array(
266 'caption' => "Item",
267 'mode' => $val['ecom_mode'],
268 'options' => array(
269 'data_locator_meta' => $data_locator_meta,
270 'decode' => 1,
271 'decode_args' => array(
272 'seperator' => "_",
273 ),
274 ),
275 );
276 if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
277 }
278 // switch component type
279 } elseif ($val['ecom_type'] == "nav") {
280 // switch abstract type
281 if($val['ecom_abstract_type'] == "list") {
282 if($val['ecom_data_locator_key'] == "rpc") {
283 $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'concrete' );
284 } else {
285 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
286 }
287 $args = array(
288 'caption' => "Objekt Typen",
289 'options' => array(
290 'data_locator_meta' => $data_locator_meta,
291 ),
292 );
293 } elseif ($val['ecom_abstract_type'] == "tree") {
294 $args = array();
295 }
296 }
297 return $args;
298 }
299
300 function get_msg($label) {
301 if($label == "welcome") {
302 $msg = "Welcome to the Explorer.";
303 }
304 return $msg;
305 }
306
307 function render() {
308 user_error("AbstractExplorer::render - please implement me....");
309 }
310
311 }
312
313
314 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed