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

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

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