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

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