/[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.28 - (show annotations)
Tue Aug 31 14:15:49 2004 UTC (19 years, 10 months ago) by jonen
Branch: MAIN
Changes since 1.27: +11 -1 lines
+ added function to clear 'ecom' state
   (specially needed to refresh the 'content' block)

1 <?
2 /*
3 ## -----------------------------------------------------------------------------
4 ## $Id: AbstractExplorer.php,v 1.27 2004/03/11 21:01:35 jonen Exp $
5 ## -----------------------------------------------------------------------------
6 ## $Log: AbstractExplorer.php,v $
7 ## Revision 1.27 2004/03/11 21:01:35 jonen
8 ## minor change
9 ##
10 ## Revision 1.26 2003/12/14 01:50:30 jonen
11 ## implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes
12 ##
13 ## Revision 1.25 2003/11/22 18:47:49 udo
14 ## update for expand data item
15 ##
16 ## Revision 1.24 2003/07/02 11:39:16 jonen
17 ## fixed bugs
18 ##
19 ## Revision 1.23 2003/06/06 11:57:20 joko
20 ## minor update: cosmetic changes
21 ##
22 ## Revision 1.22 2003/05/13 14:50:27 joko
23 ## HACKed compatibility for config-type data sources
24 ## + function get_data_filter
25 ##
26 ## Revision 1.21 2003/05/10 18:23:21 jonen
27 ## + added stuff relating to 'create/add new' links/buttons
28 ##
29 ## Revision 1.20 2003/04/19 16:24:49 jonen
30 ## + added two more GUI modules to default registry initiation,
31 ## relating to new navigation module 'NavigationTree'
32 ## + added prepartion of needed args for abstract navigation tree
33 ## and concret UserManagment 'UMnav' tree
34 ##
35 ## Revision 1.19 2003/04/18 16:21:37 joko
36 ## fixed commit comment - the last one caused a syntax error!!!
37 ##
38 ## Revision 1.18 2003/04/18 15:27:06 joko
39 ## NEW: XML Trees in data area
40 ## new ecom module: DataTree
41 ## introduced new query argument: 'filter' (purpose: xml/tree filtering)
42 ## $filter = array(
43 ## dotted => $val['ecom_data_filter'],
44 ## ident => $val['ecom_data_ident'],
45 ## );
46 ## A Data::Lift module translates this filter-query into a XPath-query ...
47 ## $filter = array(
48 ## xpq => '*\/*[@name="cli"]',
49 ## );
50 ## ... which finally is propagated to the backend.
51 ## NEW: AbstractExplorer - standalone version
52 ## enhanced set_e_state: now can overwrite internal state to arguments from outside
53 ## enhanced get_com: also capable of propagating additional args through _load_ecom to _prepare_component_args
54 ## enhanced _prepare_component_args: now able to dispatch to a "transparent navigation ecom" (e.g. YAA::JobGroups)
55 ## MISC:
56 ## added some pre-flight checks throughout the module, especially at the core dispatcher inside _prepare_component_args
57 ## error checking: added some more croaks via 'user_error'
58 ## cosmetic updates
59 ##
60 ## Revision 1.17 2003/04/18 13:46:15 jonen
61 ## + add hidden elements(items) now to the constructor arguments of each ecom
62 ##
63 ## Revision 1.16 2003/04/10 06:00:58 joko
64 ## ALPHA: Item.Delete
65 ##
66 ## Revision 1.15 2003/04/09 02:08:20 joko
67 ## CHANGE: renamed key 'classname' through 'nodename'
68 ##
69 ## Revision 1.14 2003/04/09 00:31:27 jonen
70 ## + added arguments for data list ecom
71 ##
72 ## Revision 1.13 2003/04/09 00:03:11 jonen
73 ## disabled form rendering for inheritanced items at 'list'
74 ##
75 ## Revision 1.12 2003/04/08 17:52:12 joko
76 ## CHANGE: renamed property 'datasource' to 'transport'
77 ## NEW: Module 'RemoteAction'
78 ##
79 ## Revision 1.11 2003/04/07 22:31:51 jonen
80 ## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav'
81 ## - removed recent added ecom type chooser
82 ##
83 ## Revision 1.10 2003/04/05 20:32:04 joko
84 ## added Chooser
85 ##
86 ## Revision 1.9 2003/04/04 02:22:37 joko
87 ## minor fix: querySchema now issues argument
88 ##
89 ## Revision 1.8 2003/04/04 01:16:03 jonen
90 ## + integrated different mode's for 'DataItem'
91 ##
92 ## Revision 1.7 2003/03/29 07:49:55 joko
93 ## show boxes in DEBUG-mode only!
94 ##
95 ## Revision 1.6 2003/03/28 06:42:37 joko
96 ## fix: propagating rpc-debugging-options to constants here
97 ##
98 ## Revision 1.5 2003/03/27 01:24:29 jonen
99 ## + enabled navigation ecom (only list yet)
100 ##
101 ## Revision 1.4 2003/03/20 08:02:11 jonen
102 ## + purged code
103 ##
104 ## Revision 1.3 2003/03/20 07:54:52 jonen
105 ## + added docu
106 ##
107 ## Revision 1.2 2003/03/20 07:44:31 jonen
108 ## + removed dumper
109 ##
110 ## Revision 1.1 2003/03/20 03:48:46 jonen
111 ## + initial commit
112 ##
113 ## Revision 1.1 2003/03/08 02:36:17 cvsmax
114 ## + moved from *.inc
115 ## + mungled namespace with WebExplorer
116 ##
117 ## Revision 1.3 2003/03/03 22:25:21 joko
118 ## fixed minor typos
119 ## namespace mungling
120 ##
121 ## Revision 1.2 2003/03/02 00:48:49 cvsmax
122 ## + set up gui module registry
123 ## - purged old/sample code
124 ##
125 ## Revision 1.1 2003/03/01 22:57:32 cvsmax
126 ## + inital commit
127 ##
128 ##
129 ## -----------------------------------------------------------------------------
130 */
131
132 /**
133 * WebExplorer::AbstractExplorer - this can be simple compared to a container,
134 * which modular GUI classes can be register, manipulated and rendered...
135 *
136 * @author Sebastian Utz <seut@tunemedia.de>
137 * @package org.netfrag.app
138 * @name WebExplorer::AbstractExplorer
139 */
140
141
142 class WebExplorer_AbstractExplorer {
143
144 /**
145 * container holds meta information of data locators
146 */
147 var $_data_locators = array();
148
149 /**
150 * container for registered modules
151 */
152 var $_module = array();
153
154 /**
155 * container holds references to each ecom
156 */
157 var $_ecom = array();
158
159 /**
160 * holds the whole page state
161 */
162 var $_state = array();
163
164 /**
165 * holds state variables only needed for explorer
166 */
167 var $_e_state = array();
168
169
170 function WebExplorer_AbstractExplorer($data_locators=array()) {
171 $this->_data_locators = $data_locators;
172 $this->init_default_gui_modules();
173 $this->set_e_state();
174
175 //debug
176 // print "State: " . Dumper($this->_state) ."<br>";
177 //print "_data_locators: " . Dumper($this->_data_locators) ."<br>";
178 $div = html_div();
179 $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
180 $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
181 if (constants::get('DEBUG')) {
182 print $div->render();
183 }
184 }
185
186
187 function add_data_locator($label, $args) {
188 $this->_data_locators[$label] = $args;
189 }
190
191 function set_data_locator($label, $new_args=array() ) {
192 global $app;
193
194 // pre-flight checks
195 if (!$label) {
196 user_error("AbstractExplorer::set_data_locator - label was empty.");
197 return;
198 }
199
200 if ($label == "rpc") {
201 $rpcinfo = $app->getConfig("rpcinfo");
202 define('RPC_HOSTNAME', $rpcinfo[Host]);
203 define('RPC_PORT', $rpcinfo[Port]);
204 define('RPC_DEBUG', $rpcinfo[DEBUG]);
205 define('RPC_TRACE', $rpcinfo[TRACE]);
206 define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
207 } else {
208 user_error("AbstractExplorer::set_data_locator - Could not dispatch data_locator_key label '$label'!");
209 }
210 }
211
212 function get_data_locator($label) {
213 }
214
215 function get_page_state() {
216 $requestTracker = mkObject("Application::Request::Tracker");
217 $this->_state = $requestTracker->getPointer();
218 //print "state: " . Dumper($this->_state) . "<br>";
219 }
220
221 function clear_comp_state($comp = NULL) {
222 if($comp) {
223 $this->_e_state[ecoms][$comp] = array();
224 }
225 }
226
227 function set_e_state($state = null) {
228 // NEW [2003-04-18]: now has two modes
229 // 1. inject page state from argument passed to us
230 // 2. (was) get page state from request tracker
231 if ($state) {
232 $this->_e_state = $state;
233
234 } else {
235 $this->get_page_state();
236 $this->_e_state = $this->_state[options][options];
237
238 }
239 // print "Setting Explorer state:" . Dumper($this->_e_state);
240 }
241
242 function set_page_state() {
243 user_error("AbstractExplorer::set_page_state - please implement me....");
244 }
245
246 function init_default_gui_modules() {
247
248 // format of parameters: label, ecom_type, abstract_type, module_name
249
250 // 2003-03-02 - First ecom modules/components
251 //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
252 $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
253 $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
254 $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
255
256 // 2003-04-05 - Chooser (a Nav.List)
257 $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
258
259 // 2003-04-07 - RemoteAction
260 $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");
261
262 // 2003-04-09 - Data.Item: DeleteAction
263 $this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem");
264 //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction");
265 //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem");
266
267 // 2003-04-12 - Data.Tree
268 $this->register_gui_module("content", "data", "tree", "WebExplorer::Module::DataTree" );
269
270 // 2003-04-18 - Nav.Tree
271 $this->register_gui_module("nav", "nav", "tree", "WebExplorer::Module::NavigationTree" );
272
273 // 2003-04-18 - UserManagment Nav.Tree (we need only a different 'label' as Nav.Tree yet..)
274 $this->register_gui_module("UMnav", "nav", "tree", "WebExplorer::Module::NavigationTree" );
275
276 }
277
278 function register_source_module($label, $args) {
279 $this->_module['source'][$label] = $args;
280 }
281
282 function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
283 $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
284 }
285
286
287 function &get_ecom($label, $args = array()) {
288
289 // the very first - strongly hardcoded - Hello World ecom
290 //return "Hello World";
291
292 // that's better ...
293 $this->_load_ecom($label, $args);
294
295 //print "getEcom_args: " .Dumper($args). "<br>";
296
297 return $this->_ecom[$label];
298
299 }
300
301
302 function _load_ecoms() {
303 //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
304 foreach($this->_e_state[ecoms] as $label => $val) {
305 $this->_load_ecom($label);
306 }
307 }
308
309
310
311 function _load_ecom($label, $args = array()) {
312
313 // fetch values from state
314 $val = $this->_e_state['ecoms'][$label];
315 debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
316
317 // NEW [2003-04-10]: ecom-RESET-condition
318 if (!is_array($val) && $val == 'RESET') {
319 debug::info("Resetting component: $label");
320 return;
321 }
322
323 // find right ecom gui module
324 $ecom_type = $val['ecom_type'];
325 $abstract_type = $val['ecom_abstract_type'];
326 $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
327 //print Dumper($gui_module);
328 if(!$gui_module) {
329 user_error("_load_ecom: No GUI module found for [label='$label', ecom type='$val[ecom_type]', abstract type='$val[ecom_abstract_type]'].");
330 return;
331 }
332
333 // get arguments needed for ecom gui module
334 $args = $this->_prepare_component_args($label, $args);
335
336 // trace
337 //print "raw-args: " . Dumper($args) . "<br/>";
338
339 // get ecom GUI module
340 if (!$ecom = php::mkComponent($gui_module, $args)) {
341 user_error("AbstractExplorer::_load_component - Error while instantiating ecom gui component. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
342 return;
343 }
344 //print Dumper($ecom);
345
346 // NEW[2003-04-18] done via args(prepare args!) passed at constructor
347 // (needed for non-real objects instanced at some child of AbstractGUIModule, eg. NavigationList)
348 /*
349 // add hidden vars, needed for explorer control
350 $hidden_items = $this->_get_hidden_items($label);
351 if(is_array($hidden_items) ) {
352 $ecom->add_hidden_items($hidden_items);
353 print "Hidden: " . Dumper($hidden_items);
354 }
355 */
356
357 // load phphtmllib GUI object
358 $gui_ecom = &$ecom->get();
359
360 // attempt:
361 //$gui_ecom->make_transparent();
362
363 // store phphtmllib GUI object
364 $this->_ecom[$label] = &$gui_ecom;
365 }
366
367
368
369 function _get_hidden_items($label) {
370 $ecom_state = $this->_e_state['ecoms'][$label];
371 if($ecom_state['ecom_type'] == "data") {
372 if($ecom_state['ecom_abstract_type'] == "list") {
373 $hidden_items = array(
374 'ecl' => $label,
375 'ecat' => "list",
376 'ecmod' => "view",
377 'ecdid' => $ecom_state['ecom_data_ident'],
378 );
379 }
380 elseif($ecom_state['ecom_abstract_type'] == "item") {
381 $hidden_items = array(
382 'ecl' => $label,
383 'ecat' => "item",
384 'ecmod' => "view",
385 );
386 }
387 }
388 elseif($ecom_state['ecom_type'] == "nav") {
389 // Switching abstract make no real sense here,
390 // because hidden_items(link_vars) for Naviagtion-Ecoms
391 // are more label specified!!
392 // OLD:
393 //if($ecom_state['ecom_abstract_type'] == "list") {
394
395 // decide whether to link to items or to a list
396 $abstract_type = 'list';
397 // FIXME: HACK
398 if ($this->_e_state[main][ecom_data_source_key] == 'config') {
399 $abstract_type = 'item';
400 }
401
402 // NEW:
403 if ($label == "nav") {
404 $hidden_items = array(
405 'ecl' => "content",
406 'ecat' => $abstract_type,
407 'ecmod' => "view",
408 'ect' => "data",
409 'ecdlk' => "rpc",
410 );
411
412 }
413 elseif ($label == "chooser") {
414 $hidden_items = array(
415 'ecl' => "phase_startup",
416 'ecdlk' => "rpc",
417 );
418
419 }
420 }
421 // add page idents
422
423 //print "-e-state-idents: " .Dumper($this->_e_state[idents]). "<br>";
424
425 foreach($this->_e_state[idents] as $label => $value) {
426 $hidden_items[$label] = $value;
427 }
428 return $hidden_items;
429 }
430
431
432
433 function _prepare_component_args($label, $args = array()) {
434 $val = $this->_e_state['ecoms'][$label];
435 //print "val: " .Dumper($val). "<br>";
436 // pre-flight checks
437 if (!$val['ecom_data_locator_key']) {
438 user_error("_prepare_component_args: Key 'ecom_data_locator_key' was empty, should be one of 'rpc'.");
439 return;
440 }
441
442 if (!$val['ecom_type']) {
443 user_error("WebExplorer::AbstractExplorer: Key 'ecom_type' was empty, should be one of 'data|nav|call'.");
444 }
445
446 if (!$val['ecom_abstract_type']) {
447 user_error("_prepare_component_args: Key 'ecom_abstract_type' was empty, should be one of 'item|list|tree|auto'.");
448 return;
449 }
450
451 // trace
452 //print "YAI1<br/>";
453
454
455 $this->set_data_locator($val['ecom_data_locator_key']);
456
457 // detect and execute 'selectSource' action
458 // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
459 //print Dumper($this->_e_state['sources']);
460 if ($source = $this->_e_state['main']['ecom_data_source_key']) {
461 //print "selectSource: $source<br/>";
462 //global $app;
463 //print Dumper($backend);
464 //$app->backend->do();
465 }
466
467 // switch component type
468 if($val['ecom_type'] == "data") {
469 // switch abstract type
470 if($val['ecom_abstract_type'] == "list") {
471 // debugging
472 //print "Mode: $val[ecom_mode], type: list<br>";
473 //print "val: " .Dumper($val). "<br>";
474
475 if($val['ecom_data_locator_key'] == "rpc") {
476 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);
477
478 $data_locator_meta = array(
479 transport => 'rpc',
480 metatype => 'data',
481 abstract_type => 'list',
482 nodename => $val['ecom_data_ident'],
483 list_meta => $val['ecom_data_meta']
484 );
485 } else {
486 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
487 }
488
489 if($val['ecom_mode'] == 'select') {
490 $actionbar = array(
491 'buttons' => array(
492 array(
493 'name' => "ecdfsel",
494 'value' => "Select"
495 ),
496 ),
497 );
498 } else {
499 $actionbar = array(
500 'name' => "ecdfa",
501 'list' => array(
502 "View" => 'view',
503 "Edit" => 'edit',
504 "Delete" => 'delete',
505 "Expand" => 'expand',
506 "Expandedit" => 'expandedit',
507 ),
508 'selected' => 'view',
509 'buttons' => array(
510 array(
511 'name' => "ecdfcr",
512 'value' => "Add new"
513 ),
514 ),
515 );
516 }
517
518 $args = array(
519 'caption' => $val['ecom_data_ident'],
520 'orderby' => "Guid",
521 'options' => array(
522 'data_locator_meta' => $data_locator_meta,
523 'decode' => 1,
524 'decode_args' => array(
525 'seperator' => "_",
526 //'form' => 1,
527 ),
528 'actionbar' => $actionbar,
529 'parent' => array(
530 'class' => $val['ecom_data_ident'],
531 ),
532 ),
533 );
534 if($val['ecom_data_meta_x']) {
535 //unset($args['options']['data_locator_meta']['nodename']);
536 $args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta'];
537 $args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x'];
538 }
539
540 // switch abstract type
541 } elseif ($val['ecom_abstract_type'] == "item") {
542 if($val['ecom_data_locator_key'] == "rpc") {
543 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);
544
545 // NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes
546 $filter = $this->get_data_filter($val);
547
548 $data_locator_meta = array(
549 transport => 'rpc', metatype => 'data', abstract_type => 'item',
550 ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], filter => $filter,
551 );
552 } else {
553 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
554 }
555
556 // defaults
557 if (!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
558 //$val['ecom_mode'] = "view";
559
560 // debugging
561 print "Mode: $val[ecom_mode]<br>";
562
563 //print Dumper($val);
564 // NEW [2003-04-22]: append some more meta information to the caption
565 //$caption_addendum = ' {' . $val['ecom_data_meta'] . '}';
566 $caption_addendum = ' {' . $val['ecom_data_meta'] . ':' . $val['ecom_data_filter'] . '}';
567
568 // prepare some arguments...
569 $args = array(
570 'caption' => $val['ecom_data_ident'] . $caption_addendum,
571 'mode' => $val['ecom_mode'],
572 'options' => array(
573 'data_locator_meta' => $data_locator_meta,
574 'decode' => 1,
575 'decode_args' => array(
576 'seperator' => "_",
577 ),
578 'parent' => array(
579 'guid' => $val['ecom_data_ident'],
580 'class' => $val['ecom_data_meta'],
581 ),
582 ),
583 );
584 if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
585
586 // FIXME: (see WebExplorer::Module::AbstractGUIModule)
587 //if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; }
588 if ($val['ecom_mode'] == "delete") {
589 $args['adapter'] = 'NonValidatingFormProcessor';
590 $args['options']['data_locator_meta']['action'] = 'delete';
591 }
592
593 if ($val['ecom_mode'] == "create") {
594 $args['adapter'] = 'FormProcessor';
595 $args['options']['caption'] = $val['ecom_data_ident'];
596 $args['options']['data_locator_meta']['action'] = 'create';
597 //print "debug 'create': " . Dumper($val);
598 if($val['ecom_data_meta_x']) {
599 unset($args['options']['data_locator_meta']['nodename']);
600 $args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta'];
601 $args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x'];
602 }
603 }
604 if ($val['ecom_mode'] == "select") {
605 $args['adapter'] = 'FormProcessor';
606 $args['caption'] = $val['ecom_data_meta_xe'] . " {". $val['ecom_data_meta_x'] . ":}";
607 $args['options']['data_locator_meta']['action'] = 'select';
608 //print "debug 'select': " . Dumper($val);
609 if($val['ecom_data_meta_x']) {
610 $args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta_xe'];
611 $args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x'];
612 }
613 }
614
615 //print "debug 'args' : " . Dumper($args);
616
617 // switch abstract type
618 } elseif ($val['ecom_abstract_type'] == "tree") {
619
620 // NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes
621 $filter = $this->get_data_filter($val);
622
623 // FIXME: shouldn't this (dispatching by transport-key) be done very *outside* of this scope?
624 // or: do it outside per default, let a possibility to modify it inside the lower levels of the dispatcher (here)
625 if ($val['ecom_data_locator_key'] == "rpc") {
626 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);
627 $args[options][data_locator_meta] = array(
628 transport => 'rpc', metatype => 'data', abstract_type => 'tree',
629 ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'],
630 // NEW [2003-04-22]: Full tree node filtering established.
631 filter => $filter
632 );
633 }
634
635 // NEW [2003-09-26]: transparent content - argument pass-through mode
636 } elseif ($val['ecom_abstract_type'] == "transparent") {
637
638 // You are responsible for all arguments passed through.
639 // Where are these arguments from?
640 // They are propagated transparently to this place from a new optional
641 // parameter ($args) introduced for the methods 'get_com', 'load_com'
642 // and '_prepare_component_args' (this one).
643 // This means full control over ecoms from outside.
644
645 // TODO: maybe add some additional pre-flight checks here!?
646
647 // croak
648 } else {
649 user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'.");
650
651 }
652
653 // switch component type
654 } elseif ($val['ecom_type'] == "nav") {
655
656 // switch abstract type
657 // list
658 if ($val['ecom_abstract_type'] == "list") {
659 $args = array();
660 if($val['ecom_data_locator_key'] == "rpc") {
661
662 // switch component label
663 // TODO: should we really dispatch by label inside here?
664
665 if ($label == "nav") {
666 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
667 $args['caption'] = "Objekt Typen";
668 }
669 // NEW [2003-04-05]: DataSource.Chooser
670 elseif ($label == "chooser") {
671 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
672 $args['caption'] = "Datenquellen";
673 }
674 // NEW [2003-04-18]: croak if label empty
675 else {
676 user_error("_prepare_component_args: Dispatching for nav.list.rpc failed. \$label was empty.");
677 }
678 $args['options']['data_locator_meta'] = $data_locator_meta;
679
680 } else {
681 user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
682 }
683
684 // NEW [2003-04-18]: Abstract navigation tree
685 } elseif ($val['ecom_abstract_type'] == "tree") {
686 $args = array();
687 if($label == "nav") {
688 //$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'schema', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);
689 $args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
690 $args['caption'] = $val['ecom_data_source_key'];
691 } elseif($label == "UMnav") {
692 //$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'schema', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);
693 $args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'method', method => 'UserManagmentSchema' );
694 $args['caption'] = "Benutzerverwaltung";
695 }
696
697 // NEW [2003-04-18]: transparent nav - argument pass-through mode
698 } elseif ($val['ecom_abstract_type'] == "transparent") {
699 // You are responsible for all arguments passed through.
700 // Where are these arguments from?
701 // They are propagated transparently to this place from a new optional
702 // parameter ($args) introduced for the methods 'get_com', 'load_com'
703 // and '_prepare_component_args' (this one).
704 // This means full control over ecoms from outside.
705
706 // TODO: maybe add some additional pre-flight checks here!?
707 // croak
708 } else {
709 user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'.");
710 }
711
712 // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
713 // switch component type
714 } elseif ($val['ecom_type'] == "call") {
715
716 // responses of RemoteActions are not predictable!
717 if ($val['ecom_abstract_type'] == "auto") {
718
719 // Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere!
720
721 // Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently.
722 // Really - just a remote call is issued, no data-/schema-structures or similar are expected.
723
724 // The RemoteMethod 'method' is called directly with arguments in 'args'!
725 // As response (important for widget assignement!) you may expect an arbitrary payload.
726 $args['options']['data_locator_meta'] = array(
727 transport => 'rpc',
728 metatype => 'method',
729 method => $val['ecom_call_method'],
730 args => $val['ecom_call_args']
731 );
732
733 } else {
734 // FIXME: implement automatic re-dispatching to available ecoms here!
735 user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
736 }
737
738 }
739
740 // NEW[2003-04-18]: add hidden items to args
741 $args['hidden_elements'] = $this->_get_hidden_items($label);
742 //print "args_hidden: " .Dumper($args['hidden_elements']). "<br>";
743 return $args;
744 }
745
746
747
748 function get_msg($label) {
749 if($label == "welcome") {
750 $msg = "Welcome to the Explorer.";
751 }
752 return $msg;
753 }
754
755
756
757 function render() {
758 user_error("AbstractExplorer::render - please implement me....");
759 }
760
761
762 function get_data_filter($state = array()) {
763
764 // NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes
765 // V1: this was inside ecom_abstract_type == item && ecom_data_locator_key == rpc, but ...
766 // V2: ... it should be considered / work independent of these both criterias
767 // since it is required for showing xml nodes in items (editing) *and* trees again (browsing).
768
769 if ($filter_expression = $state[ecom_data_filter]) {
770
771 // new of 2003-05-13: Apply "Node navigation" in tree mode only.
772 // Lock context when switching to item mode.
773 //print Dumper($state);
774 if ($state[ecom_abstract_type] == "tree") {
775 if ($parent_xpq = $state[ecom_data_meta]) {
776 $filter_expression = $parent_xpq . $filter_expression;
777 }
778 }
779
780 // This propagates a XPath filter expression which fully identifies
781 // a single node in a document. It reaches through all parent nodes.
782 $filter = array(
783 //dotted => $val['ecom_data_filter'],
784 //ident => $val['ecom_data_ident'],
785 //xpq => '*/*[@name="cli"]',
786 //xpq => '*/*',
787 // NEW [2003-04-21]: An xpq is already ready now inside
788 // 'ecdf' since it already has been built by the revamped tree lift.
789 xpq => '*' . $filter_expression
790 );
791
792 } else {
793 $filter = '';
794
795 }
796
797 // lift filter from dotted format to xpq format
798 // NEW [2003-04-21]: not required any more (see above)
799 //$lift = mkObject('Data::Lift', $filter, array( metatype => 'filter' ) );
800 //$filter = $lift->to('XPath');
801
802 return $filter;
803
804 }
805
806 }
807
808
809 ?>

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