/[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.10 by joko, Sat Apr 5 20:32:04 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.10  2003/04/05 20:32:04  joko
8    ##    added Chooser
9    ##
10    ##    Revision 1.9  2003/04/04 02:22:37  joko
11    ##    minor fix: querySchema now issues argument
12    ##
13    ##    Revision 1.8  2003/04/04 01:16:03  jonen
14    ##    +  integrated different mode's for 'DataItem'
15    ##
16    ##    Revision 1.7  2003/03/29 07:49:55  joko
17    ##    show boxes in DEBUG-mode only!
18    ##
19    ##    Revision 1.6  2003/03/28 06:42:37  joko
20    ##    fix: propagating rpc-debugging-options to constants here
21    ##
22    ##    Revision 1.5  2003/03/27 01:24:29  jonen
23    ##    + enabled navigation ecom (only list yet)
24    ##
25    ##    Revision 1.4  2003/03/20 08:02:11  jonen
26    ##    + purged code
27    ##
28    ##    Revision 1.3  2003/03/20 07:54:52  jonen
29    ##    + added docu
30    ##
31    ##    Revision 1.2  2003/03/20 07:44:31  jonen
32    ##    + removed dumper
33    ##
34  ##    Revision 1.1  2003/03/20 03:48:46  jonen  ##    Revision 1.1  2003/03/20 03:48:46  jonen
35  ##    + initial commit  ##    + initial commit
36  ##  ##
# Line 26  Line 53 
53  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
54  */  */
55    
56    /**
57     * WebExplorer::AbstractExplorer - this can be simple compared to a container,
58     *  which modular GUI classes can be register, manipulated and rendered...
59     *
60     * @author Sebastian Utz <seut@tunemedia.de>
61     * @package org.netfrag.app
62     * @name WebExplorer::AbstractExplorer
63     */
64    
65    
66  class WebExplorer_AbstractExplorer {  class WebExplorer_AbstractExplorer {
67    
# Line 54  class WebExplorer_AbstractExplorer { Line 90  class WebExplorer_AbstractExplorer {
90    */    */
91   var $_e_state = array();   var $_e_state = array();
92    
  // needed (old)?  
  var $_control = array();  
  var $_hidden_elements = array();  
   
93    
94    function WebExplorer_AbstractExplorer($data_locators=array()) {    function WebExplorer_AbstractExplorer($data_locators=array()) {
95      $this->_data_locators = $data_locators;      $this->_data_locators = $data_locators;
96      $this->init_default_gui_modules();      $this->init_default_gui_modules();
97            
98      $this->set_e_state();      $this->set_e_state();
99      print "State: " . Dumper($this->_state) ."<br>";      //print "State: " . Dumper($this->_state) ."<br>";
100      print "E_State: " . Dumper($this->_e_state) ."<br>";      $div = html_div();
101        $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
102        $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
103        if (constants::get('DEBUG')) {
104          print $div->render();
105        }
106      //$this->init_state();      //$this->init_state();
107    }    }
108    
# Line 81  class WebExplorer_AbstractExplorer { Line 118  class WebExplorer_AbstractExplorer {
118        $rpcinfo = $app->getConfig("rpcinfo");        $rpcinfo = $app->getConfig("rpcinfo");
119        define('RPC_HOSTNAME', $rpcinfo[Host]);        define('RPC_HOSTNAME', $rpcinfo[Host]);
120        define('RPC_PORT', $rpcinfo[Port]);        define('RPC_PORT', $rpcinfo[Port]);
121          define('RPC_DEBUG', $rpcinfo[DEBUG]);
122          define('RPC_TRACE', $rpcinfo[TRACE]);
123          define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
124      } else {      } else {
125        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!");
126      }      }
# Line 107  class WebExplorer_AbstractExplorer { Line 147  class WebExplorer_AbstractExplorer {
147    
148    function init_default_gui_modules() {    function init_default_gui_modules() {
149      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );      //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
150      $this->register_gui_module("list", "nav", array( 'name' => "NavigationList", 'type' => "list") );      $this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") );
151      $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );      $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );
152      $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );      $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );
153        // 2003-04-05 - Chooser
154        $this->register_gui_module("list", "chooser", array( 'name' => "WebExplorer::Module::Chooser", 'type' => "list") );
155    }    }
156    
157    function register_source_module($label, $args) {    function register_source_module($label, $args) {
# Line 127  class WebExplorer_AbstractExplorer { Line 169  class WebExplorer_AbstractExplorer {
169    }    }
170        
171    function _load_ecoms() {    function _load_ecoms() {
172        //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
173      foreach($this->_e_state[ecoms] as $label => $val) {      foreach($this->_e_state[ecoms] as $label => $val) {
174        $this->_load_ecom($label);        $this->_load_ecom($label);
175      }      }
176    }    }
177        
178    function _load_ecom($label) {    function _load_ecom($label) {
179        
180      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
181        debug::info("_load_ecom: " . Dumper($val) . "<br/>");
182      // find right gui module      // find right gui module
183      $com_type = $val['ecom_type'];      $com_type = $val['ecom_type'];
184      $abstract_type = $val['ecom_abstract_type'];      $abstract_type = $val['ecom_abstract_type'];
185      $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];      $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];
186      if(!$gui_module) {      if(!$gui_module) {
187        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]']");
188        return;        return;
189      }      }
190      // get arguments needed for gui module      // get arguments needed for gui module
# Line 155  class WebExplorer_AbstractExplorer { Line 200  class WebExplorer_AbstractExplorer {
200    
201      // add hidden vars, needed for explorer control      // add hidden vars, needed for explorer control
202      $hidden_items = $this->_get_hidden_items($label);      $hidden_items = $this->_get_hidden_items($label);
203      $ecom->add_hidden_items($hidden_items);      if(is_array($hidden_items) ) {
204      //print "Hidden: " . Dumper($gui_ecom->_hidden_items);        $ecom->add_hidden_items($hidden_items);
205          //print "Hidden: " . Dumper($hidden_items);
206        }
207    
208      $this->_ecom[$label] = &$gui_ecom;      $this->_ecom[$label] = &$gui_ecom;
209    }    }
210    
211    function _get_hidden_items($label) {    function _get_hidden_items($label) {
212      $ecom_state = $this->_e_state['ecoms'][$label];      $ecom_state = $this->_e_state['ecoms'][$label];
213      if($ecom_state['ecom_abstract_type'] == "list") {      if($ecom_state['ecom_type'] == "data") {
214        $hidden_items = array(        if($ecom_state['ecom_abstract_type'] == "list") {
215            $hidden_items = array(
216                                      'ecl' => $label,
217                                      'ecat' => "item",
218                                      'ecmod' => "view",
219                                      );
220          }
221          elseif($ecom_state['ecom_abstract_type'] == "item") {
222            $hidden_items = array(
223                                    'ecl' => $label,                                    'ecl' => $label,
224                                      'ecat' => "item",
225                                      'ecmod' => "view",
226                                    );                                    );
227    /*
228            if($ecom_state['ecom_mode'] == "view") {
229              $hidden_items['ecmod'] = "edit";
230            }
231            elseif($ecom_state['ecom_mode'] == "edit") {
232              $hidden_items['ecmod'] = "edit";
233            }
234    */      
235          }
236          $hidden_items['ap'] = "explorer";
237      }      }
     // set default hidden item for whole explorer  
     $hidden_items['ap'] = "explorer";  
238      return $hidden_items;      return $hidden_items;
239    }    }
240    
241    function _prepare_component_args($label) {        function _prepare_component_args($label) {    
242      $val = $this->_e_state['ecoms'][$label];      $val = $this->_e_state['ecoms'][$label];
243      $this->set_data_locator($val['ecom_data_locator_key']);      $this->set_data_locator($val['ecom_data_locator_key']);
244      if($val['ecom_abstract_type'] == "list") {  
245        if($val['ecom_data_locator_key'] == "rpc") {      // detect and execute 'selectSource' action
246          $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.
247        } else {      //print Dumper($this->_e_state['sources']);
248          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']) {
249        }        //print "selectSource: $source<br/>";
250        $args = array(        //global $app;
251          //print Dumper($backend);
252          //$app->backend->do();
253        }
254        
255        // switch component type
256        if($val['ecom_type'] == "data") {
257          // switch abstract type
258          if($val['ecom_abstract_type'] == "list") {
259            if($val['ecom_data_locator_key'] == "rpc") {
260              //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
261              $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
262            } else {
263              user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
264            }
265            $args = array(
266                        'caption' => "Liste",                        'caption' => "Liste",
267                        'orderby' => "Guid",                        'orderby' => "Guid",
268                        'options' => array(                        'options' => array(
# Line 194  class WebExplorer_AbstractExplorer { Line 274  class WebExplorer_AbstractExplorer {
274                                                ),                                                ),
275                                            ),                                            ),
276                        );                        );
277      } elseif ($ecom_type == "item") {        // switch abstract type
278        $args = array();        } elseif ($val['ecom_abstract_type'] == "item") {
279      } elseif ($ecom_type == "nav") {          if($val['ecom_data_locator_key'] == "rpc") {
280        $args = array();            //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
281              $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);
282            } else {
283              user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
284            }
285            if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
286            print "Mode: $val[ecom_mode]<br>";
287            $args = array(
288                          'caption' => "Item",
289                          'mode' => $val['ecom_mode'],
290                          'options' => array(
291                                              'data_locator_meta' => $data_locator_meta,
292                                              'decode' => 1,
293                                              'decode_args' => array(
294                                                  'seperator' => "_",
295                                                  ),
296                                              ),
297                          );
298             if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
299          }
300        
301        // switch component type
302        } elseif ($val['ecom_type'] == "nav") {
303          // switch abstract type
304          if($val['ecom_abstract_type'] == "list") {
305            if($val['ecom_data_locator_key'] == "rpc") {
306              $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
307            } else {
308              user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
309            }
310            $args = array(
311                          'caption' => "Objekt Typen",
312                          'options' => array(
313                                              'data_locator_meta' => $data_locator_meta,
314                                              ),
315                          );
316          } elseif ($val['ecom_abstract_type'] == "tree") {
317            $args = array();
318          }
319    
320        // switch component type
321        // NEW [2003-04-05]: DataSource.Chooser
322        } elseif ($val['ecom_type'] == "chooser") {
323    
324          // switch abstract type
325          if($val['ecom_abstract_type'] == "list") {
326            if ($val['ecom_data_locator_key'] == "rpc") {
327              $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'sources.all' );
328            } else {
329              user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
330            }
331            $args = array(
332              'caption' => "Datenquellen",
333              'options' => array(
334              'data_locator_meta' => $data_locator_meta,
335              ),
336            );
337          } elseif ($val['ecom_abstract_type'] == "tree") {
338            $args = array();
339          }
340    
341      }      }
342      return $args;      return $args;
343    }    }

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

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