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