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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show 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 <?
2 /*
3 ## -----------------------------------------------------------------------------
4 ## $Id: AbstractExplorer.php,v 1.15 2003/04/09 02:08:20 joko Exp $
5 ## -----------------------------------------------------------------------------
6 ## $Log: AbstractExplorer.php,v $
7 ## Revision 1.15 2003/04/09 02:08:20 joko
8 ## CHANGE: renamed key 'classname' through 'nodename'
9 ##
10 ## Revision 1.14 2003/04/09 00:31:27 jonen
11 ## + added arguments for data list ecom
12 ##
13 ## Revision 1.13 2003/04/09 00:03:11 jonen
14 ## disabled form rendering for inheritanced items at 'list'
15 ##
16 ## Revision 1.12 2003/04/08 17:52:12 joko
17 ## CHANGE: renamed property 'datasource' to 'transport'
18 ## NEW: Module 'RemoteAction'
19 ##
20 ## 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 ## Revision 1.10 2003/04/05 20:32:04 joko
25 ## added Chooser
26 ##
27 ## Revision 1.9 2003/04/04 02:22:37 joko
28 ## minor fix: querySchema now issues argument
29 ##
30 ## Revision 1.8 2003/04/04 01:16:03 jonen
31 ## + integrated different mode's for 'DataItem'
32 ##
33 ## Revision 1.7 2003/03/29 07:49:55 joko
34 ## show boxes in DEBUG-mode only!
35 ##
36 ## Revision 1.6 2003/03/28 06:42:37 joko
37 ## fix: propagating rpc-debugging-options to constants here
38 ##
39 ## Revision 1.5 2003/03/27 01:24:29 jonen
40 ## + enabled navigation ecom (only list yet)
41 ##
42 ## Revision 1.4 2003/03/20 08:02:11 jonen
43 ## + purged code
44 ##
45 ## Revision 1.3 2003/03/20 07:54:52 jonen
46 ## + added docu
47 ##
48 ## Revision 1.2 2003/03/20 07:44:31 jonen
49 ## + removed dumper
50 ##
51 ## Revision 1.1 2003/03/20 03:48:46 jonen
52 ## + initial commit
53 ##
54 ## 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
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
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 $this->init_default_gui_modules();
114 $this->set_e_state();
115
116 //debug
117 //print "State: " . Dumper($this->_state) ."<br>";
118 $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 if (constants::get('DEBUG')) {
122 print $div->render();
123 }
124 }
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 define('RPC_DEBUG', $rpcinfo[DEBUG]);
139 define('RPC_TRACE', $rpcinfo[TRACE]);
140 define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
141 } 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
167 // format of parameters: label, ecom_type, abstract_type, module_name
168
169 //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
170 $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 // 2003-04-05 - Chooser
174 $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
175 // 2003-04-07 - RemoteAction
176 $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 }
182
183 function register_source_module($label, $args) {
184 $this->_module['source'][$label] = $args;
185 }
186
187 function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
188 $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
189 }
190
191
192 function &get_ecom($label) {
193 //return "Hello World";
194 $this->_load_ecom($label);
195 return $this->_ecom[$label];
196 }
197
198
199
200 function _load_ecoms() {
201 //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
202 foreach($this->_e_state[ecoms] as $label => $val) {
203 $this->_load_ecom($label);
204 }
205 }
206
207
208
209 function _load_ecom($label) {
210
211 // fetch values from state
212 $val = $this->_e_state['ecoms'][$label];
213 debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
214
215 // 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 // find right ecom gui module
222 $ecom_type = $val['ecom_type'];
223 $abstract_type = $val['ecom_abstract_type'];
224 $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
225 //print Dumper($gui_module);
226 if(!$gui_module) {
227 user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
228 return;
229 }
230
231 // get arguments needed for ecom gui module
232 $args = $this->_prepare_component_args($label);
233 //print Dumper($args);
234
235 // get ecom GUI module
236 if (!$ecom = php::mkComponent($gui_module, $args)) {
237 return;
238 }
239 //print Dumper($ecom);
240
241 // load phphtmllib GUI object
242 $gui_ecom = &$ecom->get();
243
244 // add hidden vars, needed for explorer control
245 $hidden_items = $this->_get_hidden_items($label);
246 if(is_array($hidden_items) ) {
247 $ecom->add_hidden_items($hidden_items);
248 //print "Hidden: " . Dumper($hidden_items);
249 }
250
251 // attempt:
252 //$gui_ecom->make_transparent();
253
254 // store phphtmllib GUI object
255 $this->_ecom[$label] = &$gui_ecom;
256 }
257
258
259
260 function _get_hidden_items($label) {
261 $ecom_state = $this->_e_state['ecoms'][$label];
262 if($ecom_state['ecom_type'] == "data") {
263 if($ecom_state['ecom_abstract_type'] == "list") {
264 $hidden_items = array(
265 'ecl' => $label,
266 'ecat' => "item",
267 'ecmod' => "view",
268 );
269 }
270 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 $hidden_items['ap'] = "explorer";
286 }
287 return $hidden_items;
288 }
289
290
291
292 function _prepare_component_args($label) {
293 $val = $this->_e_state['ecoms'][$label];
294 $this->set_data_locator($val['ecom_data_locator_key']);
295
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 // 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 //$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 } 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 'caption' => $val['ecom_data_ident'],
318 'orderby' => "Guid",
319 'options' => array(
320 'data_locator_meta' => $data_locator_meta,
321 'decode' => 1,
322 'decode_args' => array(
323 'seperator' => "_",
324 //'form' => 1,
325 ),
326 'actionbar' => array(
327 'name' => "ecdfa",
328 'list' => array(
329 "View" => 'view',
330 "Edit" => 'edit',
331 "Delete" => 'delete',
332 "Add new" => 'add',
333 ),
334 ),
335 ),
336 );
337 // switch abstract type
338 } elseif ($val['ecom_abstract_type'] == "item") {
339 if($val['ecom_data_locator_key'] == "rpc") {
340 //$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 } else {
343 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
344 }
345
346 // defaults
347 if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
348 //$val['ecom_mode'] = "view";
349
350 // debugging
351 print "Mode: $val[ecom_mode]<br>";
352
353 // prepare some arguments...
354 $args = array(
355 'caption' => $val['ecom_data_meta'],
356 '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 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 }
372
373 // switch component type
374 } elseif ($val['ecom_type'] == "nav") {
375 // switch abstract type
376 if($val['ecom_abstract_type'] == "list") {
377 $args = array();
378 if($val['ecom_data_locator_key'] == "rpc") {
379 // switch component label
380 if($label == "nav") {
381 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
382 $args['caption'] = "Objekt Typen";
383 }
384 // NEW [2003-04-05]: DataSource.Chooser
385 elseif ($label == "chooser") {
386 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
387 $args['caption'] = "Datenquellen";
388 }
389 $args['options']['data_locator_meta'] = $data_locator_meta;
390 } else {
391 user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
392 }
393 } elseif ($val['ecom_abstract_type'] == "tree") {
394 $args = array();
395 }
396
397 // 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
423 }
424 return $args;
425 }
426
427
428
429 function get_msg($label) {
430 if($label == "welcome") {
431 $msg = "Welcome to the Explorer.";
432 }
433 return $msg;
434 }
435
436
437
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