/[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.17 by jonen, Fri Apr 18 13:46:15 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.17  2003/04/18 13:46:15  jonen
8    ##    + add hidden elements(items) now to the constructor arguments of each ecom
9    ##
10    ##    Revision 1.16  2003/04/10 06:00:58  joko
11    ##    ALPHA: Item.Delete
12    ##
13    ##    Revision 1.15  2003/04/09 02:08:20  joko
14    ##    CHANGE: renamed key 'classname' through 'nodename'
15    ##
16    ##    Revision 1.14  2003/04/09 00:31:27  jonen
17    ##    + added arguments for data list ecom
18    ##
19    ##    Revision 1.13  2003/04/09 00:03:11  jonen
20    ##    disabled form rendering for inheritanced items at 'list'
21    ##
22    ##    Revision 1.12  2003/04/08 17:52:12  joko
23    ##    CHANGE: renamed property 'datasource' to 'transport'
24    ##    NEW: Module 'RemoteAction'
25    ##
26    ##    Revision 1.11  2003/04/07 22:31:51  jonen
27    ##    + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav'
28    ##    - removed recent added ecom type chooser
29    ##
30    ##    Revision 1.10  2003/04/05 20:32:04  joko
31    ##    added Chooser
32    ##
33  ##    Revision 1.9  2003/04/04 02:22:37  joko  ##    Revision 1.9  2003/04/04 02:22:37  joko
34  ##    minor fix: querySchema now issues argument  ##    minor fix: querySchema now issues argument
35  ##  ##
# Line 90  class WebExplorer_AbstractExplorer { Line 116  class WebExplorer_AbstractExplorer {
116    
117    function WebExplorer_AbstractExplorer($data_locators=array()) {    function WebExplorer_AbstractExplorer($data_locators=array()) {
118      $this->_data_locators = $data_locators;      $this->_data_locators = $data_locators;
119      $this->init_default_gui_modules();      $this->init_default_gui_modules();    
       
120      $this->set_e_state();      $this->set_e_state();
121    
122        //debug
123      //print "State: " . Dumper($this->_state) ."<br>";      //print "State: " . Dumper($this->_state) ."<br>";
124      $div = html_div();      $div = html_div();
125      $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 127  class WebExplorer_AbstractExplorer {
127      if (constants::get('DEBUG')) {      if (constants::get('DEBUG')) {
128        print $div->render();        print $div->render();
129      }      }
     //$this->init_state();  
130    }    }
131    
132    
# Line 134  class WebExplorer_AbstractExplorer { Line 160  class WebExplorer_AbstractExplorer {
160    function set_e_state() {    function set_e_state() {
161      $this->get_page_state();      $this->get_page_state();
162      $this->_e_state = $this->_state[options][options];      $this->_e_state = $this->_state[options][options];
163        //  print "Setting Explorer state:" . Dumper($this->_e_state);
164    }    }
165        
166    
# Line 143  class WebExplorer_AbstractExplorer { Line 170  class WebExplorer_AbstractExplorer {
170        
171    
172    function init_default_gui_modules() {    function init_default_gui_modules() {
173        
174        // format of parameters: label, ecom_type, abstract_type, module_name
175        
176      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
177      $this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") );      $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
178      $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );      $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
179      $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );      $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
180        // 2003-04-05 - Chooser
181        $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
182        // 2003-04-07 - RemoteAction
183        $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");
184        // 2003-04-09 - Item.Delete
185        $this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem");
186        //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction");
187        //$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem");
188    }    }
189    
190    function register_source_module($label, $args) {    function register_source_module($label, $args) {
191      $this->_module['source'][$label] = $args;      $this->_module['source'][$label] = $args;
192    }    }
193        
194    function register_gui_module($abstract_type, $ecom_type, $args) {    function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
195      $this->_module['gui'][$ecom_type][$abstract_type] = $args;      $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
196    }    }
197    
198    
199    function &get_ecom($label) {    function &get_ecom($label) {
200      //return "Hello World";      //return "Hello World";
201      $this->_load_ecom($label);      $this->_load_ecom($label);
202      return $this->_ecom[$label];      return $this->_ecom[$label];
203    }    }
204    
205    
206        
207    function _load_ecoms() {    function _load_ecoms() {
208        //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
209      foreach($this->_e_state[ecoms] as $label => $val) {      foreach($this->_e_state[ecoms] as $label => $val) {
210        $this->_load_ecom($label);        $this->_load_ecom($label);
211      }      }
212    }    }
213    
214    
215        
216    function _load_ecom($label) {    function _load_ecom($label) {
217        
218        // fetch values from state
219      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
220      // find right gui module      debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
221      $com_type = $val['ecom_type'];  
222        // NEW [2003-04-10]: ecom-RESET-condition
223        if (!is_array($val) && $val == 'RESET') {
224          debug::info("Resetting component: $label");
225          return;
226        }
227    
228        // find right ecom gui module
229        $ecom_type = $val['ecom_type'];
230      $abstract_type = $val['ecom_abstract_type'];      $abstract_type = $val['ecom_abstract_type'];
231      $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];      $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
232        //print Dumper($gui_module);
233      if(!$gui_module) {      if(!$gui_module) {
234        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]']");
235        return;        return;
236      }      }
237      // get arguments needed for gui module  
238        // get arguments needed for ecom gui module
239      $args = $this->_prepare_component_args($label);      $args = $this->_prepare_component_args($label);
240      //print Dumper($args);      //print Dumper($args);
241            
242      // get GUI module      // get ecom GUI module
243      $ecom = php::mkComponent($gui_module, $args);      if (!$ecom = php::mkComponent($gui_module, $args)) {
244          return;
245        }
246      //print Dumper($ecom);      //print Dumper($ecom);
247                
248      // get phphtmllib GUI object      // NOW[2003-18-04] done at via args(prepare args!) to pass at constructor
249      $gui_ecom = &$ecom->get();      //  (needed for non-real objects instanced at some child of AbstractGUIModule, eg. NavigationList)
250    /*
251      // add hidden vars, needed for explorer control      // add hidden vars, needed for explorer control
252      $hidden_items = $this->_get_hidden_items($label);      $hidden_items = $this->_get_hidden_items($label);
253      if(is_array($hidden_items) ) {      if(is_array($hidden_items) ) {
254        $ecom->add_hidden_items($hidden_items);        $ecom->add_hidden_items($hidden_items);
255        //print "Hidden: " . Dumper($hidden_items);        print "Hidden: " . Dumper($hidden_items);
256      }      }
257    */
258    
259        // load phphtmllib GUI object
260        $gui_ecom = &$ecom->get();
261    
262        // attempt:
263        //$gui_ecom->make_transparent();
264        
265        // store phphtmllib GUI object
266      $this->_ecom[$label] = &$gui_ecom;      $this->_ecom[$label] = &$gui_ecom;
267    }    }
268    
269    
270    
271    function _get_hidden_items($label) {    function _get_hidden_items($label) {
272      $ecom_state = $this->_e_state['ecoms'][$label];      $ecom_state = $this->_e_state['ecoms'][$label];
273      if($ecom_state['ecom_type'] == "data") {      if($ecom_state['ecom_type'] == "data") {
# Line 216  class WebExplorer_AbstractExplorer { Line 284  class WebExplorer_AbstractExplorer {
284                                    'ecat' => "item",                                    'ecat' => "item",
285                                    'ecmod' => "view",                                    'ecmod' => "view",
286                                    );                                    );
 /*  
         if($ecom_state['ecom_mode'] == "view") {  
           $hidden_items['ecmod'] = "edit";  
         }  
         elseif($ecom_state['ecom_mode'] == "edit") {  
           $hidden_items['ecmod'] = "edit";  
         }  
 */        
287        }        }
       $hidden_items['ap'] = "explorer";  
