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

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