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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.25 - (hide annotations)
Sat Nov 22 18:47:49 2003 UTC (20 years, 9 months ago) by udo
Branch: MAIN
Changes since 1.24: +51 -20 lines
update for expand data item

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

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