/[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.24 - (hide annotations)
Wed Jul 2 11:39:16 2003 UTC (21 years ago) by jonen
Branch: MAIN
Changes since 1.23: +8 -4 lines
fixed bugs

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

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