/[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.17 by jonen, Fri Apr 18 13:46:15 2003 UTC revision 1.18 by joko, Fri Apr 18 15:27:06 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.18  2003/04/18 15:27:06  joko
8    ##    NEW: XML Trees in data area
9    ##      new ecom module: DataTree
10    ##      introduced new query argument: 'filter' (purpose: xml/tree filtering)
11    ##        $filter = array(
12    ##          dotted => $val['ecom_data_filter'],
13    ##          ident => $val['ecom_data_ident'],
14    ##        );
15    ##        A Data::Lift module translates this filter-query into a XPath-query ...
16    ##        $filter = array(
17    ##          xpq => '*/*[@name="cli"]',
18    ##        );
19    ##        ... which finally is propagated to the backend.
20    ##    NEW: AbstractExplorer - standalone version
21    ##      enhanced set_e_state: now can overwrite internal state to arguments from outside
22    ##      enhanced get_com: also capable of propagating additional args through _load_ecom to _prepare_component_args
23    ##      enhanced _prepare_component_args: now able to dispatch to a "transparent navigation ecom" (e.g. YAA::JobGroups)
24    ##    MISC:
25    ##      added some pre-flight checks throughout the module, especially at the core dispatcher inside _prepare_component_args
26    ##      error checking: added some more croaks via 'user_error'
27    ##      cosmetic updates
28    ##
29  ##    Revision 1.17  2003/04/18 13:46:15  jonen  ##    Revision 1.17  2003/04/18 13:46:15  jonen
30  ##    + add hidden elements(items) now to the constructor arguments of each ecom  ##    + add hidden elements(items) now to the constructor arguments of each ecom
31  ##  ##
# Line 136  class WebExplorer_AbstractExplorer { Line 158  class WebExplorer_AbstractExplorer {
158        
159    function set_data_locator($label, $new_args=array() ) {    function set_data_locator($label, $new_args=array() ) {
160      global $app;      global $app;
161      //print Dumper($app) . "<br>";      
162      if($label == "rpc") {      // pre-flight checks
163        if (!$label) {
164          user_error("AbstractExplorer::set_data_locator - label was empty.");
165          return;
166        }
167        
168        if ($label == "rpc") {
169        $rpcinfo = $app->getConfig("rpcinfo");        $rpcinfo = $app->getConfig("rpcinfo");
170        define('RPC_HOSTNAME', $rpcinfo[Host]);        define('RPC_HOSTNAME', $rpcinfo[Host]);
171        define('RPC_PORT', $rpcinfo[Port]);        define('RPC_PORT', $rpcinfo[Port]);
# Line 145  class WebExplorer_AbstractExplorer { Line 173  class WebExplorer_AbstractExplorer {
173        define('RPC_TRACE', $rpcinfo[TRACE]);        define('RPC_TRACE', $rpcinfo[TRACE]);
174        define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);        define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
175      } else {      } else {
176        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'!");
177      }      }
178    }    }
179        
# Line 154  class WebExplorer_AbstractExplorer { Line 182  class WebExplorer_AbstractExplorer {
182    
183    function get_page_state() {    function get_page_state() {
184      $requestTracker = mkObject("Application::Request::Tracker");      $requestTracker = mkObject("Application::Request::Tracker");
185        //print Dumper($this->_state);
186      $this->_state = $requestTracker->getPointer();      $this->_state = $requestTracker->getPointer();
187    }    }
188        
189    function set_e_state() {    function set_e_state($state = null) {
190      $this->get_page_state();      // NEW [2003-04-18]: now has two modes
191      $this->_e_state = $this->_state[options][options];      // 1. inject page state from argument passed to us
192        // 2. (was) get page state from request tracker
193        if ($state) {
194          $this->_e_state = $state;
195        } else {
196          $this->get_page_state();
197          $this->_e_state = $this->_state[options][options];
198        }
199      //  print "Setting Explorer state:" . Dumper($this->_e_state);      //  print "Setting Explorer state:" . Dumper($this->_e_state);
200    }    }
     
201    
202    function set_page_state() {    function set_page_state() {
203      user_error("AbstractExplorer::set_page_state - please implement me....");          user_error("AbstractExplorer::set_page_state - please implement me....");    
204    }    }
     
