/[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.16 by joko, Thu Apr 10 06:00:58 2003 UTC revision 1.19 by joko, Fri Apr 18 16:21:37 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.19  2003/04/18 16:21:37  joko
8    ##    fixed commit comment - the last one caused a syntax error!!!
9    ##
10    ##    Revision 1.18  2003/04/18 15:27:06  joko
11    ##    NEW: XML Trees in data area
12    ##      new ecom module: DataTree
13    ##      introduced new query argument: 'filter' (purpose: xml/tree filtering)
14    ##        $filter = array(
15    ##          dotted => $val['ecom_data_filter'],
16    ##          ident => $val['ecom_data_ident'],
17    ##        );
18    ##        A Data::Lift module translates this filter-query into a XPath-query ...
19    ##        $filter = array(
20    ##          xpq => '*\/*[@name="cli"]',
21    ##        );
22    ##        ... which finally is propagated to the backend.
23    ##    NEW: AbstractExplorer - standalone version
24    ##      enhanced set_e_state: now can overwrite internal state to arguments from outside
25    ##      enhanced get_com: also capable of propagating additional args through _load_ecom to _prepare_component_args
26    ##      enhanced _prepare_component_args: now able to dispatch to a "transparent navigation ecom" (e.g. YAA::JobGroups)
27    ##    MISC:
28    ##      added some pre-flight checks throughout the module, especially at the core dispatcher inside _prepare_component_args
29    ##      error checking: added some more croaks via 'user_error'
30    ##      cosmetic updates
31    ##
32    ##    Revision 1.17  2003/04/18 13:46:15  jonen
33    ##    + add hidden elements(items) now to the constructor arguments of each ecom
34    ##
35  ##    Revision 1.16  2003/04/10 06:00:58  joko  ##    Revision 1.16  2003/04/10 06:00:58  joko
36  ##    ALPHA: Item.Delete  ##    ALPHA: Item.Delete
37  ##  ##
# Line 133  class WebExplorer_AbstractExplorer { Line 161  class WebExplorer_AbstractExplorer {
161        
162    function set_data_locator($label, $new_args=array() ) {    function set_data_locator($label, $new_args=array() ) {
163      global $app;      global $app;
164      //print Dumper($app) . "<br>";      
165      if($label == "rpc") {      // pre-flight checks
166        if (!$label) {
167          user_error("AbstractExplorer::set_data_locator - label was empty.");
168          return;
169        }
170        
171        if ($label == "rpc") {
172        $rpcinfo = $app->getConfig("rpcinfo");        $rpcinfo = $app->getConfig("rpcinfo");
173        define('RPC_HOSTNAME', $rpcinfo[Host]);        define('RPC_HOSTNAME', $rpcinfo[Host]);
174        define('RPC_PORT', $rpcinfo[Port]);        define('RPC_PORT', $rpcinfo[Port]);
# Line 142  class WebExplorer_AbstractExplorer { Line 176  class WebExplorer_AbstractExplorer {
176        define('RPC_TRACE', $rpcinfo[TRACE]);        define('RPC_TRACE', $rpcinfo[TRACE]);
177        define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);        define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
178      } else {      } else {
179        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'!");
180      }      }
181    }    }
182        
# Line 151  class WebExplorer_AbstractExplorer { Line 185  class WebExplorer_AbstractExplorer {
185    
186    function get_page_state() {    function get_page_state() {
187      $requestTracker = mkObject("Application::Request::Tracker");      $requestTracker = mkObject("Application::Request::Tracker");
188        //print Dumper($this->_state);
189      $this->_state = $requestTracker->getPointer();      $this->_state = $requestTracker->getPointer();
190    }    }
191        
192    function set_e_state() {    function set_e_state($state = null) {
193      $this->get_page_state();      // NEW [2003-04-18]: now has two modes
194      $this->_e_state = $this->_state[options][options];      // 1. inject page state from argument passed to us
195        // 2. (was) get page state from request tracker
196        if ($state) {
197          $this->_e_state = $state;
198        } else {
199          $this->get_page_state();
200          $this->_e_state = $this->_state[options][options];
201        }
202        //  print "Setting Explorer state:" . Dumper($this->_e_state);
203    }    }
     
