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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.25

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