205    
206    function init_default_gui_modules() {    function init_default_gui_modules() {
207            
208      // format of parameters: label, ecom_type, abstract_type, module_name      // format of parameters: label, ecom_type, abstract_type, module_name
209            
210        // 2003-03-02 - First ecom modules/components
211      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
212      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
213      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
214      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
215      // 2003-04-05 - Chooser      
216        // 2003-04-05 - Chooser (a Nav.List)
217      $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");      $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
218        
219      // 2003-04-07 - RemoteAction      // 2003-04-07 - RemoteAction
220      $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");      $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");
221      // 2003-04-09 - Item.Delete      
222        // 2003-04-09 - Data.Item: DeleteAction
223      $this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem");      $this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem");
224      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction");      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction");
225      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem");      //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem");
226        
227        // 2003-04-12 - Data.Tree
228        $this->register_gui_module("content", "data", "tree", "WebExplorer::Module::DataTree" );
229        
230        
231    }    }
232    
233    function register_source_module($label, $args) {    function register_source_module($label, $args) {
# Line 196  class WebExplorer_AbstractExplorer { Line 239  class WebExplorer_AbstractExplorer {
239    }    }
240    
241    
242    function &get_ecom($label) {    function &get_ecom($label, $args = array()) {
243        
244        // the very first - strongly hardcoded - Hello World ecom
245      //return "Hello World";      //return "Hello World";
246      $this->_load_ecom($label);      
247        // that's better ...
248        $this->_load_ecom($label, $args);
249      return $this->_ecom[$label];      return $this->_ecom[$label];
250        
251    }    }
252    
   
