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