/[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.15 by joko, Wed Apr 9 02:08:20 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.15  2003/04/09 02:08:20  joko
8    ##    CHANGE: renamed key 'classname' through 'nodename'
9    ##
10    ##    Revision 1.14  2003/04/09 00:31:27  jonen
11    ##    + added arguments for data list ecom
12    ##
13    ##    Revision 1.13  2003/04/09 00:03:11  jonen
14    ##    disabled form rendering for inheritanced items at 'list'
15    ##
16    ##    Revision 1.12  2003/04/08 17:52:12  joko
17    ##    CHANGE: renamed property 'datasource' to 'transport'
18    ##    NEW: Module 'RemoteAction'
19    ##
20    ##    Revision 1.11  2003/04/07 22:31:51  jonen
21    ##    + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav'
22    ##    - removed recent added ecom type chooser
23    ##
24    ##    Revision 1.10  2003/04/05 20:32:04  joko
25    ##    added Chooser
26    ##
27  ##    Revision 1.9  2003/04/04 02:22:37  joko  ##    Revision 1.9  2003/04/04 02:22:37  joko
28  ##    minor fix: querySchema now issues argument  ##    minor fix: querySchema now issues argument
29  ##  ##
# Line 90  class WebExplorer_AbstractExplorer { Line 110  class WebExplorer_AbstractExplorer {
110    
111    function WebExplorer_AbstractExplorer($data_locators=array()) {    function WebExplorer_AbstractExplorer($data_locators=array()) {
112      $this->_data_locators = $data_locators;      $this->_data_locators = $data_locators;
113      $this->init_default_gui_modules();      $this->init_default_gui_modules();    
       
114      $this->set_e_state();      $this->set_e_state();
115    
116        //debug
117      //print "State: " . Dumper($this->_state) ."<br>";      //print "State: " . Dumper($this->_state) ."<br>";
118      $div = html_div();      $div = html_div();
119      $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 121  class WebExplorer_AbstractExplorer {
121      if (constants::get('DEBUG')) {      if (constants::get('DEBUG')) {
122        print $div->render();        print $div->render();
123      }      }
     //$this->init_state();  
124    }    }
125    
126    
# Line 143  class WebExplorer_AbstractExplorer { Line 163  class WebExplorer_AbstractExplorer {
163        
164    
165    function init_default_gui_modules() {    function init_default_gui_modules() {
166        
167        // format of parameters: label, ecom_type, abstract_type, module_name
168        
169      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
170      $this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") );      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
171      $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
172      $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
173        // 2003-04-05 - Chooser
174        $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");    
175        // 2003-04-07 - RemoteAction
176        $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");    
177    }    }
178    
179    function register_source_module($label, $args) {    function register_source_module($label, $args) {
180      $this->_module['source'][$label] = $args;      $this->_module['source'][$label] = $args;
181    }    }
182        
183    function register_gui_module($abstract_type, $ecom_type, $args) {    function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
184      $this->_module['gui'][$ecom_type][$abstract_type] = $args;      $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
185    }    }
186    
187    
188    function &get_ecom($label) {    function &get_ecom($label) {
189      //return "Hello World";      //return "Hello World";
190      $this->_load_ecom($label);      $this->_load_ecom($label);
191      return $this->_ecom[$label];      return $this->_ecom[$label];
192    }    }
193    
194    
195        
196    function _load_ecoms() {    function _load_ecoms() {
197        //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
198      foreach($this->_e_state[ecoms] as $label => $val) {      foreach($this->_e_state[ecoms] as $label => $val) {
199        $this->_load_ecom($label);        $this->_load_ecom($label);
200      }      }
201    }    }
202    
203    
204        
205    function _load_ecom($label) {    function _load_ecom($label) {
206        // fetch values from state
207      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
208      // find right gui module      debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
209      $com_type = $val['ecom_type'];  
210        // find right ecom gui module
211        $ecom_type = $val['ecom_type'];
212      $abstract_type = $val['ecom_abstract_type'];      $abstract_type = $val['ecom_abstract_type'];
213      $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
214        //print Dumper($gui_module);
215      if(!$gui_module) {      if(!$gui_module) {
216        user_error("AbstractExplorer::_load_component - No GUI module found for abstract type $val[ecom_abstract_type] ecom type $val[ecom_type] !");        user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
217        return;        return;
218      }      }
219      // get arguments needed for gui module  
220        // get arguments needed for ecom gui module
221      $args = $this->_prepare_component_args($label);      $args = $this->_prepare_component_args($label);
222      //print Dumper($args);      //print Dumper($args);
223            
224      // get GUI module      // get ecom GUI module
225      $ecom = php::mkComponent($gui_module, $args);      if (!$ecom = php::mkComponent($gui_module, $args)) {
226          return;
227        }
228      //print Dumper($ecom);      //print Dumper($ecom);
229                    
230      // get phphtmllib GUI object      // load phphtmllib GUI object
231      $gui_ecom = &$ecom->get();      $gui_ecom = &$ecom->get();
232    
233      // add hidden vars, needed for explorer control      // add hidden vars, needed for explorer control
# Line 197  class WebExplorer_AbstractExplorer { Line 237  class WebExplorer_AbstractExplorer {
237        //print "Hidden: " . Dumper($hidden_items);        //print "Hidden: " . Dumper($hidden_items);
238      }      }
239    
240        // attempt:
241        //$gui_ecom->make_transparent();
242        
243        // store phphtmllib GUI object
244      $this->_ecom[$label] = &$gui_ecom;      $this->_ecom[$label] = &$gui_ecom;
245    }    }
246    
247    
248    
249    function _get_hidden_items($label) {    function _get_hidden_items($label) {
250      $ecom_state = $this->_e_state['ecoms'][$label];      $ecom_state = $this->_e_state['ecoms'][$label];
251      if($ecom_state['ecom_type'] == "data") {      if($ecom_state['ecom_type'] == "data") {
# Line 230  class WebExplorer_AbstractExplorer { Line 276  class WebExplorer_AbstractExplorer {
276      return $hidden_items;      return $hidden_items;
277    }    }
278    
279    
280    
281    function _prepare_component_args($label) {        function _prepare_component_args($label) {    
282      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
283      $this->set_data_locator($val['ecom_data_locator_key']);      $this->set_data_locator($val['ecom_data_locator_key']);
284    
285        // detect and execute 'selectSource' action
286        // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
287        //print Dumper($this->_e_state['sources']);
288        if ($source = $this->_e_state['main']['ecom_data_source_key']) {
289          //print "selectSource: $source<br/>";
290          //global $app;
291          //print Dumper($backend);
292          //$app->backend->do();
293        }
294        
295      // switch component type      // switch component type
296      if($val['ecom_type'] == "data") {      if($val['ecom_type'] == "data") {
297        // switch abstract type        // switch abstract type
298        if($val['ecom_abstract_type'] == "list") {        if($val['ecom_abstract_type'] == "list") {
299          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
300            //$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']);
301            $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']);
302          } else {          } else {
303            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] !");
304          }          }
305          $args = array(          $args = array(
306                        'caption' => "Liste",                        'caption' => $val['ecom_data_ident'],
307                        'orderby' => "Guid",                        'orderby' => "Guid",
308                        'options' => array(                        'options' => array(
309                                            'data_locator_meta' => $data_locator_meta,                                            'data_locator_meta' => $data_locator_meta,
310                                            'decode' => 1,                                            'decode' => 1,
311                                            'decode_args' => array(                                            'decode_args' => array(
312                                                'seperator' => "_",                                                'seperator' => "_",
313                                                'form' => 1,                                                //'form' => 1,
314                                                  ),
315                                              'actionbar' => array(
316                                                  'name' => "ecdfa",
317                                                  'list' => array(
318                                                      "View" => 'view',
319                                                      "Edit" => 'edit',
320                                                      "Delete" => 'delete',
321                                                      "Add new" => 'add',
322                                                      ),
323                                                ),                                                ),
324                                            ),                                            ),
325                        );                        );
326        // switch abstract type        // switch abstract type
327        } elseif ($val['ecom_abstract_type'] == "item") {        } elseif ($val['ecom_abstract_type'] == "item") {
328          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
329            //$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']);
330            $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);            $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']);
331          } else {          } else {
332            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] !");
333          }          }
334          if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }          if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
335          print "Mode: $val[ecom_mode]<br>";          print "Mode: $val[ecom_mode]<br>";
336          $args = array(          $args = array(
337                        'caption' => "Item",                        'caption' => $val['ecom_data_meta'],
338                        'mode' => $val['ecom_mode'],                        'mode' => $val['ecom_mode'],
339                        'options' => array(                        'options' => array(
340                                            'data_locator_meta' => $data_locator_meta,                                            'data_locator_meta' => $data_locator_meta,
# Line 278  class WebExplorer_AbstractExplorer { Line 346  class WebExplorer_AbstractExplorer {
346                        );                        );
347           if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }           if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
348        }        }
349        
350      // switch component type      // switch component type
351      } elseif ($val['ecom_type'] == "nav") {      } elseif ($val['ecom_type'] == "nav") {
352        // switch abstract type        // switch abstract type
353        if($val['ecom_abstract_type'] == "list") {        if($val['ecom_abstract_type'] == "list") {
354           $args = array();
355          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
356            $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'concrete' );            // switch component label
357              if($label == "nav") {
358                $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
359                $args['caption'] = "Objekt Typen";
360              }
361              // NEW [2003-04-05]: DataSource.Chooser
362              elseif ($label == "chooser") {
363                $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
364                $args['caption'] = "Datenquellen";
365              }
366              $args['options']['data_locator_meta'] = $data_locator_meta;
367          } else {          } else {
368            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] !");
369          }          }
         $args = array(  
                       'caption' => "Objekt Typen",  
                       'options' => array(  
                                           'data_locator_meta' => $data_locator_meta,  
                                           ),  
                       );  