253        
254    function _load_ecoms() {    function _load_ecoms() {
255      //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");      //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
# Line 213  class WebExplorer_AbstractExplorer { Line 260  class WebExplorer_AbstractExplorer {
260    
261    
262        
263    function _load_ecom($label) {    function _load_ecom($label, $args = array()) {
264            
265      // fetch values from state      // fetch values from state
266      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
# Line 231  class WebExplorer_AbstractExplorer { Line 278  class WebExplorer_AbstractExplorer {
278      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
279      //print Dumper($gui_module);      //print Dumper($gui_module);
280      if(!$gui_module) {      if(!$gui_module) {
281        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]'].");
282        return;        return;
283      }      }
284    
285      // get arguments needed for ecom gui module      // get arguments needed for ecom gui module
286      $args = $this->_prepare_component_args($label);      $args = $this->_prepare_component_args($label, $args);
287      //print Dumper($args);      
288        // trace
289        //print "raw-args: " . Dumper($args) . "<br/>";
290            
291      // get ecom GUI module      // get ecom GUI module
292      if (!$ecom = php::mkComponent($gui_module, $args)) {      if (!$ecom = php::mkComponent($gui_module, $args)) {
293          user_error("AbstractExplorer::_load_component - Error while instantiating ecom gui component. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
294        return;        return;
295      }      }
296      //print Dumper($ecom);      //print Dumper($ecom);
# Line 320  class WebExplorer_AbstractExplorer { Line 370  class WebExplorer_AbstractExplorer {
370    
371    
372    
373    function _prepare_component_args($label) {        function _prepare_component_args($label, $args = array()) {    
374      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
375    
376        // pre-flight checks
377        if (!$val['ecom_data_locator_key']) {
378          user_error("_prepare_component_args: Key 'ecom_data_locator_key' was empty, should be one of 'rpc'.");
379          return;
380        }
381    
382        if (!$val['ecom_type']) {
383          user_error("WebExplorer::AbstractExplorer: Key 'ecom_type' was empty, should be one of 'data|nav|call'.");
384        }
385    
386        if (!$val['ecom_abstract_type']) {
387          user_error("_prepare_component_args: Key 'ecom_abstract_type' was empty, should be one of 'item|list|tree|auto'.");
388          return;
389        }
390    
391        // trace
392        //print "YAI1<br/>";
393        //print Dumper($val);
394        
395      $this->set_data_locator($val['ecom_data_locator_key']);      $this->set_data_locator($val['ecom_data_locator_key']);
396    
397      // detect and execute 'selectSource' action      // detect and execute 'selectSource' action
# Line 365  class WebExplorer_AbstractExplorer { Line 435  class WebExplorer_AbstractExplorer {
435                                                ),                                                ),
436                                            ),                                            ),
437                        );                        );
438          
439        // switch abstract type        // switch abstract type
440        } elseif ($val['ecom_abstract_type'] == "item") {        } elseif ($val['ecom_abstract_type'] == "item") {
441          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
442            //$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']);
443            $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);            
444              // NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes
445              // this propagates the full identifier to reach through all parent nodes
446              $filter = array(
447                dotted => $val['ecom_data_filter'],
448                ident => $val['ecom_data_ident'],
449                //xpq => '*/*[@name="cli"]',
450                //xpq => '*/*',
451              );
452              // lift filter from dotted format to xpq format
453              $lift = mkObject('Data::Lift', $filter, array( metatype => 'filter' ) );
454              $filter = $lift->to('XPath');
455    
456              $data_locator_meta = array(
457                transport => 'rpc', metatype => 'data', abstract_type => 'item',
458                ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], filter => $filter,
459              );
460          } else {          } else {
461            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] !");
462          }          }
463                    
464          // defaults          // defaults
465          if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }          if (!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
466          //$val['ecom_mode'] = "view";          //$val['ecom_mode'] = "view";
467                    
468          // debugging          // debugging
# Line 386  class WebExplorer_AbstractExplorer { Line 473  class WebExplorer_AbstractExplorer {
473                        'caption' => $val['ecom_data_meta'],                        'caption' => $val['ecom_data_meta'],
474                        'mode' => $val['ecom_mode'],                        'mode' => $val['ecom_mode'],
475                        'options' => array(                        'options' => array(
476                                            'data_locator_meta' => $data_locator_meta,                                              'data_locator_meta' => $data_locator_meta,
477                                            'decode' => 1,                                              'decode' => 1,
478                                            'decode_args' => array(                                              'decode_args' => array(
479                                                'seperator' => "_",                                                'seperator' => "_",
480                                                ),                                              ),
481                                            ),                                          ),
482                        );                        );
483           if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }           if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
484                    
# Line 399  class WebExplorer_AbstractExplorer { Line 486  class WebExplorer_AbstractExplorer {
486           //if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; }           //if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; }
487           if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; }           if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; }
488                    
489          // switch abstract type
490          } elseif ($val['ecom_abstract_type'] == "tree") {
491            //print "TREE!<br/>";
492            
493            // FIXME: shouldn't this (dispatching by transport-key) be done very *outside* of this scope?
494            // or: do it outside per default, let a possibility to modify it inside the lower levels of the dispatcher (here)
495            if ($val['ecom_data_locator_key'] == "rpc") {
496              //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']);
497              $args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'data', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);
498            }
499    
500          } else {
501            user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'.");
502            
503        }        }
504            
505      // switch component type      // switch component type
506      } elseif ($val['ecom_type'] == "nav") {      } elseif ($val['ecom_type'] == "nav") {
507          
508        // switch abstract type        // switch abstract type
509        if($val['ecom_abstract_type'] == "list") {        // list
510          if ($val['ecom_abstract_type'] == "list") {
511         $args = array();         $args = array();
512          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
513              
514            // switch component label            // switch component label
515            if($label == "nav") {            // TODO: should we really dispatch by label inside here?
516              
517              if ($label == "nav") {
518              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
519              $args['caption'] = "Objekt Typen";              $args['caption'] = "Objekt Typen";
520            }            }
# Line 417  class WebExplorer_AbstractExplorer { Line 523  class WebExplorer_AbstractExplorer {
523              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );              $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
524              $args['caption'] = "Datenquellen";              $args['caption'] = "Datenquellen";
525            }            }
526              // NEW [2003-04-18]: croak if label empty
527              else {
528                user_error("_prepare_component_args: Dispatching for nav.list.rpc failed. \$label was empty.");
529              }
530            $args['options']['data_locator_meta'] = $data_locator_meta;            $args['options']['data_locator_meta'] = $data_locator_meta;
531              
532          } else {          } else {
533            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] !");
534          }          }
535          
536          // tree
537        } elseif ($val['ecom_abstract_type'] == "tree") {        } elseif ($val['ecom_abstract_type'] == "tree") {
538          $args = array();          $args = array();
539            print "TREE!<br/>";
540    
541          // NEW [2003-04-18]: transparent nav - argument pass-through mode
542          } elseif ($val['ecom_abstract_type'] == "transparent") {
543            
544            // You are responsible for all arguments passed through.
545            // Where are these arguments from?
546            // They are propagated transparently to this place from a new optional
547            // parameter ($args) introduced for the methods 'get_com', 'load_com'
548            // and '_prepare_component_args' (this one).
549            // This means full control over ecoms from outside.
550            
551            // TODO: maybe add some additional pre-flight checks here!?
552          
553          // croak
554          } else {
555            user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'.");
556        }        }
557    
558      // 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 450  class WebExplorer_AbstractExplorer { Line 580  class WebExplorer_AbstractExplorer {
580          // FIXME: implement automatic re-dispatching to available ecoms here!          // FIXME: implement automatic re-dispatching to available ecoms here!
581          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?");
582        }              }      
583        
584      }      }
585    
586      // add hidden items to args      // add hidden items to args

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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