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