370        } elseif ($val['ecom_abstract_type'] == "tree") {        } elseif ($val['ecom_abstract_type'] == "tree") {
371          $args = array();          $args = array();
372        }        }
373    
374        // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
375        // switch component type
376        } elseif ($val['ecom_type'] == "call") {
377    
378          // responses of RemoteActions are not predictable!
379          if ($val['ecom_abstract_type'] == "auto") {
380            
381            // Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere!
382    
383            // Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently.
384            // Really - just a remote call is issued, no data-/schema-structures or similar are expected.
385            
386            // The RemoteMethod 'method' is called directly with arguments in 'args'!
387            // As response (important for widget assignement!) you may expect an arbitrary payload.
388            $args['options']['data_locator_meta'] = array(
389              transport => 'rpc',
390              metatype => 'method',
391              method => $val['ecom_call_method'],
392              args => $val['ecom_call_args']
393            );
394            
395          } else {
396            // FIXME: implement automatic re-dispatching to available ecoms here!
397            user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
398          }      
399    
400      }      }
401      return $args;      return $args;
402    }    }
403    
404    
405    
406    function get_msg($label) {    function get_msg($label) {
407      if($label == "welcome") {      if($label == "welcome") {
408        $msg = "Welcome to the Explorer.";        $msg = "Welcome to the Explorer.";
409      }      }
410      return $msg;      return $msg;
411    }    }
412    
413    
414        
415    function render() {    function render() {
416      user_error("AbstractExplorer::render - please implement me....");      user_error("AbstractExplorer::render - please implement me....");

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

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