/[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.29 - (hide annotations)
Thu Aug 11 14:11:28 2005 UTC (18 years, 11 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.28: +27 -2 lines
+ changes relating to new web-interface for TerminalOwner

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

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