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