/[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.1 by jonen, Thu Mar 20 03:48:46 2003 UTC revision 1.12 by joko, Tue Apr 8 17:52:12 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.12  2003/04/08 17:52:12  joko
8    ##    CHANGE: renamed property 'datasource' to 'transport'
9    ##    NEW: Module 'RemoteAction'
10    ##
11    ##    Revision 1.11  2003/04/07 22:31:51  jonen
12    ##    + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav'
13    ##    - removed recent added ecom type chooser
14    ##
15    ##    Revision 1.10  2003/04/05 20:32:04  joko
16    ##    added Chooser
17    ##
18    ##    Revision 1.9  2003/04/04 02:22:37  joko
19    ##    minor fix: querySchema now issues argument
20    ##
21    ##    Revision 1.8  2003/04/04 01:16:03  jonen
22    ##    +  integrated different mode's for 'DataItem'
23    ##
24    ##    Revision 1.7  2003/03/29 07:49:55  joko
25    ##    show boxes in DEBUG-mode only!
26    ##
27    ##    Revision 1.6  2003/03/28 06:42:37  joko
28    ##    fix: propagating rpc-debugging-options to constants here
29    ##
30    ##    Revision 1.5  2003/03/27 01:24:29  jonen
31    ##    + enabled navigation ecom (only list yet)
32    ##
33    ##    Revision 1.4  2003/03/20 08:02:11  jonen
34    ##    + purged code
35    ##
36    ##    Revision 1.3  2003/03/20 07:54:52  jonen
37    ##    + added docu
38    ##
39    ##    Revision 1.2  2003/03/20 07:44:31  jonen
40    ##    + removed dumper
41    ##
42  ##    Revision 1.1  2003/03/20 03:48:46  jonen  ##    Revision 1.1  2003/03/20 03:48:46  jonen
43  ##    + initial commit  ##    + initial commit
44  ##  ##
# Line 26  Line 61 
61  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
62  */  */
63    
64    /**
65     * WebExplorer::AbstractExplorer - this can be simple compared to a container,
66     *  which modular GUI classes can be register, manipulated and rendered...
67     *
68     * @author Sebastian Utz <seut@tunemedia.de>
69     * @package org.netfrag.app
70     * @name WebExplorer::AbstractExplorer
71     */
72    
73    
74  class WebExplorer_AbstractExplorer {  class WebExplorer_AbstractExplorer {
75    
# Line 54  class WebExplorer_AbstractExplorer { Line 98  class WebExplorer_AbstractExplorer {
98    */    */
99   var $_e_state = array();   var $_e_state = array();
100    
  // needed (old)?  
  var $_control = array();  
  var $_hidden_elements = array();  
   
101    
102    function WebExplorer_AbstractExplorer($data_locators=array()) {    function WebExplorer_AbstractExplorer($data_locators=array()) {
103      $this->_data_locators = $data_locators;      $this->_data_locators = $data_locators;
104      $this->init_default_gui_modules();      $this->init_default_gui_modules();    
       
105      $this->set_e_state();      $this->set_e_state();
106      print "State: " . Dumper($this->_state) ."<br>";  
107      print "E_State: " . Dumper($this->_e_state) ."<br>";      //debug
108      //$this->init_state();      //print "State: " . Dumper($this->_state) ."<br>";
109        $div = html_div();
110        $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
111        $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
112        if (constants::get('DEBUG')) {
113          print $div->render();
114        }
115    }    }
116    
117    
# Line 81  class WebExplorer_AbstractExplorer { Line 126  class WebExplorer_AbstractExplorer {
126        $rpcinfo = $app->getConfig("rpcinfo");        $rpcinfo = $app->getConfig("rpcinfo");
127        define('RPC_HOSTNAME', $rpcinfo[Host]);        define('RPC_HOSTNAME', $rpcinfo[Host]);
128        define('RPC_PORT', $rpcinfo[Port]);        define('RPC_PORT', $rpcinfo[Port]);
129          define('RPC_DEBUG', $rpcinfo[DEBUG]);
130          define('RPC_TRACE', $rpcinfo[TRACE]);
131          define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
132      } else {      } else {
133        user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");        user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");
134      }      }
# Line 106  class WebExplorer_AbstractExplorer { Line 154  class WebExplorer_AbstractExplorer {
154        
155    
156    function init_default_gui_modules() {    function init_default_gui_modules() {
157        
158        // format of parameters: label, ecom_type, abstract_type, module_name
159        
160      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
161      $this->register_gui_module("list", "nav", array( 'name' => "NavigationList", 'type' => "list") );      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
162      $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
163      $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
164        // 2003-04-05 - Chooser
165        $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");    
166        // 2003-04-07 - RemoteAction
167        $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");    
168    }    }
169    
170    function register_source_module($label, $args) {    function register_source_module($label, $args) {
171      $this->_module['source'][$label] = $args;      $this->_module['source'][$label] = $args;
172    }    }
173        
174    function register_gui_module($abstract_type, $ecom_type, $args) {    function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
175      $this->_module['gui'][$ecom_type][$abstract_type] = $args;      $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
176    }    }
177    
178    
179    function &get_ecom($label) {    function &get_ecom($label) {
180      //return "Hello World";      //return "Hello World";
181      $this->_load_ecom($label);      $this->_load_ecom($label);
182      return $this->_ecom[$label];      return $this->_ecom[$label];
183    }    }
184    
185    
186        
187    function _load_ecoms() {    function _load_ecoms() {
188        //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
189      foreach($this->_e_state[ecoms] as $label => $val) {      foreach($this->_e_state[ecoms] as $label => $val) {
190        $this->_load_ecom($label);        $this->_load_ecom($label);
191      }      }
192    }    }
193    
194    
195        
196    function _load_ecom($label) {    function _load_ecom($label) {
197        // fetch values from state
198      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
199      // find right gui module      debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
200      $com_type = $val['ecom_type'];  
201        // find right ecom gui module
202        $ecom_type = $val['ecom_type'];
203      $abstract_type = $val['ecom_abstract_type'];      $abstract_type = $val['ecom_abstract_type'];
204      $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
205        //print Dumper($gui_module);
206      if(!$gui_module) {      if(!$gui_module) {
207        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]']");
208        return;        return;
209      }      }
210      // get arguments needed for gui module  
211        // get arguments needed for ecom gui module
212      $args = $this->_prepare_component_args($label);      $args = $this->_prepare_component_args($label);
213      //print Dumper($args);      //print Dumper($args);
214            
215      // get GUI module      // get ecom GUI module
216      $ecom = php::mkComponent($gui_module, $args);      if (!$ecom = php::mkComponent($gui_module, $args)) {
217          return;
218        }
219      //print Dumper($ecom);      //print Dumper($ecom);
220                    
221      // get phphtmllib GUI object      // load phphtmllib GUI object
222      $gui_ecom = &$ecom->get();      $gui_ecom = &$ecom->get();
223    
224      // add hidden vars, needed for explorer control      // add hidden vars, needed for explorer control
225      $hidden_items = $this->_get_hidden_items($label);      $hidden_items = $this->_get_hidden_items($label);
226      $ecom->add_hidden_items($hidden_items);      if(is_array($hidden_items) ) {
227      //print "Hidden: " . Dumper($gui_ecom->_hidden_items);        $ecom->add_hidden_items($hidden_items);
228          //print "Hidden: " . Dumper($hidden_items);
229        }
230    
231        // attempt:
232        //$gui_ecom->make_transparent();
233        
234        // store phphtmllib GUI object
235      $this->_ecom[$label] = &$gui_ecom;      $this->_ecom[$label] = &$gui_ecom;
236    }    }
237    
238    
239    
240    function _get_hidden_items($label) {    function _get_hidden_items($label) {
241      $ecom_state = $this->_e_state['ecoms'][$label];      $ecom_state = $this->_e_state['ecoms'][$label];
242      if($ecom_state['ecom_abstract_type'] == "list") {      if($ecom_state['ecom_type'] == "data") {
243        $hidden_items = array(        if($ecom_state['ecom_abstract_type'] == "list") {
244            $hidden_items = array(
245                                    'ecl' => $label,                                    'ecl' => $label,
246                                      'ecat' => "item",
247                                      'ecmod' => "view",
248                                    );                                    );
249          }
250          elseif($ecom_state['ecom_abstract_type'] == "item") {
251            $hidden_items = array(
252                                      'ecl' => $label,
253                                      'ecat' => "item",
254                                      'ecmod' => "view",
255                                      );
256    /*
257            if($ecom_state['ecom_mode'] == "view") {
258              $hidden_items['ecmod'] = "edit";
259            }
260            elseif($ecom_state['ecom_mode'] == "edit") {
261              $hidden_items['ecmod'] = "edit";
262            }
263    */      
264          }
265          $hidden_items['ap'] = "explorer";
266      }      }
     // set default hidden item for whole explorer  
     $hidden_items['ap'] = "explorer";  
267      return $hidden_items;      return $hidden_items;
268    }    }
269    
270    
271    
272    function _prepare_component_args($label) {        function _prepare_component_args($label) {    
273      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
274      $this->set_data_locator($val['ecom_data_locator_key']);      $this->set_data_locator($val['ecom_data_locator_key']);
275      if($val['ecom_abstract_type'] == "list") {  
276        if($val['ecom_data_locator_key'] == "rpc") {      // detect and execute 'selectSource' action
277          $data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);      // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
278        } else {      //print Dumper($this->_e_state['sources']);
279          user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");      if ($source = $this->_e_state['main']['ecom_data_source_key']) {
280        }        //print "selectSource: $source<br/>";
281        $args = array(        //global $app;
282                        'caption' => "Liste",        //print Dumper($backend);
283          //$app->backend->do();
284        }
285        
286        // switch component type
287        if($val['ecom_type'] == "data") {
288          // switch abstract type
289          if($val['ecom_abstract_type'] == "list") {
290            if($val['ecom_data_locator_key'] == "rpc") {
291              //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
292              $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
293            } else {
294              user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
295            }
296            $args = array(
297                          'caption' => $val['ecom_data_ident'],
298                        'orderby' => "Guid",                        'orderby' => "Guid",
299                        'options' => array(                        'options' => array(
300                                            'data_locator_meta' => $data_locator_meta,                                            'data_locator_meta' => $data_locator_meta,
# Line 194  class WebExplorer_AbstractExplorer { Line 305  class WebExplorer_AbstractExplorer {
305                                                ),                                                ),
306                                            ),                                            ),
307                        );                        );
308      } elseif ($ecom_type == "item") {        // switch abstract type
309        $args = array();        } elseif ($val['ecom_abstract_type'] == "item") {
310      } elseif ($ecom_type == "nav") {          if($val['ecom_data_locator_key'] == "rpc") {
311        $args = array();            //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
312              $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);
313            } else {
314              user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
315            }
316            if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
317            print "Mode: $val[ecom_mode]<br>";
318            $args = array(
319                          'caption' => $val['ecom_data_meta'],
320                          'mode' => $val['ecom_mode'],
321                          'options' => array(
322                                              'data_locator_meta' => $data_locator_meta,
323                                              'decode' => 1,
324                                              'decode_args' => array(
325                                                  'seperator' => "_",
326                                                  ),
327                                              ),
328                          );
329             if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
330          }
331        
332        // switch component type
333        } elseif ($val['ecom_type'] == "nav") {
334          // switch abstract type
335          if($val['ecom_abstract_type'] == "list") {
336           $args = array();
337            if($val['ecom_data_locator_key'] == "rpc") {
338              // switch component label
339              if($label == "nav") {
340                $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
341                $args['caption'] = "Objekt Typen";
342              }
343              // NEW [2003-04-05]: DataSource.Chooser
344              elseif ($label == "chooser") {
345                $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
346                $args['caption'] = "Datenquellen";
347              }
348              $args['options']['data_locator_meta'] = $data_locator_meta;
349            } else {
350              user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
351            }
352          } elseif ($val['ecom_abstract_type'] == "tree") {
353            $args = array();
354          }
355    
356        // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
357        // switch component type
358        } elseif ($val['ecom_type'] == "call") {
359    
360          // responses of RemoteActions are not predictable!
361          if ($val['ecom_abstract_type'] == "auto") {
362            
363            // Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere!
364    
365            // Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently.
366            // Really - just a remote call is issued, no data-/schema-structures or similar are expected.
367            
368            // The RemoteMethod 'method' is called directly with arguments in 'args'!
369            // As response (important for widget assignement!) you may expect an arbitrary payload.
370            $args['options']['data_locator_meta'] = array(
371              transport => 'rpc',
372              metatype => 'method',
373              method => $val['ecom_call_method'],
374              args => $val['ecom_call_args']
375            );
376            
377          } else {
378            // FIXME: implement automatic re-dispatching to available ecoms here!
379            user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
380          }      
381    
382      }      }
383      return $args;      return $args;
384    }    }
385    
386    
387    
388    function get_msg($label) {    function get_msg($label) {
389      if($label == "welcome") {      if($label == "welcome") {
390        $msg = "Welcome to the Explorer.";        $msg = "Welcome to the Explorer.";
391      }      }
392      return $msg;      return $msg;
393    }    }
394    
395    
396        
397    function render() {    function render() {
398      user_error("AbstractExplorer::render - please implement me....");      user_error("AbstractExplorer::render - please implement me....");

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.12

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