/[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.26 - (hide annotations)
Sun Dec 14 01:50:30 2003 UTC (20 years, 8 months ago) by jonen
Branch: MAIN
Changes since 1.25: +54 -21 lines
implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes

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

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