/[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.27 - (show annotations)
Thu Mar 11 21:01:35 2004 UTC (20 years, 5 months ago) by jonen
Branch: MAIN
Changes since 1.26: +5 -1 lines
minor change

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

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