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

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.22

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