/[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.17 - (hide annotations)
Fri Apr 18 13:46:15 2003 UTC (21 years, 3 months ago) by jonen
Branch: MAIN
Changes since 1.16: +47 -15 lines
+ add hidden elements(items) now to the constructor arguments of each ecom

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

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