204    
205    function set_page_state() {    function set_page_state() {
206      user_error("AbstractExplorer::set_page_state - please implement me....");          user_error("AbstractExplorer::set_page_state - please implement me....");    
207    }    }
     
208    
209    function init_default_gui_modules() {    function init_default_gui_modules() {
210            
211      // format of parameters: label, ecom_type, abstract_type, module_name      // format of parameters: label, ecom_type, abstract_type, module_name
212            
213        // 2003-03-02 - First ecom modules/components
214      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
215      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
216      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
217      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
218      // 2003-04-05 - Chooser      
219        // 2003-04-05 - Chooser (a Nav.List)
220      $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");      $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
221        
222      // 2003-04-07 - RemoteAction      // 2003-04-07 - RemoteAction
223      $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");      $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");
224      // 2003-04-09 - Item.Delete      
225        // 2003-04-09 - Data.Item: DeleteAction
226      $this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem");      $this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem");
227      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction");      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction");
228      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem");      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem");
229        
230        // 2003-04-12 - Data.Tree
231        $this->register_gui_module("content", "data", "tree", "WebExplorer::Module::DataTree" );
232        
233        
234    }    }
235    
236    function register_source_module($label, $args) {    function register_source_module($label, $args) {
# Line 192  class WebExplorer_AbstractExplorer { Line 242  class WebExplorer_AbstractExplorer {
242    }    }
243    
244    
245    function &get_ecom($label) {    function &get_ecom($label, $args = array()) {
246        
247        // the very first - strongly hardcoded - Hello World ecom
248      //return "Hello World";      //return "Hello World";
249      $this->_load_ecom($label);      
250        // that's better ...
251        $this->_load_ecom($label, $args);
252      return $this->_ecom[$label];      return $this->_ecom[$label];
253        
254    }    }
255    
   
256        
257    function _load_ecoms() {    function _load_ecoms() {
258      //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");      //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
# Line 209  class WebExplorer_AbstractExplorer { Line 263  class WebExplorer_AbstractExplorer {
263    
264    
265        
266    function _load_ecom($label) {    function _load_ecom($label, $args = array()) {
267            
268      // fetch values from state      // fetch values from state
269      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
# Line 227  class WebExplorer_AbstractExplorer { Line 281  class WebExplorer_AbstractExplorer {
281      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
282      //print Dumper($gui_module);      //print Dumper($gui_module);
283      if(!$gui_module) {      if(!$gui_module) {
284        user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', 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]'].");
285        return;        return;
286      }      }
287    
288      // get arguments needed for ecom gui module      // get arguments needed for ecom gui module
289      $args = $this->_prepare_component_args($label);      $args = $this->_prepare_component_args($label, $args);
290      //print Dumper($args);      
291        // trace
292        //print "raw-args: " . Dumper($args) . "<br/>";
293            
294      // get ecom GUI module      // get ecom GUI module
295      if (!$ecom = php::mkComponent($gui_module, $args)) {      if (!$ecom = php::mkComponent($gui_module, $args)) {
296          user_error("AbstractExplorer::_load_component - Error while instantiating ecom gui component. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
297        return;        return;
298      }      }
299      //print Dumper($ecom);      //print Dumper($ecom);
300                
301      // load phphtmllib GUI object      // NOW[2003-18-04] done at via args(prepare args!) to pass at constructor
302      $gui_ecom = &$ecom->get();      //  (needed for non-real objects instanced at some child of AbstractGUIModule, eg. NavigationList)
303    /*
304      // add hidden vars, needed for explorer control      // add hidden vars, needed for explorer control
305      $hidden_items = $this->_get_hidden_items($label);      $hidden_items = $this->_get_hidden_items($label);
306      if(is_array($hidden_items) ) {      if(is_array($hidden_items) ) {
307        $ecom->add_hidden_items($hidden_items);        $ecom->add_hidden_items($hidden_items);
308        //print "Hidden: " . Dumper($hidden_items);        print "Hidden: " . Dumper($hidden_items);
309      }      }
310    */
311    
312        // load phphtmllib GUI object
313        $gui_ecom = &$ecom->get();
314    
315      // attempt:      // attempt:
316      //$gui_ecom->make_transparent();      //$gui_ecom->make_transparent();
# Line 276  class WebExplorer_AbstractExplorer { Line 337  class WebExplorer_AbstractExplorer {
337                                    'ecat' => "item",                                    'ecat' => "item",
338                                    'ecmod' => "view",                                    'ecmod' => "view",
339                                    );                                    );
 /*  
         if($ecom_state['ecom_mode'] == "view") {  
           $hidden_items['ecmod'] = "edit";  
         }  
         elseif($ecom_state['ecom_mode'] == "edit") {  
           $hidden_items['ecmod'] = "edit";  
         }  
 */        
340        }        }
       $hidden_items['ap'] = "explorer";  
