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

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