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