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

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

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