1 |
<? |
2 |
/* |
3 |
## ----------------------------------------------------------------------------- |
4 |
## $Id: AbstractExplorer.php,v 1.28 2004/08/31 14:15:49 jonen Exp $ |
5 |
## ----------------------------------------------------------------------------- |
6 |
## $Log: AbstractExplorer.php,v $ |
7 |
## Revision 1.28 2004/08/31 14:15:49 jonen |
8 |
## + added function to clear 'ecom' state |
9 |
## (specially needed to refresh the 'content' block) |
10 |
## |
11 |
## Revision 1.27 2004/03/11 21:01:35 jonen |
12 |
## minor change |
13 |
## |
14 |
## Revision 1.26 2003/12/14 01:50:30 jonen |
15 |
## implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes |
16 |
## |
17 |
## Revision 1.25 2003/11/22 18:47:49 udo |
18 |
## update for expand data item |
19 |
## |
20 |
## Revision 1.24 2003/07/02 11:39:16 jonen |
21 |
## fixed bugs |
22 |
## |
23 |
## Revision 1.23 2003/06/06 11:57:20 joko |
24 |
## minor update: cosmetic changes |
25 |
## |
26 |
## Revision 1.22 2003/05/13 14:50:27 joko |
27 |
## HACKed compatibility for config-type data sources |
28 |
## + function get_data_filter |
29 |
## |
30 |
## Revision 1.21 2003/05/10 18:23:21 jonen |
31 |
## + added stuff relating to 'create/add new' links/buttons |
32 |
## |
33 |
## Revision 1.20 2003/04/19 16:24:49 jonen |
34 |
## + added two more GUI modules to default registry initiation, |
35 |
## relating to new navigation module 'NavigationTree' |
36 |
## + added prepartion of needed args for abstract navigation tree |
37 |
## and concret UserManagment 'UMnav' tree |
38 |
## |
39 |
## Revision 1.19 2003/04/18 16:21:37 joko |
40 |
## fixed commit comment - the last one caused a syntax error!!! |
41 |
## |
42 |
## Revision 1.18 2003/04/18 15:27:06 joko |
43 |
## NEW: XML Trees in data area |
44 |
## new ecom module: DataTree |
45 |
## introduced new query argument: 'filter' (purpose: xml/tree filtering) |
46 |
## $filter = array( |
47 |
## dotted => $val['ecom_data_filter'], |
48 |
## ident => $val['ecom_data_ident'], |
49 |
## ); |
50 |
## A Data::Lift module translates this filter-query into a XPath-query ... |
51 |
## $filter = array( |
52 |
## xpq => '*\/*[@name="cli"]', |
53 |
## ); |
54 |
## ... which finally is propagated to the backend. |
55 |
## NEW: AbstractExplorer - standalone version |
56 |
## enhanced set_e_state: now can overwrite internal state to arguments from outside |
57 |
## enhanced get_com: also capable of propagating additional args through _load_ecom to _prepare_component_args |
58 |
## enhanced _prepare_component_args: now able to dispatch to a "transparent navigation ecom" (e.g. YAA::JobGroups) |
59 |
## MISC: |
60 |
## added some pre-flight checks throughout the module, especially at the core dispatcher inside _prepare_component_args |
61 |
## error checking: added some more croaks via 'user_error' |
62 |
## cosmetic updates |
63 |
## |
64 |
## Revision 1.17 2003/04/18 13:46:15 jonen |
65 |
## + add hidden elements(items) now to the constructor arguments of each ecom |
66 |
## |
67 |
## Revision 1.16 2003/04/10 06:00:58 joko |
68 |
## ALPHA: Item.Delete |
69 |
## |
70 |
## Revision 1.15 2003/04/09 02:08:20 joko |
71 |
## CHANGE: renamed key 'classname' through 'nodename' |
72 |
## |
73 |
## Revision 1.14 2003/04/09 00:31:27 jonen |
74 |
## + added arguments for data list ecom |
75 |
## |
76 |
## Revision 1.13 2003/04/09 00:03:11 jonen |
77 |
## disabled form rendering for inheritanced items at 'list' |
78 |
## |
79 |
## Revision 1.12 2003/04/08 17:52:12 joko |
80 |
## CHANGE: renamed property 'datasource' to 'transport' |
81 |
## NEW: Module 'RemoteAction' |
82 |
## |
83 |
## Revision 1.11 2003/04/07 22:31:51 jonen |
84 |
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
85 |
## - removed recent added ecom type chooser |
86 |
## |
87 |
## Revision 1.10 2003/04/05 20:32:04 joko |
88 |
## added Chooser |
89 |
## |
90 |
## Revision 1.9 2003/04/04 02:22:37 joko |
91 |
## minor fix: querySchema now issues argument |
92 |
## |
93 |
## Revision 1.8 2003/04/04 01:16:03 jonen |
94 |
## + integrated different mode's for 'DataItem' |
95 |
## |
96 |
## Revision 1.7 2003/03/29 07:49:55 joko |
97 |
## show boxes in DEBUG-mode only! |
98 |
## |
99 |
## Revision 1.6 2003/03/28 06:42:37 joko |
100 |
## fix: propagating rpc-debugging-options to constants here |
101 |
## |
102 |
## Revision 1.5 2003/03/27 01:24:29 jonen |
103 |
## + enabled navigation ecom (only list yet) |
104 |
## |
105 |
## Revision 1.4 2003/03/20 08:02:11 jonen |
106 |
## + purged code |
107 |
## |
108 |
## Revision 1.3 2003/03/20 07:54:52 jonen |
109 |
## + added docu |
110 |
## |
111 |
## Revision 1.2 2003/03/20 07:44:31 jonen |
112 |
## + removed dumper |
113 |
## |
114 |
## Revision 1.1 2003/03/20 03:48:46 jonen |
115 |
## + initial commit |
116 |
## |
117 |
## Revision 1.1 2003/03/08 02:36:17 cvsmax |
118 |
## + moved from *.inc |
119 |
## + mungled namespace with WebExplorer |
120 |
## |
121 |
## Revision 1.3 2003/03/03 22:25:21 joko |
122 |
## fixed minor typos |
123 |
## namespace mungling |
124 |
## |
125 |
## Revision 1.2 2003/03/02 00:48:49 cvsmax |
126 |
## + set up gui module registry |
127 |
## - purged old/sample code |
128 |
## |
129 |
## Revision 1.1 2003/03/01 22:57:32 cvsmax |
130 |
## + inital commit |
131 |
## |
132 |
## |
133 |
## ----------------------------------------------------------------------------- |
134 |
*/ |
135 |
|
136 |
/** |
137 |
* WebExplorer::AbstractExplorer - this can be simple compared to a container, |
138 |
* which modular GUI classes can be register, manipulated and rendered... |
139 |
* |
140 |
* @author Sebastian Utz <seut@tunemedia.de> |
141 |
* @package org.netfrag.app |
142 |
* @name WebExplorer::AbstractExplorer |
143 |
*/ |
144 |
|
145 |
|
146 |
class WebExplorer_AbstractExplorer { |
147 |
|
148 |
/** |
149 |
* container holds meta information of data locators |
150 |
*/ |
151 |
var $_data_locators = array(); |
152 |
|
153 |
/** |
154 |
* container for registered modules |
155 |
*/ |
156 |
var $_module = array(); |
157 |
|
158 |
/** |
159 |
* container holds references to each ecom |
160 |
*/ |
161 |
var $_ecom = array(); |
162 |
|
163 |
/** |
164 |
* holds the whole page state |
165 |
*/ |
166 |
var $_state = array(); |
167 |
|
168 |
/** |
169 |
* holds state variables only needed for explorer |
170 |
*/ |
171 |
var $_e_state = array(); |
172 |
|
173 |
|
174 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
175 |
$this->_data_locators = $data_locators; |
176 |
$this->init_default_gui_modules(); |
177 |
$this->set_e_state(); |
178 |
|
179 |
//debug |
180 |
// print "State: " . Dumper($this->_state) ."<br>"; |
181 |
//print "_data_locators: " . Dumper($this->_data_locators) ."<br>"; |
182 |
$div = html_div(); |
183 |
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
184 |
$div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;'); |
185 |
if (constants::get('DEBUG')) { |
186 |
print $div->render(); |
187 |
} |
188 |
} |
189 |
|
190 |
|
191 |
function add_data_locator($label, $args) { |
192 |
$this->_data_locators[$label] = $args; |
193 |
} |
194 |
|
195 |
function set_data_locator($label, $new_args=array() ) { |
196 |
global $app; |
197 |
|
198 |
// pre-flight checks |
199 |
if (!$label) { |
200 |
user_error("AbstractExplorer::set_data_locator - label was empty."); |
201 |
return; |
202 |
} |
203 |
|
204 |
if ($label == "rpc") { |
205 |
$rpcinfo = $app->getConfig("rpcinfo"); |
206 |
define('RPC_HOSTNAME', $rpcinfo[Host]); |
207 |
define('RPC_PORT', $rpcinfo[Port]); |
208 |
define('RPC_DEBUG', $rpcinfo[DEBUG]); |
209 |
define('RPC_TRACE', $rpcinfo[TRACE]); |
210 |
define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]); |
211 |
} else { |
212 |
user_error("AbstractExplorer::set_data_locator - Could not dispatch data_locator_key label '$label'!"); |
213 |
} |
214 |
} |
215 |
|
216 |
function get_data_locator($label) { |
217 |
} |
218 |
|
219 |
function get_page_state() { |
220 |
$requestTracker = mkObject("Application::Request::Tracker"); |
221 |
$this->_state = $requestTracker->getPointer(); |
222 |
//print "state: " . Dumper($this->_state) . "<br>"; |
223 |
} |
224 |
|
225 |
function clear_comp_state($comp = NULL) { |
226 |
if($comp) { |
227 |
$this->_e_state[ecoms][$comp] = array(); |
228 |
} |
229 |
} |
230 |
|
231 |
function set_e_state($state = null) { |
232 |
// NEW [2003-04-18]: now has two modes |
233 |
// 1. inject page state from argument passed to us |
234 |
// 2. (was) get page state from request tracker |
235 |
if ($state) { |
236 |
$this->_e_state = $state; |
237 |
|
238 |
} else { |
239 |
$this->get_page_state(); |
240 |
$this->_e_state = $this->_state[options][options]; |
241 |
|
242 |
} |
243 |
// print "Setting Explorer state:" . Dumper($this->_e_state); |
244 |
} |
245 |
|
246 |
function set_page_state() { |
247 |
user_error("AbstractExplorer::set_page_state - please implement me...."); |
248 |
} |
249 |
|
250 |
function init_default_gui_modules() { |
251 |
|
252 |
// format of parameters: label, ecom_type, abstract_type, module_name |
253 |
|
254 |
// 2003-03-02 - First ecom modules/components |
255 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
256 |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
257 |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
258 |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
259 |
|
260 |
// 2003-04-05 - Chooser (a Nav.List) |
261 |
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
262 |
|
263 |
// 2003-04-07 - RemoteAction |
264 |
$this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction"); |
265 |
|
266 |
// 2003-04-09 - Data.Item: DeleteAction |
267 |
$this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem"); |
268 |
//$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction"); |
269 |
//$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem"); |
270 |
|
271 |
// 2003-04-12 - Data.Tree |
272 |
$this->register_gui_module("content", "data", "tree", "WebExplorer::Module::DataTree" ); |
273 |
|
274 |
// 2003-04-18 - Nav.Tree |
275 |
$this->register_gui_module("nav", "nav", "tree", "WebExplorer::Module::NavigationTree" ); |
276 |
|
277 |
// 2003-04-18 - UserManagment Nav.Tree (we need only a different 'label' as Nav.Tree yet..) |
278 |
$this->register_gui_module("UMnav", "nav", "tree", "WebExplorer::Module::NavigationTree" ); |
279 |
|
280 |
} |
281 |
|
282 |
function register_source_module($label, $args) { |
283 |
$this->_module['source'][$label] = $args; |
284 |
} |
285 |
|
286 |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
287 |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
288 |
} |
289 |
|
290 |
|
291 |
function &get_ecom($label, $args = array()) { |
292 |
|
293 |
// the very first - strongly hardcoded - Hello World ecom |
294 |
//return "Hello World"; |
295 |
|
296 |
// that's better ... |
297 |
$this->_load_ecom($label, $args); |
298 |
|
299 |
//print "getEcom_args: " .Dumper($args). "<br>"; |
300 |
|
301 |
return $this->_ecom[$label]; |
302 |
|
303 |
} |
304 |
|
305 |
|
306 |
function _load_ecoms() { |
307 |
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
308 |
foreach($this->_e_state[ecoms] as $label => $val) { |
309 |
$this->_load_ecom($label); |
310 |
} |
311 |
} |
312 |
|
313 |
|
314 |
|
315 |
function _load_ecom($label, $args = array()) { |
316 |
|
317 |
// fetch values from state |
318 |
$val = $this->_e_state['ecoms'][$label]; |
319 |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
320 |
|
321 |
// NEW [2003-04-10]: ecom-RESET-condition |
322 |
if (!is_array($val) && $val == 'RESET') { |
323 |
debug::info("Resetting component: $label"); |
324 |
return; |
325 |
} |
326 |
|
327 |
// find right ecom gui module |
328 |
$ecom_type = $val['ecom_type']; |
329 |
$abstract_type = $val['ecom_abstract_type']; |
330 |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
331 |
//print Dumper($gui_module); |
332 |
if(!$gui_module) { |
333 |
user_error("_load_ecom: No GUI module found for [label='$label', ecom type='$val[ecom_type]', abstract type='$val[ecom_abstract_type]']."); |
334 |
return; |
335 |
} |
336 |
|
337 |
// get arguments needed for ecom gui module |
338 |
$args = $this->_prepare_component_args($label, $args); |
339 |
|
340 |
// trace |
341 |
//print "raw-args: " . Dumper($args) . "<br/>"; |
342 |
|
343 |
// get ecom GUI module |
344 |
if (!$ecom = php::mkComponent($gui_module, $args)) { |
345 |
user_error("AbstractExplorer::_load_component - Error while instantiating ecom gui component. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']"); |
346 |
return; |
347 |
} |
348 |
//print Dumper($ecom); |
349 |
|
350 |
// NEW[2003-04-18] done via args(prepare args!) passed at constructor |
351 |
// (needed for non-real objects instanced at some child of AbstractGUIModule, eg. NavigationList) |
352 |
/* |
353 |
// add hidden vars, needed for explorer control |
354 |
$hidden_items = $this->_get_hidden_items($label); |
355 |
if(is_array($hidden_items) ) { |
356 |
$ecom->add_hidden_items($hidden_items); |
357 |
print "Hidden: " . Dumper($hidden_items); |
358 |
} |
359 |
*/ |
360 |
|
361 |
// load phphtmllib GUI object |
362 |
$gui_ecom = &$ecom->get(); |
363 |
|
364 |
// attempt: |
365 |
//$gui_ecom->make_transparent(); |
366 |
|
367 |
// store phphtmllib GUI object |
368 |
$this->_ecom[$label] = &$gui_ecom; |
369 |
} |
370 |
|
371 |
|
372 |
|
373 |
function _get_hidden_items($label) { |
374 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
375 |
if($ecom_state['ecom_type'] == "data") { |
376 |
if($ecom_state['ecom_abstract_type'] == "list") { |
377 |
$hidden_items = array( |
378 |
'ecl' => $label, |
379 |
'ecat' => "list", |
380 |
'ecmod' => "view", |
381 |
'ecdid' => $ecom_state['ecom_data_ident'], |
382 |
); |
383 |
} |
384 |
elseif($ecom_state['ecom_abstract_type'] == "item") { |
385 |
$hidden_items = array( |
386 |
'ecl' => $label, |
387 |
'ecat' => "item", |
388 |
'ecmod' => "view", |
389 |
); |
390 |
} |
391 |
} |
392 |
elseif($ecom_state['ecom_type'] == "nav") { |
393 |
// Switching abstract make no real sense here, |
394 |
// because hidden_items(link_vars) for Naviagtion-Ecoms |
395 |
// are more label specified!! |
396 |
// OLD: |
397 |
//if($ecom_state['ecom_abstract_type'] == "list") { |
398 |
|
399 |
// decide whether to link to items or to a list |
400 |
$abstract_type = 'list'; |
401 |
// FIXME: HACK |
402 |
if ($this->_e_state[main][ecom_data_source_key] == 'config') { |
403 |
$abstract_type = 'item'; |
404 |
} |
405 |
|
406 |
// NEW: |
407 |
if ($label == "nav") { |
408 |
$hidden_items = array( |
409 |
'ecl' => "content", |
410 |
'ecat' => $abstract_type, |
411 |
'ecmod' => "view", |
412 |
'ect' => "data", |
413 |
'ecdlk' => "rpc", |
414 |
); |
415 |
|
416 |
} |
417 |
elseif ($label == "chooser") { |
418 |
$hidden_items = array( |
419 |
'ecl' => "phase_startup", |
420 |
'ecdlk' => "rpc", |
421 |
); |
422 |
|
423 |
} |
424 |
} |
425 |
// add page idents |
426 |
|
427 |
//print "-e-state-idents: " .Dumper($this->_e_state[idents]). "<br>"; |
428 |
|
429 |
foreach($this->_e_state[idents] as $label => $value) { |
430 |
$hidden_items[$label] = $value; |
431 |
} |
432 |
return $hidden_items; |
433 |
} |
434 |
|
435 |
|
436 |
|
437 |
function _prepare_component_args($label, $args = array()) { |
438 |
$val = $this->_e_state['ecoms'][$label]; |
439 |
//print "val: " .Dumper($val). "<br>"; |
440 |
// pre-flight checks |
441 |
if (!$val['ecom_data_locator_key']) { |
442 |
user_error("_prepare_component_args: Key 'ecom_data_locator_key' was empty, should be one of 'rpc'."); |
443 |
return; |
444 |
} |
445 |
|
446 |
if (!$val['ecom_type']) { |
447 |
user_error("WebExplorer::AbstractExplorer: Key 'ecom_type' was empty, should be one of 'data|nav|call'."); |
448 |
} |
449 |
|
450 |
if (!$val['ecom_abstract_type']) { |
451 |
user_error("_prepare_component_args: Key 'ecom_abstract_type' was empty, should be one of 'item|list|tree|auto'."); |
452 |
return; |
453 |
} |
454 |
|
455 |
// trace |
456 |
//print "YAI1<br/>"; |
457 |
|
458 |
|
459 |
$this->set_data_locator($val['ecom_data_locator_key']); |
460 |
|
461 |
// detect and execute 'selectSource' action |
462 |
// FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th. |
463 |
//print Dumper($this->_e_state['sources']); |
464 |
if ($source = $this->_e_state['main']['ecom_data_source_key']) { |
465 |
//print "selectSource: $source<br/>"; |
466 |
//global $app; |
467 |
//print Dumper($backend); |
468 |
//$app->backend->do(); |
469 |
} |
470 |
|
471 |
// switch component type |
472 |
if($val['ecom_type'] == "data") { |
473 |
// switch abstract type |
474 |
if($val['ecom_abstract_type'] == "list") { |
475 |
// debugging |
476 |
//print "Mode: $val[ecom_mode], type: list<br>"; |
477 |
//print "val: " .Dumper($val). "<br>"; |
478 |
|
479 |
if($val['ecom_data_locator_key'] == "rpc") { |
480 |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
481 |
|
482 |
$data_locator_meta = array( |
483 |
transport => 'rpc', |
484 |
metatype => 'data', |
485 |
abstract_type => 'list', |
486 |
nodename => $val['ecom_data_ident'], |
487 |
list_meta => $val['ecom_data_meta'] |
488 |
); |
489 |
} else { |
490 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
491 |
} |
492 |
|
493 |
if($val['ecom_mode'] == 'select') { |
494 |
$actionbar = array( |
495 |
'buttons' => array( |
496 |
array( |
497 |
'name' => "ecdfsel", |
498 |
'value' => "Select" |
499 |
), |
500 |
), |
501 |
); |
502 |
} else { |
503 |
if(is_array($_SESSION[user]) && $_SESSION[user][loggedIn]) { |
504 |
$actionbar = array( |
505 |
'name' => "ecdfa", |
506 |
'list' => array( |
507 |
"View" => 'view', |
508 |
"Edit" => 'edit', |
509 |
), |
510 |
'selected' => 'view', |
511 |
'buttons' => array( |
512 |
), |
513 |
); |
514 |
} else { |
515 |
$actionbar = array( |
516 |
'name' => "ecdfa", |
517 |
'list' => array( |
518 |
"View" => 'view', |
519 |
"Edit" => 'edit', |
520 |
"Delete" => 'delete', |
521 |
"Expand" => 'expand', |
522 |
"Expandedit" => 'expandedit', |
523 |
), |
524 |
'selected' => 'view', |
525 |
'buttons' => array( |
526 |
array( |
527 |
'name' => "ecdfcr", |
528 |
'value' => "Add new" |
529 |
), |
530 |
), |
531 |
); |
532 |
} |
533 |
} |
534 |
|
535 |
$args = array( |
536 |
'caption' => $val['ecom_data_ident'], |
537 |
'orderby' => "Guid", |
538 |
'options' => array( |
539 |
'data_locator_meta' => $data_locator_meta, |
540 |
'decode' => 1, |
541 |
'decode_args' => array( |
542 |
'seperator' => "_", |
543 |
//'form' => 1, |
544 |
), |
545 |
'actionbar' => $actionbar, |
546 |
'parent' => array( |
547 |
'class' => $val['ecom_data_ident'], |
548 |
), |
549 |
), |
550 |
); |
551 |
if($val['ecom_data_meta_x']) { |
552 |
//unset($args['options']['data_locator_meta']['nodename']); |
553 |
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta']; |
554 |
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
555 |
} |
556 |
if(is_array($_SESSION[user]) && $_SESSION[user][loggedIn]) { |
557 |
$args['options']['data_locator_meta']['owner'][guid] = $_SESSION[user][guid]; |
558 |
$args['options']['data_locator_meta']['owner']['class'] = $_SESSION[user]['class']; |
559 |
} |
560 |
|
561 |
// switch abstract type |
562 |
} elseif ($val['ecom_abstract_type'] == "item") { |
563 |
if($val['ecom_data_locator_key'] == "rpc") { |
564 |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
565 |
|
566 |
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
567 |
$filter = $this->get_data_filter($val); |
568 |
|
569 |
$data_locator_meta = array( |
570 |
transport => 'rpc', metatype => 'data', abstract_type => 'item', |
571 |
ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], filter => $filter, |
572 |
); |
573 |
} else { |
574 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
575 |
} |
576 |
|
577 |
// defaults |
578 |
if (!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
579 |
//$val['ecom_mode'] = "view"; |
580 |
|
581 |
// debugging |
582 |
print "Mode: $val[ecom_mode]<br>"; |
583 |
|
584 |
//print Dumper($val); |
585 |
// NEW [2003-04-22]: append some more meta information to the caption |
586 |
//$caption_addendum = ' {' . $val['ecom_data_meta'] . '}'; |
587 |
$caption_addendum = ' {' . $val['ecom_data_meta'] . ':' . $val['ecom_data_filter'] . '}'; |
588 |
|
589 |
// prepare some arguments... |
590 |
$args = array( |
591 |
'caption' => $val['ecom_data_ident'] . $caption_addendum, |
592 |
'mode' => $val['ecom_mode'], |
593 |
'options' => array( |
594 |
'data_locator_meta' => $data_locator_meta, |
595 |
'decode' => 1, |
596 |
'decode_args' => array( |
597 |
'seperator' => "_", |
598 |
), |
599 |
'parent' => array( |
600 |
'guid' => $val['ecom_data_ident'], |
601 |
'class' => $val['ecom_data_meta'], |
602 |
), |
603 |
), |
604 |
); |
605 |
if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
606 |
|
607 |
// FIXME: (see WebExplorer::Module::AbstractGUIModule) |
608 |
//if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; } |
609 |
if ($val['ecom_mode'] == "delete") { |
610 |
$args['adapter'] = 'NonValidatingFormProcessor'; |
611 |
$args['options']['data_locator_meta']['action'] = 'delete'; |
612 |
} |
613 |
|
614 |
if ($val['ecom_mode'] == "create") { |
615 |
$args['adapter'] = 'FormProcessor'; |
616 |
$args['options']['caption'] = $val['ecom_data_ident']; |
617 |
$args['options']['data_locator_meta']['action'] = 'create'; |
618 |
//print "debug 'create': " . Dumper($val); |
619 |
if($val['ecom_data_meta_x']) { |
620 |
unset($args['options']['data_locator_meta']['nodename']); |
621 |
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta']; |
622 |
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
623 |
} |
624 |
} |
625 |
if ($val['ecom_mode'] == "select") { |
626 |
$args['adapter'] = 'FormProcessor'; |
627 |
$args['caption'] = $val['ecom_data_meta_xe'] . " {". $val['ecom_data_meta_x'] . ":}"; |
628 |
$args['options']['data_locator_meta']['action'] = 'select'; |
629 |
//print "debug 'select': " . Dumper($val); |
630 |
if($val['ecom_data_meta_x']) { |
631 |
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta_xe']; |
632 |
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
633 |
} |
634 |
} |
635 |
|
636 |
//print "debug 'args' : " . Dumper($args); |
637 |
|
638 |
// switch abstract type |
639 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
640 |
|
641 |
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
642 |
$filter = $this->get_data_filter($val); |
643 |
|
644 |
// FIXME: shouldn't this (dispatching by transport-key) be done very *outside* of this scope? |
645 |
// or: do it outside per default, let a possibility to modify it inside the lower levels of the dispatcher (here) |
646 |
if ($val['ecom_data_locator_key'] == "rpc") { |
647 |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
648 |
$args[options][data_locator_meta] = array( |
649 |
transport => 'rpc', metatype => 'data', abstract_type => 'tree', |
650 |
ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], |
651 |
// NEW [2003-04-22]: Full tree node filtering established. |
652 |
filter => $filter |
653 |
); |
654 |
} |
655 |
|
656 |
// NEW [2003-09-26]: transparent content - argument pass-through mode |
657 |
} elseif ($val['ecom_abstract_type'] == "transparent") { |
658 |
|
659 |
// You are responsible for all arguments passed through. |
660 |
// Where are these arguments from? |
661 |
// They are propagated transparently to this place from a new optional |
662 |
// parameter ($args) introduced for the methods 'get_com', 'load_com' |
663 |
// and '_prepare_component_args' (this one). |
664 |
// This means full control over ecoms from outside. |
665 |
|
666 |
// TODO: maybe add some additional pre-flight checks here!? |
667 |
|
668 |
// croak |
669 |
} else { |
670 |
user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'."); |
671 |
|
672 |
} |
673 |
|
674 |
// switch component type |
675 |
} elseif ($val['ecom_type'] == "nav") { |
676 |
|
677 |
// switch abstract type |
678 |
// list |
679 |
if ($val['ecom_abstract_type'] == "list") { |
680 |
$args = array(); |
681 |
if($val['ecom_data_locator_key'] == "rpc") { |
682 |
|
683 |
// switch component label |
684 |
// TODO: should we really dispatch by label inside here? |
685 |
|
686 |
if ($label == "nav") { |
687 |
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
688 |
$args['caption'] = "Objekt Typen"; |
689 |
} |
690 |
// NEW [2003-04-05]: DataSource.Chooser |
691 |
elseif ($label == "chooser") { |
692 |
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
693 |
$args['caption'] = "Datenquellen"; |
694 |
} |
695 |
// NEW [2003-04-18]: croak if label empty |
696 |
else { |
697 |
user_error("_prepare_component_args: Dispatching for nav.list.rpc failed. \$label was empty."); |
698 |
} |
699 |
$args['options']['data_locator_meta'] = $data_locator_meta; |
700 |
|
701 |
} else { |
702 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !"); |
703 |
} |
704 |
|
705 |
// NEW [2003-04-18]: Abstract navigation tree |
706 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
707 |
$args = array(); |
708 |
if($label == "nav") { |
709 |
//$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'schema', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']); |
710 |
$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
711 |
$args['caption'] = $val['ecom_data_source_key']; |
712 |
} elseif($label == "UMnav") { |
713 |
//$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'schema', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']); |
714 |
$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'method', method => 'UserManagmentSchema' ); |
715 |
$args['caption'] = "Benutzerverwaltung"; |
716 |
} |
717 |
|
718 |
// NEW [2003-04-18]: transparent nav - argument pass-through mode |
719 |
} elseif ($val['ecom_abstract_type'] == "transparent") { |
720 |
// You are responsible for all arguments passed through. |
721 |
// Where are these arguments from? |
722 |
// They are propagated transparently to this place from a new optional |
723 |
// parameter ($args) introduced for the methods 'get_com', 'load_com' |
724 |
// and '_prepare_component_args' (this one). |
725 |
// This means full control over ecoms from outside. |
726 |
|
727 |
// TODO: maybe add some additional pre-flight checks here!? |
728 |
// croak |
729 |
} else { |
730 |
user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'."); |
731 |
} |
732 |
|
733 |
// NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser) |
734 |
// switch component type |
735 |
} elseif ($val['ecom_type'] == "call") { |
736 |
|
737 |
// responses of RemoteActions are not predictable! |
738 |
if ($val['ecom_abstract_type'] == "auto") { |
739 |
|
740 |
// Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere! |
741 |
|
742 |
// Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently. |
743 |
// Really - just a remote call is issued, no data-/schema-structures or similar are expected. |
744 |
|
745 |
// The RemoteMethod 'method' is called directly with arguments in 'args'! |
746 |
// As response (important for widget assignement!) you may expect an arbitrary payload. |
747 |
$args['options']['data_locator_meta'] = array( |
748 |
transport => 'rpc', |
749 |
metatype => 'method', |
750 |
method => $val['ecom_call_method'], |
751 |
args => $val['ecom_call_args'] |
752 |
); |
753 |
|
754 |
} else { |
755 |
// FIXME: implement automatic re-dispatching to available ecoms here! |
756 |
user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?"); |
757 |
} |
758 |
|
759 |
} |
760 |
|
761 |
if(is_array($_SESSION[user]) && $_SESSION[user][loggedIn]) { |
762 |
$args['options']['userclass'] = $_SESSION[user]['class']; |
763 |
} |
764 |
|
765 |
// NEW[2003-04-18]: add hidden items to args |
766 |
$args['hidden_elements'] = $this->_get_hidden_items($label); |
767 |
//print "args_hidden: " .Dumper($args['hidden_elements']). "<br>"; |
768 |
return $args; |
769 |
} |
770 |
|
771 |
|
772 |
|
773 |
function get_msg($label) { |
774 |
if($label == "welcome") { |
775 |
$msg = "Welcome to the Explorer."; |
776 |
} |
777 |
return $msg; |
778 |
} |
779 |
|
780 |
|
781 |
|
782 |
function render() { |
783 |
user_error("AbstractExplorer::render - please implement me...."); |
784 |
} |
785 |
|
786 |
|
787 |
function get_data_filter($state = array()) { |
788 |
|
789 |
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
790 |
// V1: this was inside ecom_abstract_type == item && ecom_data_locator_key == rpc, but ... |
791 |
// V2: ... it should be considered / work independent of these both criterias |
792 |
// since it is required for showing xml nodes in items (editing) *and* trees again (browsing). |
793 |
|
794 |
if ($filter_expression = $state[ecom_data_filter]) { |
795 |
|
796 |
// new of 2003-05-13: Apply "Node navigation" in tree mode only. |
797 |
// Lock context when switching to item mode. |
798 |
//print Dumper($state); |
799 |
if ($state[ecom_abstract_type] == "tree") { |
800 |
if ($parent_xpq = $state[ecom_data_meta]) { |
801 |
$filter_expression = $parent_xpq . $filter_expression; |
802 |
} |
803 |
} |
804 |
|
805 |
// This propagates a XPath filter expression which fully identifies |
806 |
// a single node in a document. It reaches through all parent nodes. |
807 |
$filter = array( |
808 |
//dotted => $val['ecom_data_filter'], |
809 |
//ident => $val['ecom_data_ident'], |
810 |
//xpq => '*/*[@name="cli"]', |
811 |
//xpq => '*/*', |
812 |
// NEW [2003-04-21]: An xpq is already ready now inside |
813 |
// 'ecdf' since it already has been built by the revamped tree lift. |
814 |
xpq => '*' . $filter_expression |
815 |
); |
816 |
|
817 |
} else { |
818 |
$filter = ''; |
819 |
|
820 |
} |
821 |
|
822 |
// lift filter from dotted format to xpq format |
823 |
// NEW [2003-04-21]: not required any more (see above) |
824 |
//$lift = mkObject('Data::Lift', $filter, array( metatype => 'filter' ) ); |
825 |
//$filter = $lift->to('XPath'); |
826 |
|
827 |
return $filter; |
828 |
|
829 |
} |
830 |
|
831 |
} |
832 |
|
833 |
|
834 |
?> |