341      }      }
342        elseif($ecom_state['ecom_type'] == "nav") {
343          // Switching abstract make no real sense here,
344          // because hidden_items(link_vars) for Naviagtion-Ecoms
345          // are more label specified!!
346          // OLD:
347          //if($ecom_state['ecom_abstract_type'] == "list") {
348          // NEW:
349          if($label == "nav") {
350            $hidden_items = array(
351                                      'ecl' => "content",
352                                      'ecat' => "list",
353                                      'ecmod' => "view",
354                                      'ect' => "data",
355                                      'ecdlk' => "rpc",
356                                     );
357    
358          }
359          elseif($label == "chooser") {
360            $hidden_items = array(
361                                      'ecl' => "phase_startup",
362                                      'ecdlk' => "rpc",
363                                     );
364    
365          }
366        }
367          // add page idents
368          foreach($this->_e_state[idents] as $label => $value) {
369            $hidden_items[$label] = $value;
370          }
371      return $hidden_items;      return $hidden_items;
372    }    }
373    
374    
375    
376    function _prepare_component_args($label) {        function _prepare_component_args($label, $args = array()) {    
377      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
378    
379        // pre-flight checks
380        if (!$val['ecom_data_locator_key']) {
381          user_error("_prepare_component_args: Key 'ecom_data_locator_key' was empty, should be one of 'rpc'.");
382          return;
383        }
384    
385        if (!$val['ecom_type']) {
386          user_error("WebExplorer::AbstractExplorer: Key 'ecom_type' was empty, should be one of 'data|nav|call'.");
387        }
388    
389        if (!$val['ecom_abstract_type']) {
390          user_error("_prepare_component_args: Key 'ecom_abstract_type' was empty, should be one of 'item|list|tree|auto'.");
391          return;
392        }
393    
394        // trace
395        //print "YAI1<br/>";
396        //print Dumper($val);
397        
398      $this->set_data_locator($val['ecom_data_locator_key']);      $this->set_data_locator($val['ecom_data_locator_key']);
399    
400      // detect and execute 'selectSource' action      // detect and execute 'selectSource' action
# Line 337  class WebExplorer_AbstractExplorer { Line 438  class WebExplorer_AbstractExplorer {
438                                                ),                                                ),
439                                            ),                                            ),
440                        );                        );
441          
442        // switch abstract type        // switch abstract type
443        } elseif ($val['ecom_abstract_type'] == "item") {        } elseif ($val['ecom_abstract_type'] == "item") {
444          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
445            //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);            //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);
446            $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);            
447              // NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes
448              // this propagates the full identifier to reach through all parent nodes
449              $filter = array(
450                dotted => $val['ecom_data_filter'],
451                ident => $val['ecom_data_ident'],
452                //xpq => '*/*[@name="cli"]',
453                //xpq => '*/*',
454              );
455              // lift filter from dotted format to xpq format
456              $lift = mkObject('Data::Lift', $filter, array( metatype => 'filter' ) );
457              $filter = $lift->to('XPath');
458    
459              $data_locator_meta = array(
460                transport => 'rpc', metatype => 'data', abstract_type => 'item',
461                ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], filter => $filter,
462              );
463          } else {          } else {
464            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] !");
465          }          }
466                    
467          // defaults          // defaults
468          if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }          if (!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
469          //$val['ecom_mode'] = "view";          //$val['ecom_mode'] = "view";
470                    
471          // debugging          // debugging
# Line 358  class WebExplorer_AbstractExplorer { Line 476  class WebExplorer_AbstractExplorer {
476                        'caption' => $val['ecom_data_meta'],                        'caption' => $val['ecom_data_meta'],
477                        'mode' => $val['ecom_mode'],                        'mode' => $val['ecom_mode'],
478                        'options' => array(                        'options' => array(
479                                            'data_locator_meta' => $data_locator_meta,                                              'data_locator_meta' => $data_locator_meta,
480                                            'decode' => 1,                                              'decode' => 1,
481                                            'decode_args' => array(                                              'decode_args' => array(
482                                                'seperator' => "_",                                                'seperator' => "_",
483                                                ),                                              ),
484                                            ),                                          ),
485                        );                        );
486           if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }           if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
487                    
# Line 371  class WebExplorer_AbstractExplorer { Line 489  class WebExplorer_AbstractExplorer {
489           //if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; }           //if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; }
490           if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; }           if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; }
491                    
492          // switch abstract type
493          } elseif ($val['ecom_abstract_type'] == "tree") {
494            //print "TREE!<br/>";
495            
496            // FIXME: shouldn't this (dispatching by transport-key) be done very *outside* of this scope?
497            // or: do it outside per default, let a possibility to modify it inside the lower levels of the dispatcher (here)
498            if ($val['ecom_data_locator_key'] == "rpc") {
499              //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);
500              $args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'data', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);
501            }
502    
503          } else {
504            user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'.");
505            
506        }        }
507            
508      // switch component type      // switch component type
509      } elseif ($val['ecom_type'] == "nav") {      } elseif ($val['ecom_type'] == "nav") {
510          
511        // switch abstract type        // switch abstract type
512        if($val['ecom_abstract_type'] == "list") {        // list
513          if ($val['ecom_abstract_type'] == "list") {
514         $args = array();         $args = array();
515          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
516              
517            // switch component label            // switch component label
518            if($label == "nav") {            // TODO: should we really dispatch by label inside here?
519              
520              if ($label == "nav") {
521              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
522              $args['caption'] = "Objekt Typen";              $args['caption'] = "Objekt Typen";
523            }            }
# Line 389  class WebExplorer_AbstractExplorer { Line 526  class WebExplorer_AbstractExplorer {
526              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
527              $args['caption'] = "Datenquellen";              $args['caption'] = "Datenquellen";
528            }            }
529              // NEW [2003-04-18]: croak if label empty
530              else {
531                user_error("_prepare_component_args: Dispatching for nav.list.rpc failed. \$label was empty.");
532              }
533            $args['options']['data_locator_meta'] = $data_locator_meta;            $args['options']['data_locator_meta'] = $data_locator_meta;
534              
535          } else {          } else {
536            user_error("AbstractExplorer::_prepare_component_args - Cannot build schema 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] !");
537          }          }
538          
539          // tree
540        } elseif ($val['ecom_abstract_type'] == "tree") {        } elseif ($val['ecom_abstract_type'] == "tree") {
541          $args = array();          $args = array();
542            print "TREE!<br/>";
543    
544          // NEW [2003-04-18]: transparent nav - argument pass-through mode
545          } elseif ($val['ecom_abstract_type'] == "transparent") {
546            
547            // You are responsible for all arguments passed through.
548            // Where are these arguments from?
549            // They are propagated transparently to this place from a new optional
550            // parameter ($args) introduced for the methods 'get_com', 'load_com'
551            // and '_prepare_component_args' (this one).
552            // This means full control over ecoms from outside.
553            
554            // TODO: maybe add some additional pre-flight checks here!?
555          
556          // croak
557          } else {
558            user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'.");
559        }        }
560    
561      // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)      // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
# Line 422  class WebExplorer_AbstractExplorer { Line 583  class WebExplorer_AbstractExplorer {
583          // FIXME: implement automatic re-dispatching to available ecoms here!          // FIXME: implement automatic re-dispatching to available ecoms here!
584          user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");          user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
585        }              }      
586        
587      }      }
588    
589        // add hidden items to args
590        $args['hidden_elements'] = $this->_get_hidden_items($label);
591    
592      return $args;      return $args;
593    }    }
594    

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.19

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