288      }      }
289        elseif($ecom_state['ecom_type'] == "nav") {
290          // Switching abstract make no real sense here,
291          // because hidden_items(link_vars) for Naviagtion-Ecoms
292          // are more label specified!!
293          // OLD:
294          //if($ecom_state['ecom_abstract_type'] == "list") {
295          // NEW:
296          if($label == "nav") {
297            $hidden_items = array(
298                                      'ecl' => "content",
299                                      'ecat' => "list",
300                                      'ecmod' => "view",
301                                      'ect' => "data",
302                                      'ecdlk' => "rpc",
303                                     );
304    
305          }
306          elseif($label == "chooser") {
307            $hidden_items = array(
308                                      'ecl' => "phase_startup",
309                                      'ecdlk' => "rpc",
310                                     );
311    
312          }
313        }
314          // add page idents
315          foreach($this->_e_state[idents] as $label => $value) {
316            $hidden_items[$label] = $value;
317          }
318      return $hidden_items;      return $hidden_items;
319    }    }
320    
321    
322    
323    function _prepare_component_args($label) {        function _prepare_component_args($label) {    
324      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
325      $this->set_data_locator($val['ecom_data_locator_key']);      $this->set_data_locator($val['ecom_data_locator_key']);
326    
327        // detect and execute 'selectSource' action
328        // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
329        //print Dumper($this->_e_state['sources']);
330        if ($source = $this->_e_state['main']['ecom_data_source_key']) {
331          //print "selectSource: $source<br/>";
332          //global $app;
333          //print Dumper($backend);
334          //$app->backend->do();
335        }
336        
337      // switch component type      // switch component type
338      if($val['ecom_type'] == "data") {      if($val['ecom_type'] == "data") {
339        // switch abstract type        // switch abstract type
340        if($val['ecom_abstract_type'] == "list") {        if($val['ecom_abstract_type'] == "list") {
341          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
342            //$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']);
343            $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']);
344          } else {          } else {
345            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] !");
346          }          }
347          $args = array(          $args = array(
348                        'caption' => "Liste",                        'caption' => $val['ecom_data_ident'],
349                        'orderby' => "Guid",                        'orderby' => "Guid",
350                        'options' => array(                        'options' => array(
351                                            'data_locator_meta' => $data_locator_meta,                                            'data_locator_meta' => $data_locator_meta,
352                                            'decode' => 1,                                            'decode' => 1,
353                                            'decode_args' => array(                                            'decode_args' => array(
354                                                'seperator' => "_",                                                'seperator' => "_",
355                                                'form' => 1,                                                //'form' => 1,
356                                                  ),
357                                              'actionbar' => array(
358                                                  'name' => "ecdfa",
359                                                  'list' => array(
360                                                      "View" => 'view',
361                                                      "Edit" => 'edit',
362                                                      "Delete" => 'delete',
363                                                      "Add new" => 'add',
364                                                      ),
365                                                ),                                                ),
366                                            ),                                            ),
367                        );                        );
368        // switch abstract type        // switch abstract type
369        } elseif ($val['ecom_abstract_type'] == "item") {        } elseif ($val['ecom_abstract_type'] == "item") {
370          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
371            //$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']);
372            $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']);
373          } else {          } else {
374            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] !");
375          }          }
376            
377            // defaults
378          if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }          if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
379            //$val['ecom_mode'] = "view";
380            
381            // debugging
382          print "Mode: $val[ecom_mode]<br>";          print "Mode: $val[ecom_mode]<br>";
383            
384            // prepare some arguments...
385          $args = array(          $args = array(
386                        'caption' => "Item",                        'caption' => $val['ecom_data_meta'],
387                        'mode' => $val['ecom_mode'],                        'mode' => $val['ecom_mode'],
388                        'options' => array(                        'options' => array(
389                                            'data_locator_meta' => $data_locator_meta,                                            'data_locator_meta' => $data_locator_meta,
# Line 276  class WebExplorer_AbstractExplorer { Line 393  class WebExplorer_AbstractExplorer {
393                                                ),                                                ),
394                                            ),                                            ),
395                        );                        );
396           if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }           if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
397            
398             // FIXME: (see WebExplorer::Module::AbstractGUIModule)
399             //if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; }
400             if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; }
401            
402        }        }
403        
404      // switch component type      // switch component type
405      } elseif ($val['ecom_type'] == "nav") {      } elseif ($val['ecom_type'] == "nav") {
406        // switch abstract type        // switch abstract type
407        if($val['ecom_abstract_type'] == "list") {        if($val['ecom_abstract_type'] == "list") {
408           $args = array();
409          if($val['ecom_data_locator_key'] == "rpc") {          if($val['ecom_data_locator_key'] == "rpc") {
410            $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'concrete' );            // switch component label
411              if($label == "nav") {
412                $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
413                $args['caption'] = "Objekt Typen";
414              }
415              // NEW [2003-04-05]: DataSource.Chooser
416              elseif ($label == "chooser") {
417                $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
418                $args['caption'] = "Datenquellen";
419              }
420              $args['options']['data_locator_meta'] = $data_locator_meta;
421          } else {          } else {
422            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] !");
423          }          }
         $args = array(  
                       'caption' => "Objekt Typen",  
                       'options' => array(  
                                           'data_locator_meta' => $data_locator_meta,  
                                           ),  
                       );  
424        } elseif ($val['ecom_abstract_type'] == "tree") {        } elseif ($val['ecom_abstract_type'] == "tree") {
425          $args = array();          $args = array();
426        }        }
427    
428        // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
429        // switch component type
430        } elseif ($val['ecom_type'] == "call") {
431    
432          // responses of RemoteActions are not predictable!
433          if ($val['ecom_abstract_type'] == "auto") {
434            
435            // Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere!
436    
437            // Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently.
438            // Really - just a remote call is issued, no data-/schema-structures or similar are expected.
439            
440            // The RemoteMethod 'method' is called directly with arguments in 'args'!
441            // As response (important for widget assignement!) you may expect an arbitrary payload.
442            $args['options']['data_locator_meta'] = array(
443              transport => 'rpc',
444              metatype => 'method',
445              method => $val['ecom_call_method'],
446              args => $val['ecom_call_args']
447            );
448            
449          } else {
450            // FIXME: implement automatic re-dispatching to available ecoms here!
451            user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
452          }      
453    
454      }      }
455    
456        // add hidden items to args
457        $args['hidden_elements'] = $this->_get_hidden_items($label);
458    
459      return $args;      return $args;
460    }    }
461    
462    
463    
464    function get_msg($label) {    function get_msg($label) {
465      if($label == "welcome") {      if($label == "welcome") {
466        $msg = "Welcome to the Explorer.";        $msg = "Welcome to the Explorer.";
467      }      }
468      return $msg;      return $msg;
469    }    }
470    
471    
472        
473    function render() {    function render() {
474      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.17

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