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

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

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