/[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.14 - (show annotations)
Wed Apr 9 00:31:27 2003 UTC (21 years, 3 months ago) by jonen
Branch: MAIN
Changes since 1.13: +13 -1 lines
+ added arguments for data list ecom

1 <?
2 /*
3 ## -----------------------------------------------------------------------------
4 ## $Id: AbstractExplorer.php,v 1.13 2003/04/09 00:03:11 jonen Exp $
5 ## -----------------------------------------------------------------------------
6 ## $Log: AbstractExplorer.php,v $
7 ## Revision 1.13 2003/04/09 00:03:11 jonen
8 ## disabled form rendering for inheritanced items at 'list'
9 ##
10 ## Revision 1.12 2003/04/08 17:52:12 joko
11 ## CHANGE: renamed property 'datasource' to 'transport'
12 ## NEW: Module 'RemoteAction'
13 ##
14 ## Revision 1.11 2003/04/07 22:31:51 jonen
15 ## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav'
16 ## - removed recent added ecom type chooser
17 ##
18 ## Revision 1.10 2003/04/05 20:32:04 joko
19 ## added Chooser
20 ##
21 ## Revision 1.9 2003/04/04 02:22:37 joko
22 ## minor fix: querySchema now issues argument
23 ##
24 ## Revision 1.8 2003/04/04 01:16:03 jonen
25 ## + integrated different mode's for 'DataItem'
26 ##
27 ## Revision 1.7 2003/03/29 07:49:55 joko
28 ## show boxes in DEBUG-mode only!
29 ##
30 ## Revision 1.6 2003/03/28 06:42:37 joko
31 ## fix: propagating rpc-debugging-options to constants here
32 ##
33 ## Revision 1.5 2003/03/27 01:24:29 jonen
34 ## + enabled navigation ecom (only list yet)
35 ##
36 ## Revision 1.4 2003/03/20 08:02:11 jonen
37 ## + purged code
38 ##
39 ## Revision 1.3 2003/03/20 07:54:52 jonen
40 ## + added docu
41 ##
42 ## Revision 1.2 2003/03/20 07:44:31 jonen
43 ## + removed dumper
44 ##
45 ## Revision 1.1 2003/03/20 03:48:46 jonen
46 ## + initial commit
47 ##
48 ## Revision 1.1 2003/03/08 02:36:17 cvsmax
49 ## + moved from *.inc
50 ## + mungled namespace with WebExplorer
51 ##
52 ## Revision 1.3 2003/03/03 22:25:21 joko
53 ## fixed minor typos
54 ## namespace mungling
55 ##
56 ## Revision 1.2 2003/03/02 00:48:49 cvsmax
57 ## + set up gui module registry
58 ## - purged old/sample code
59 ##
60 ## Revision 1.1 2003/03/01 22:57:32 cvsmax
61 ## + inital commit
62 ##
63 ##
64 ## -----------------------------------------------------------------------------
65 */
66
67 /**
68 * WebExplorer::AbstractExplorer - this can be simple compared to a container,
69 * which modular GUI classes can be register, manipulated and rendered...
70 *
71 * @author Sebastian Utz <seut@tunemedia.de>
72 * @package org.netfrag.app
73 * @name WebExplorer::AbstractExplorer
74 */
75
76
77 class WebExplorer_AbstractExplorer {
78
79 /**
80 * container holds meta information of data locators
81 */
82 var $_data_locators = array();
83
84 /**
85 * container for registered modules
86 */
87 var $_module = array();
88
89 /**
90 * container holds references to each ecom
91 */
92 var $_ecom = array();
93
94 /**
95 * holds the whole page state
96 */
97 var $_state = array();
98
99 /**
100 * holds state variables only needed for explorer
101 */
102 var $_e_state = array();
103
104
105 function WebExplorer_AbstractExplorer($data_locators=array()) {
106 $this->_data_locators = $data_locators;
107 $this->init_default_gui_modules();
108 $this->set_e_state();
109
110 //debug
111 //print "State: " . Dumper($this->_state) ."<br>";
112 $div = html_div();
113 $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
114 $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
115 if (constants::get('DEBUG')) {
116 print $div->render();
117 }
118 }
119
120
121 function add_data_locator($label, $args) {
122 $this->_data_locators[$label] = $args;
123 }
124
125 function set_data_locator($label, $new_args=array() ) {
126 global $app;
127 //print Dumper($app) . "<br>";
128 if($label == "rpc") {
129 $rpcinfo = $app->getConfig("rpcinfo");
130 define('RPC_HOSTNAME', $rpcinfo[Host]);
131 define('RPC_PORT', $rpcinfo[Port]);
132 define('RPC_DEBUG', $rpcinfo[DEBUG]);
133 define('RPC_TRACE', $rpcinfo[TRACE]);
134 define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
135 } else {
136 user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");
137 }
138 }
139
140 function get_data_locator($label) {
141 }
142
143 function get_page_state() {
144 $requestTracker = mkObject("Application::Request::Tracker");
145 $this->_state = $requestTracker->getPointer();
146 }
147
148 function set_e_state() {
149 $this->get_page_state();
150 $this->_e_state = $this->_state[options][options];
151 }
152
153
154 function set_page_state() {
155 user_error("AbstractExplorer::set_page_state - please implement me....");
156 }
157
158
159 function init_default_gui_modules() {
160
161 // format of parameters: label, ecom_type, abstract_type, module_name
162
163 //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
164 $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
165 $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
166 $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
167 // 2003-04-05 - Chooser
168 $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
169 // 2003-04-07 - RemoteAction
170 $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");
171 }
172
173 function register_source_module($label, $args) {
174 $this->_module['source'][$label] = $args;
175 }
176
177 function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
178 $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
179 }
180
181
182 function &get_ecom($label) {
183 //return "Hello World";
184 $this->_load_ecom($label);
185 return $this->_ecom[$label];
186 }
187
188
189
190 function _load_ecoms() {
191 //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
192 foreach($this->_e_state[ecoms] as $label => $val) {
193 $this->_load_ecom($label);
194 }
195 }
196
197
198
199 function _load_ecom($label) {
200 // fetch values from state
201 $val = $this->_e_state['ecoms'][$label];
202 debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
203
204 // find right ecom gui module
205 $ecom_type = $val['ecom_type'];
206 $abstract_type = $val['ecom_abstract_type'];
207 $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
208 //print Dumper($gui_module);
209 if(!$gui_module) {
210 user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
211 return;
212 }
213
214 // get arguments needed for ecom gui module
215 $args = $this->_prepare_component_args($label);
216 //print Dumper($args);
217
218 // get ecom GUI module
219 if (!$ecom = php::mkComponent($gui_module, $args)) {
220 return;
221 }
222 //print Dumper($ecom);
223
224 // load phphtmllib GUI object
225 $gui_ecom = &$ecom->get();
226
227 // add hidden vars, needed for explorer control
228 $hidden_items = $this->_get_hidden_items($label);
229 if(is_array($hidden_items) ) {
230 $ecom->add_hidden_items($hidden_items);
231 //print "Hidden: " . Dumper($hidden_items);
232 }
233
234 // attempt:
235 //$gui_ecom->make_transparent();
236
237 // store phphtmllib GUI object
238 $this->_ecom[$label] = &$gui_ecom;
239 }
240
241
242
243 function _get_hidden_items($label) {
244 $ecom_state = $this->_e_state['ecoms'][$label];
245 if($ecom_state['ecom_type'] == "data") {
246 if($ecom_state['ecom_abstract_type'] == "list") {
247 $hidden_items = array(
248 'ecl' => $label,
249 'ecat' => "item",
250 'ecmod' => "view",
251 );
252 }
253 elseif($ecom_state['ecom_abstract_type'] == "item") {
254 $hidden_items = array(
255 'ecl' => $label,
256 'ecat' => "item",
257 'ecmod' => "view",
258 );
259 /*
260 if($ecom_state['ecom_mode'] == "view") {
261 $hidden_items['ecmod'] = "edit";
262 }
263 elseif($ecom_state['ecom_mode'] == "edit") {
264 $hidden_items['ecmod'] = "edit";
265 }
266 */
267 }
268 $hidden_items['ap'] = "explorer";
269 }
270 return $hidden_items;
271 }
272
273
274
275 function _prepare_component_args($label) {
276 $val = $this->_e_state['ecoms'][$label];
277 $this->set_data_locator($val['ecom_data_locator_key']);
278
279 // detect and execute 'selectSource' action
280 // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
281 //print Dumper($this->_e_state['sources']);
282 if ($source = $this->_e_state['main']['ecom_data_source_key']) {
283 //print "selectSource: $source<br/>";
284 //global $app;
285 //print Dumper($backend);
286 //$app->backend->do();
287 }
288
289 // switch component type
290 if($val['ecom_type'] == "data") {
291 // switch abstract type
292 if($val['ecom_abstract_type'] == "list") {
293 if($val['ecom_data_locator_key'] == "rpc") {
294 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
295 $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
296 } else {
297 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
298 }
299 $args = array(
300 'caption' => $val['ecom_data_ident'],
301 'orderby' => "Guid",
302 'options' => array(
303 'data_locator_meta' => $data_locator_meta,
304 'decode' => 1,
305 'decode_args' => array(
306 'seperator' => "_",
307 //'form' => 1,
308 ),
309 'actionbar' => array(
310 'name' => "ecdfa",
311 'list' => array(
312 "View" => 'view',
313 "Edit" => 'edit',
314 "Delete" => 'delete',
315 "Add new" => 'add',
316 ),
317 ),
318 ),
319 );
320 // switch abstract type
321 } elseif ($val['ecom_abstract_type'] == "item") {
322 if($val['ecom_data_locator_key'] == "rpc") {
323 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
324 $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);
325 } else {
326 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
327 }
328 if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
329 print "Mode: $val[ecom_mode]<br>";
330 $args = array(
331 'caption' => $val['ecom_data_meta'],
332 'mode' => $val['ecom_mode'],
333 'options' => array(
334 'data_locator_meta' => $data_locator_meta,
335 'decode' => 1,
336 'decode_args' => array(
337 'seperator' => "_",
338 ),
339 ),
340 );
341 if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
342 }
343
344 // switch component type
345 } elseif ($val['ecom_type'] == "nav") {
346 // switch abstract type
347 if($val['ecom_abstract_type'] == "list") {
348 $args = array();
349 if($val['ecom_data_locator_key'] == "rpc") {
350 // switch component label
351 if($label == "nav") {
352 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
353 $args['caption'] = "Objekt Typen";
354 }
355 // NEW [2003-04-05]: DataSource.Chooser
356 elseif ($label == "chooser") {
357 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
358 $args['caption'] = "Datenquellen";
359 }
360 $args['options']['data_locator_meta'] = $data_locator_meta;
361 } else {
362 user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
363 }
364 } elseif ($val['ecom_abstract_type'] == "tree") {
365 $args = array();
366 }
367
368 // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
369 // switch component type
370 } elseif ($val['ecom_type'] == "call") {
371
372 // responses of RemoteActions are not predictable!
373 if ($val['ecom_abstract_type'] == "auto") {
374
375 // Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere!
376
377 // Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently.
378 // Really - just a remote call is issued, no data-/schema-structures or similar are expected.
379
380 // The RemoteMethod 'method' is called directly with arguments in 'args'!
381 // As response (important for widget assignement!) you may expect an arbitrary payload.
382 $args['options']['data_locator_meta'] = array(
383 transport => 'rpc',
384 metatype => 'method',
385 method => $val['ecom_call_method'],
386 args => $val['ecom_call_args']
387 );
388
389 } else {
390 // FIXME: implement automatic re-dispatching to available ecoms here!
391 user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
392 }
393
394 }
395 return $args;
396 }
397
398
399
400 function get_msg($label) {
401 if($label == "welcome") {
402 $msg = "Welcome to the Explorer.";
403 }
404 return $msg;
405 }
406
407
408
409 function render() {
410 user_error("AbstractExplorer::render - please implement me....");
411 }
412
413 }
414
415
416 ?>

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