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