4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.17 2003/04/18 13:46:15 jonen |
8 |
|
## + add hidden elements(items) now to the constructor arguments of each ecom |
9 |
|
## |
10 |
|
## Revision 1.16 2003/04/10 06:00:58 joko |
11 |
|
## ALPHA: Item.Delete |
12 |
|
## |
13 |
|
## Revision 1.15 2003/04/09 02:08:20 joko |
14 |
|
## CHANGE: renamed key 'classname' through 'nodename' |
15 |
|
## |
16 |
|
## Revision 1.14 2003/04/09 00:31:27 jonen |
17 |
|
## + added arguments for data list ecom |
18 |
|
## |
19 |
|
## Revision 1.13 2003/04/09 00:03:11 jonen |
20 |
|
## disabled form rendering for inheritanced items at 'list' |
21 |
|
## |
22 |
|
## Revision 1.12 2003/04/08 17:52:12 joko |
23 |
|
## CHANGE: renamed property 'datasource' to 'transport' |
24 |
|
## NEW: Module 'RemoteAction' |
25 |
|
## |
26 |
|
## Revision 1.11 2003/04/07 22:31:51 jonen |
27 |
|
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
28 |
|
## - removed recent added ecom type chooser |
29 |
|
## |
30 |
|
## Revision 1.10 2003/04/05 20:32:04 joko |
31 |
|
## added Chooser |
32 |
|
## |
33 |
|
## Revision 1.9 2003/04/04 02:22:37 joko |
34 |
|
## minor fix: querySchema now issues argument |
35 |
|
## |
36 |
|
## Revision 1.8 2003/04/04 01:16:03 jonen |
37 |
|
## + integrated different mode's for 'DataItem' |
38 |
|
## |
39 |
|
## Revision 1.7 2003/03/29 07:49:55 joko |
40 |
|
## show boxes in DEBUG-mode only! |
41 |
|
## |
42 |
|
## Revision 1.6 2003/03/28 06:42:37 joko |
43 |
|
## fix: propagating rpc-debugging-options to constants here |
44 |
|
## |
45 |
|
## Revision 1.5 2003/03/27 01:24:29 jonen |
46 |
|
## + enabled navigation ecom (only list yet) |
47 |
|
## |
48 |
|
## Revision 1.4 2003/03/20 08:02:11 jonen |
49 |
|
## + purged code |
50 |
|
## |
51 |
|
## Revision 1.3 2003/03/20 07:54:52 jonen |
52 |
|
## + added docu |
53 |
|
## |
54 |
|
## Revision 1.2 2003/03/20 07:44:31 jonen |
55 |
|
## + removed dumper |
56 |
|
## |
57 |
## Revision 1.1 2003/03/20 03:48:46 jonen |
## Revision 1.1 2003/03/20 03:48:46 jonen |
58 |
## + initial commit |
## + initial commit |
59 |
## |
## |
76 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
77 |
*/ |
*/ |
78 |
|
|
79 |
|
/** |
80 |
|
* WebExplorer::AbstractExplorer - this can be simple compared to a container, |
81 |
|
* which modular GUI classes can be register, manipulated and rendered... |
82 |
|
* |
83 |
|
* @author Sebastian Utz <seut@tunemedia.de> |
84 |
|
* @package org.netfrag.app |
85 |
|
* @name WebExplorer::AbstractExplorer |
86 |
|
*/ |
87 |
|
|
88 |
|
|
89 |
class WebExplorer_AbstractExplorer { |
class WebExplorer_AbstractExplorer { |
90 |
|
|
113 |
*/ |
*/ |
114 |
var $_e_state = array(); |
var $_e_state = array(); |
115 |
|
|
|
// needed (old)? |
|
|
var $_control = array(); |
|
|
var $_hidden_elements = array(); |
|
|
|
|
116 |
|
|
117 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
118 |
$this->_data_locators = $data_locators; |
$this->_data_locators = $data_locators; |
119 |
$this->init_default_gui_modules(); |
$this->init_default_gui_modules(); |
|
|
|
120 |
$this->set_e_state(); |
$this->set_e_state(); |
121 |
print "State: " . Dumper($this->_state) ."<br>"; |
|
122 |
print "E_State: " . Dumper($this->_e_state) ."<br>"; |
//debug |
123 |
//$this->init_state(); |
//print "State: " . Dumper($this->_state) ."<br>"; |
124 |
|
$div = html_div(); |
125 |
|
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
126 |
|
$div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;'); |
127 |
|
if (constants::get('DEBUG')) { |
128 |
|
print $div->render(); |
129 |
|
} |
130 |
} |
} |
131 |
|
|
132 |
|
|
141 |
$rpcinfo = $app->getConfig("rpcinfo"); |
$rpcinfo = $app->getConfig("rpcinfo"); |
142 |
define('RPC_HOSTNAME', $rpcinfo[Host]); |
define('RPC_HOSTNAME', $rpcinfo[Host]); |
143 |
define('RPC_PORT', $rpcinfo[Port]); |
define('RPC_PORT', $rpcinfo[Port]); |
144 |
|
define('RPC_DEBUG', $rpcinfo[DEBUG]); |
145 |
|
define('RPC_TRACE', $rpcinfo[TRACE]); |
146 |
|
define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]); |
147 |
} else { |
} else { |
148 |
user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!"); |
user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!"); |
149 |
} |
} |
160 |
function set_e_state() { |
function set_e_state() { |
161 |
$this->get_page_state(); |
$this->get_page_state(); |
162 |
$this->_e_state = $this->_state[options][options]; |
$this->_e_state = $this->_state[options][options]; |
163 |
|
// print "Setting Explorer state:" . Dumper($this->_e_state); |
164 |
} |
} |
165 |
|
|
166 |
|
|
170 |
|
|
171 |
|
|
172 |
function init_default_gui_modules() { |
function init_default_gui_modules() { |
173 |
|
|
174 |
|
// format of parameters: label, ecom_type, abstract_type, module_name |
175 |
|
|
176 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
177 |
$this->register_gui_module("list", "nav", array( 'name' => "NavigationList", 'type' => "list") ); |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
178 |
$this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") ); |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
179 |
$this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") ); |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
180 |
|
// 2003-04-05 - Chooser |
181 |
|
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
182 |
|
// 2003-04-07 - RemoteAction |
183 |
|
$this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction"); |
184 |
|
// 2003-04-09 - Item.Delete |
185 |
|
$this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem"); |
186 |
|
//$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction"); |
187 |
|
//$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem"); |
188 |
} |
} |
189 |
|
|
190 |
function register_source_module($label, $args) { |
function register_source_module($label, $args) { |
191 |
$this->_module['source'][$label] = $args; |
$this->_module['source'][$label] = $args; |
192 |
} |
} |
193 |
|
|
194 |
function register_gui_module($abstract_type, $ecom_type, $args) { |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
195 |
$this->_module['gui'][$ecom_type][$abstract_type] = $args; |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
196 |
} |
} |
197 |
|
|
198 |
|
|
199 |
function &get_ecom($label) { |
function &get_ecom($label) { |
200 |
//return "Hello World"; |
//return "Hello World"; |
201 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
202 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
203 |
} |
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
function _load_ecoms() { |
function _load_ecoms() { |
208 |
|
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
209 |
foreach($this->_e_state[ecoms] as $label => $val) { |
foreach($this->_e_state[ecoms] as $label => $val) { |
210 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
211 |
} |
} |
212 |
} |
} |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
function _load_ecom($label) { |
function _load_ecom($label) { |
217 |
|
|
218 |
|
// fetch values from state |
219 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
220 |
// find right gui module |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
221 |
$com_type = $val['ecom_type']; |
|
222 |
|
// NEW [2003-04-10]: ecom-RESET-condition |
223 |
|
if (!is_array($val) && $val == 'RESET') { |
224 |
|
debug::info("Resetting component: $label"); |
225 |
|
return; |
226 |
|
} |
227 |
|
|
228 |
|
// find right ecom gui module |
229 |
|
$ecom_type = $val['ecom_type']; |
230 |
$abstract_type = $val['ecom_abstract_type']; |
$abstract_type = $val['ecom_abstract_type']; |
231 |
$gui_module = $this->_module['gui'][$com_type][$abstract_type]['name']; |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
232 |
|
//print Dumper($gui_module); |
233 |
if(!$gui_module) { |
if(!$gui_module) { |
234 |
user_error("AbstractExplorer::_load_component - No GUI module found for abstract type $val[ecom_abstract_type] ecom type $val[ecom_type] !"); |
user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']"); |
235 |
return; |
return; |
236 |
} |
} |
237 |
// get arguments needed for gui module |
|
238 |
|
// get arguments needed for ecom gui module |
239 |
$args = $this->_prepare_component_args($label); |
$args = $this->_prepare_component_args($label); |
240 |
//print Dumper($args); |
//print Dumper($args); |
241 |
|
|
242 |
// get GUI module |
// get ecom GUI module |
243 |
$ecom = php::mkComponent($gui_module, $args); |
if (!$ecom = php::mkComponent($gui_module, $args)) { |
244 |
|
return; |
245 |
|
} |
246 |
//print Dumper($ecom); |
//print Dumper($ecom); |
247 |
|
|
248 |
// get phphtmllib GUI object |
// NOW[2003-18-04] done at via args(prepare args!) to pass at constructor |
249 |
$gui_ecom = &$ecom->get(); |
// (needed for non-real objects instanced at some child of AbstractGUIModule, eg. NavigationList) |
250 |
|
/* |
251 |
// add hidden vars, needed for explorer control |
// add hidden vars, needed for explorer control |
252 |
$hidden_items = $this->_get_hidden_items($label); |
$hidden_items = $this->_get_hidden_items($label); |
253 |
$ecom->add_hidden_items($hidden_items); |
if(is_array($hidden_items) ) { |
254 |
//print "Hidden: " . Dumper($gui_ecom->_hidden_items); |
$ecom->add_hidden_items($hidden_items); |
255 |
|
print "Hidden: " . Dumper($hidden_items); |
256 |
|
} |
257 |
|
*/ |
258 |
|
|
259 |
|
// load phphtmllib GUI object |
260 |
|
$gui_ecom = &$ecom->get(); |
261 |
|
|
262 |
|
// attempt: |
263 |
|
//$gui_ecom->make_transparent(); |
264 |
|
|
265 |
|
// store phphtmllib GUI object |
266 |
$this->_ecom[$label] = &$gui_ecom; |
$this->_ecom[$label] = &$gui_ecom; |
267 |
} |
} |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
function _get_hidden_items($label) { |
function _get_hidden_items($label) { |
272 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
$ecom_state = $this->_e_state['ecoms'][$label]; |
273 |
if($ecom_state['ecom_abstract_type'] == "list") { |
if($ecom_state['ecom_type'] == "data") { |
274 |
$hidden_items = array( |
if($ecom_state['ecom_abstract_type'] == "list") { |
275 |
|
$hidden_items = array( |
276 |
'ecl' => $label, |
'ecl' => $label, |
277 |
|
'ecat' => "item", |
278 |
|
'ecmod' => "view", |
279 |
); |
); |
280 |
|
} |
281 |
|
elseif($ecom_state['ecom_abstract_type'] == "item") { |
282 |
|
$hidden_items = array( |
283 |
|
'ecl' => $label, |
284 |
|
'ecat' => "item", |
285 |
|
'ecmod' => "view", |
286 |
|
); |
287 |
|
} |
288 |
|
} |
289 |
|
elseif($ecom_state['ecom_type'] == "nav") { |
290 |
|
// Switching abstract make no real sense here, |
291 |
|
// because hidden_items(link_vars) for Naviagtion-Ecoms |
292 |
|
// are more label specified!! |
293 |
|
// OLD: |
294 |
|
//if($ecom_state['ecom_abstract_type'] == "list") { |
295 |
|
// NEW: |
296 |
|
if($label == "nav") { |
297 |
|
$hidden_items = array( |
298 |
|
'ecl' => "content", |
299 |
|
'ecat' => "list", |
300 |
|
'ecmod' => "view", |
301 |
|
'ect' => "data", |
302 |
|
'ecdlk' => "rpc", |
303 |
|
); |
304 |
|
|
305 |
|
} |
306 |
|
elseif($label == "chooser") { |
307 |
|
$hidden_items = array( |
308 |
|
'ecl' => "phase_startup", |
309 |
|
'ecdlk' => "rpc", |
310 |
|
); |
311 |
|
|
312 |
|
} |
313 |
} |
} |
314 |
// set default hidden item for whole explorer |
// add page idents |
315 |
$hidden_items['ap'] = "explorer"; |
foreach($this->_e_state[idents] as $label => $value) { |
316 |
|
$hidden_items[$label] = $value; |
317 |
|
} |
318 |
return $hidden_items; |
return $hidden_items; |
319 |
} |
} |
320 |
|
|
321 |
|
|
322 |
|
|
323 |
function _prepare_component_args($label) { |
function _prepare_component_args($label) { |
324 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
325 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
326 |
if($val['ecom_abstract_type'] == "list") { |
|
327 |
if($val['ecom_data_locator_key'] == "rpc") { |
// detect and execute 'selectSource' action |
328 |
$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. |
329 |
} else { |
//print Dumper($this->_e_state['sources']); |
330 |
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']) { |
331 |
} |
//print "selectSource: $source<br/>"; |
332 |
$args = array( |
//global $app; |
333 |
'caption' => "Liste", |
//print Dumper($backend); |
334 |
|
//$app->backend->do(); |
335 |
|
} |
336 |
|
|
337 |
|
// switch component type |
338 |
|
if($val['ecom_type'] == "data") { |
339 |
|
// switch abstract type |
340 |
|
if($val['ecom_abstract_type'] == "list") { |
341 |
|
if($val['ecom_data_locator_key'] == "rpc") { |
342 |
|
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
343 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', nodename => $val['ecom_data_ident']); |
344 |
|
} else { |
345 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
346 |
|
} |
347 |
|
$args = array( |
348 |
|
'caption' => $val['ecom_data_ident'], |
349 |
'orderby' => "Guid", |
'orderby' => "Guid", |
350 |
'options' => array( |
'options' => array( |
351 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
352 |
'decode' => 1, |
'decode' => 1, |
353 |
'decode_args' => array( |
'decode_args' => array( |
354 |
'seperator' => "_", |
'seperator' => "_", |
355 |
'form' => 1, |
//'form' => 1, |
356 |
|
), |
357 |
|
'actionbar' => array( |
358 |
|
'name' => "ecdfa", |
359 |
|
'list' => array( |
360 |
|
"View" => 'view', |
361 |
|
"Edit" => 'edit', |
362 |
|
"Delete" => 'delete', |
363 |
|
"Add new" => 'add', |
364 |
|
), |
365 |
|
), |
366 |
|
), |
367 |
|
); |
368 |
|
// switch abstract type |
369 |
|
} elseif ($val['ecom_abstract_type'] == "item") { |
370 |
|
if($val['ecom_data_locator_key'] == "rpc") { |
371 |
|
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
372 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']); |
373 |
|
} else { |
374 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
375 |
|
} |
376 |
|
|
377 |
|
// defaults |
378 |
|
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
379 |
|
//$val['ecom_mode'] = "view"; |
380 |
|
|
381 |
|
// debugging |
382 |
|
print "Mode: $val[ecom_mode]<br>"; |
383 |
|
|
384 |
|
// prepare some arguments... |
385 |
|
$args = array( |
386 |
|
'caption' => $val['ecom_data_meta'], |
387 |
|
'mode' => $val['ecom_mode'], |
388 |
|
'options' => array( |
389 |
|
'data_locator_meta' => $data_locator_meta, |
390 |
|
'decode' => 1, |
391 |
|
'decode_args' => array( |
392 |
|
'seperator' => "_", |
393 |
), |
), |
394 |
), |
), |
395 |
); |
); |
396 |
} elseif ($ecom_type == "item") { |
if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
397 |
$args = array(); |
|
398 |
} elseif ($ecom_type == "nav") { |
// FIXME: (see WebExplorer::Module::AbstractGUIModule) |
399 |
$args = array(); |
//if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; } |
400 |
|
if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; } |
401 |
|
|
402 |
|
} |
403 |
|
|
404 |
|
// switch component type |
405 |
|
} elseif ($val['ecom_type'] == "nav") { |
406 |
|
// switch abstract type |
407 |
|
if($val['ecom_abstract_type'] == "list") { |
408 |
|
$args = array(); |
409 |
|
if($val['ecom_data_locator_key'] == "rpc") { |
410 |
|
// switch component label |
411 |
|
if($label == "nav") { |
412 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
413 |
|
$args['caption'] = "Objekt Typen"; |
414 |
|
} |
415 |
|
// NEW [2003-04-05]: DataSource.Chooser |
416 |
|
elseif ($label == "chooser") { |
417 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
418 |
|
$args['caption'] = "Datenquellen"; |
419 |
|
} |
420 |
|
$args['options']['data_locator_meta'] = $data_locator_meta; |
421 |
|
} else { |
422 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !"); |
423 |
|
} |
424 |
|
} elseif ($val['ecom_abstract_type'] == "tree") { |
425 |
|
$args = array(); |
426 |
|
} |
427 |
|
|
428 |
|
// NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser) |
429 |
|
// switch component type |
430 |
|
} elseif ($val['ecom_type'] == "call") { |
431 |
|
|
432 |
|
// responses of RemoteActions are not predictable! |
433 |
|
if ($val['ecom_abstract_type'] == "auto") { |
434 |
|
|
435 |
|
// Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere! |
436 |
|
|
437 |
|
// Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently. |
438 |
|
// Really - just a remote call is issued, no data-/schema-structures or similar are expected. |
439 |
|
|
440 |
|
// The RemoteMethod 'method' is called directly with arguments in 'args'! |
441 |
|
// As response (important for widget assignement!) you may expect an arbitrary payload. |
442 |
|
$args['options']['data_locator_meta'] = array( |
443 |
|
transport => 'rpc', |
444 |
|
metatype => 'method', |
445 |
|
method => $val['ecom_call_method'], |
446 |
|
args => $val['ecom_call_args'] |
447 |
|
); |
448 |
|
|
449 |
|
} else { |
450 |
|
// FIXME: implement automatic re-dispatching to available ecoms here! |
451 |
|
user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?"); |
452 |
|
} |
453 |
|
|
454 |
} |
} |
455 |
|
|
456 |
|
// add hidden items to args |
457 |
|
$args['hidden_elements'] = $this->_get_hidden_items($label); |
458 |
|
|
459 |
return $args; |
return $args; |
460 |
} |
} |
461 |
|
|
462 |
|
|
463 |
|
|
464 |
function get_msg($label) { |
function get_msg($label) { |
465 |
if($label == "welcome") { |
if($label == "welcome") { |
466 |
$msg = "Welcome to the Explorer."; |
$msg = "Welcome to the Explorer."; |
467 |
} |
} |
468 |
return $msg; |
return $msg; |
469 |
} |
} |
470 |
|
|
471 |
|
|
472 |
|
|
473 |
function render() { |
function render() { |
474 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |