/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations)
Wed Apr 9 00:03:11 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.12: +6 -2 lines
disabled form rendering for inheritanced items at 'list'

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

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