/[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.16 - (hide annotations)
Thu Apr 10 06:00:58 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.15: +30 -4 lines
ALPHA: Item.Delete

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

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