4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.16 2003/04/10 06:00:58 joko |
8 |
|
## ALPHA: Item.Delete |
9 |
|
## |
10 |
|
## Revision 1.15 2003/04/09 02:08:20 joko |
11 |
|
## CHANGE: renamed key 'classname' through 'nodename' |
12 |
|
## |
13 |
|
## Revision 1.14 2003/04/09 00:31:27 jonen |
14 |
|
## + added arguments for data list ecom |
15 |
|
## |
16 |
|
## Revision 1.13 2003/04/09 00:03:11 jonen |
17 |
|
## disabled form rendering for inheritanced items at 'list' |
18 |
|
## |
19 |
|
## Revision 1.12 2003/04/08 17:52:12 joko |
20 |
|
## CHANGE: renamed property 'datasource' to 'transport' |
21 |
|
## NEW: Module 'RemoteAction' |
22 |
|
## |
23 |
|
## Revision 1.11 2003/04/07 22:31:51 jonen |
24 |
|
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
25 |
|
## - removed recent added ecom type chooser |
26 |
|
## |
27 |
|
## Revision 1.10 2003/04/05 20:32:04 joko |
28 |
|
## added Chooser |
29 |
|
## |
30 |
|
## Revision 1.9 2003/04/04 02:22:37 joko |
31 |
|
## minor fix: querySchema now issues argument |
32 |
|
## |
33 |
## Revision 1.8 2003/04/04 01:16:03 jonen |
## Revision 1.8 2003/04/04 01:16:03 jonen |
34 |
## + integrated different mode's for 'DataItem' |
## + integrated different mode's for 'DataItem' |
35 |
## |
## |
113 |
|
|
114 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
115 |
$this->_data_locators = $data_locators; |
$this->_data_locators = $data_locators; |
116 |
$this->init_default_gui_modules(); |
$this->init_default_gui_modules(); |
|
|
|
117 |
$this->set_e_state(); |
$this->set_e_state(); |
118 |
|
|
119 |
|
//debug |
120 |
//print "State: " . Dumper($this->_state) ."<br>"; |
//print "State: " . Dumper($this->_state) ."<br>"; |
121 |
$div = html_div(); |
$div = html_div(); |
122 |
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
124 |
if (constants::get('DEBUG')) { |
if (constants::get('DEBUG')) { |
125 |
print $div->render(); |
print $div->render(); |
126 |
} |
} |
|
//$this->init_state(); |
|
127 |
} |
} |
128 |
|
|
129 |
|
|
166 |
|
|
167 |
|
|
168 |
function init_default_gui_modules() { |
function init_default_gui_modules() { |
169 |
|
|
170 |
|
// format of parameters: label, ecom_type, abstract_type, module_name |
171 |
|
|
172 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
173 |
$this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") ); |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
174 |
$this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") ); |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
175 |
$this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") ); |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
176 |
|
// 2003-04-05 - Chooser |
177 |
|
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
178 |
|
// 2003-04-07 - RemoteAction |
179 |
|
$this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction"); |
180 |
|
// 2003-04-09 - Item.Delete |
181 |
|
$this->register_gui_module("phase_startup", "data", "item", "WebExplorer::Module::DataItem"); |
182 |
|
//$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::RemoteAction"); |
183 |
|
//$this->register_gui_module("phase_startup", "data", "auto", "WebExplorer::Module::DataItem"); |
184 |
} |
} |
185 |
|
|
186 |
function register_source_module($label, $args) { |
function register_source_module($label, $args) { |
187 |
$this->_module['source'][$label] = $args; |
$this->_module['source'][$label] = $args; |
188 |
} |
} |
189 |
|
|
190 |
function register_gui_module($abstract_type, $ecom_type, $args) { |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
191 |
$this->_module['gui'][$ecom_type][$abstract_type] = $args; |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
192 |
} |
} |
193 |
|
|
194 |
|
|
195 |
function &get_ecom($label) { |
function &get_ecom($label) { |
196 |
//return "Hello World"; |
//return "Hello World"; |
197 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
198 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
199 |
} |
} |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
function _load_ecoms() { |
function _load_ecoms() { |
204 |
|
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
205 |
foreach($this->_e_state[ecoms] as $label => $val) { |
foreach($this->_e_state[ecoms] as $label => $val) { |
206 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
207 |
} |
} |
208 |
} |
} |
209 |
|
|
210 |
|
|
211 |
|
|
212 |
function _load_ecom($label) { |
function _load_ecom($label) { |
213 |
|
|
214 |
|
// fetch values from state |
215 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
216 |
// find right gui module |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
217 |
$com_type = $val['ecom_type']; |
|
218 |
|
// NEW [2003-04-10]: ecom-RESET-condition |
219 |
|
if (!is_array($val) && $val == 'RESET') { |
220 |
|
debug::info("Resetting component: $label"); |
221 |
|
return; |
222 |
|
} |
223 |
|
|
224 |
|
// find right ecom gui module |
225 |
|
$ecom_type = $val['ecom_type']; |
226 |
$abstract_type = $val['ecom_abstract_type']; |
$abstract_type = $val['ecom_abstract_type']; |
227 |
$gui_module = $this->_module['gui'][$com_type][$abstract_type]['name']; |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
228 |
|
//print Dumper($gui_module); |
229 |
if(!$gui_module) { |
if(!$gui_module) { |
230 |
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]']"); |
231 |
return; |
return; |
232 |
} |
} |
233 |
// get arguments needed for gui module |
|
234 |
|
// get arguments needed for ecom gui module |
235 |
$args = $this->_prepare_component_args($label); |
$args = $this->_prepare_component_args($label); |
236 |
//print Dumper($args); |
//print Dumper($args); |
237 |
|
|
238 |
// get GUI module |
// get ecom GUI module |
239 |
$ecom = php::mkComponent($gui_module, $args); |
if (!$ecom = php::mkComponent($gui_module, $args)) { |
240 |
|
return; |
241 |
|
} |
242 |
//print Dumper($ecom); |
//print Dumper($ecom); |
243 |
|
|
244 |
// get phphtmllib GUI object |
// load phphtmllib GUI object |
245 |
$gui_ecom = &$ecom->get(); |
$gui_ecom = &$ecom->get(); |
246 |
|
|
247 |
// add hidden vars, needed for explorer control |
// add hidden vars, needed for explorer control |
251 |
//print "Hidden: " . Dumper($hidden_items); |
//print "Hidden: " . Dumper($hidden_items); |
252 |
} |
} |
253 |
|
|
254 |
|
// attempt: |
255 |
|
//$gui_ecom->make_transparent(); |
256 |
|
|
257 |
|
// store phphtmllib GUI object |
258 |
$this->_ecom[$label] = &$gui_ecom; |
$this->_ecom[$label] = &$gui_ecom; |
259 |
} |
} |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
function _get_hidden_items($label) { |
function _get_hidden_items($label) { |
264 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
$ecom_state = $this->_e_state['ecoms'][$label]; |
265 |
if($ecom_state['ecom_type'] == "data") { |
if($ecom_state['ecom_type'] == "data") { |
290 |
return $hidden_items; |
return $hidden_items; |
291 |
} |
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
function _prepare_component_args($label) { |
function _prepare_component_args($label) { |
296 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
297 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
298 |
|
|
299 |
|
// detect and execute 'selectSource' action |
300 |
|
// FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th. |
301 |
|
//print Dumper($this->_e_state['sources']); |
302 |
|
if ($source = $this->_e_state['main']['ecom_data_source_key']) { |
303 |
|
//print "selectSource: $source<br/>"; |
304 |
|
//global $app; |
305 |
|
//print Dumper($backend); |
306 |
|
//$app->backend->do(); |
307 |
|
} |
308 |
|
|
309 |
// switch component type |
// switch component type |
310 |
if($val['ecom_type'] == "data") { |
if($val['ecom_type'] == "data") { |
311 |
// switch abstract type |
// switch abstract type |
312 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
313 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
314 |
//$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
315 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']); |
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', nodename => $val['ecom_data_ident']); |
316 |
} else { |
} else { |
317 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
318 |
} |
} |
319 |
$args = array( |
$args = array( |
320 |
'caption' => "Liste", |
'caption' => $val['ecom_data_ident'], |
321 |
'orderby' => "Guid", |
'orderby' => "Guid", |
322 |
'options' => array( |
'options' => array( |
323 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
324 |
'decode' => 1, |
'decode' => 1, |
325 |
'decode_args' => array( |
'decode_args' => array( |
326 |
'seperator' => "_", |
'seperator' => "_", |
327 |
'form' => 1, |
//'form' => 1, |
328 |
|
), |
329 |
|
'actionbar' => array( |
330 |
|
'name' => "ecdfa", |
331 |
|
'list' => array( |
332 |
|
"View" => 'view', |
333 |
|
"Edit" => 'edit', |
334 |
|
"Delete" => 'delete', |
335 |
|
"Add new" => 'add', |
336 |
|
), |
337 |
), |
), |
338 |
), |
), |
339 |
); |
); |
340 |
// switch abstract type |
// switch abstract type |
341 |
} elseif ($val['ecom_abstract_type'] == "item") { |
} elseif ($val['ecom_abstract_type'] == "item") { |
342 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
343 |
//$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
344 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']); |
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']); |
345 |
} else { |
} else { |
346 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
347 |
} |
} |
348 |
|
|
349 |
|
// defaults |
350 |
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
351 |
|
//$val['ecom_mode'] = "view"; |
352 |
|
|
353 |
|
// debugging |
354 |
print "Mode: $val[ecom_mode]<br>"; |
print "Mode: $val[ecom_mode]<br>"; |
355 |
|
|
356 |
|
// prepare some arguments... |
357 |
$args = array( |
$args = array( |
358 |
'caption' => "Item", |
'caption' => $val['ecom_data_meta'], |
359 |
'mode' => $val['ecom_mode'], |
'mode' => $val['ecom_mode'], |
360 |
'options' => array( |
'options' => array( |
361 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
365 |
), |
), |
366 |
), |
), |
367 |
); |
); |
368 |
if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
if ($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
369 |
|
|
370 |
|
// FIXME: (see WebExplorer::Module::AbstractGUIModule) |
371 |
|
//if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'GenericNegotiation'; } |
372 |
|
if ($val['ecom_mode'] == "delete") { $args['adapter'] = 'NonValidatingFormProcessor'; } |
373 |
|
|
374 |
} |
} |
375 |
|
|
376 |
// switch component type |
// switch component type |
377 |
} elseif ($val['ecom_type'] == "nav") { |
} elseif ($val['ecom_type'] == "nav") { |
378 |
// switch abstract type |
// switch abstract type |
379 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
380 |
|
$args = array(); |
381 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
382 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema' ); |
// switch component label |
383 |
|
if($label == "nav") { |
384 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
385 |
|
$args['caption'] = "Objekt Typen"; |
386 |
|
} |
387 |
|
// NEW [2003-04-05]: DataSource.Chooser |
388 |
|
elseif ($label == "chooser") { |
389 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
390 |
|
$args['caption'] = "Datenquellen"; |
391 |
|
} |
392 |
|
$args['options']['data_locator_meta'] = $data_locator_meta; |
393 |
} else { |
} else { |
394 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !"); |
395 |
} |
} |
|
$args = array( |
|
|
'caption' => "Objekt Typen", |
|
|
'options' => array( |
|
|
'data_locator_meta' => $data_locator_meta, |
|
|
), |
|
|
); |
|
396 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
} elseif ($val['ecom_abstract_type'] == "tree") { |
397 |
$args = array(); |
$args = array(); |
398 |
} |
} |
399 |
|
|
400 |
|
// NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser) |
401 |
|
// switch component type |
402 |
|
} elseif ($val['ecom_type'] == "call") { |
403 |
|
|
404 |
|
// responses of RemoteActions are not predictable! |
405 |
|
if ($val['ecom_abstract_type'] == "auto") { |
406 |
|
|
407 |
|
// Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere! |
408 |
|
|
409 |
|
// Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently. |
410 |
|
// Really - just a remote call is issued, no data-/schema-structures or similar are expected. |
411 |
|
|
412 |
|
// The RemoteMethod 'method' is called directly with arguments in 'args'! |
413 |
|
// As response (important for widget assignement!) you may expect an arbitrary payload. |
414 |
|
$args['options']['data_locator_meta'] = array( |
415 |
|
transport => 'rpc', |
416 |
|
metatype => 'method', |
417 |
|
method => $val['ecom_call_method'], |
418 |
|
args => $val['ecom_call_args'] |
419 |
|
); |
420 |
|
|
421 |
|
} else { |
422 |
|
// FIXME: implement automatic re-dispatching to available ecoms here! |
423 |
|
user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?"); |
424 |
|
} |
425 |
|
|
426 |
} |
} |
427 |
return $args; |
return $args; |
428 |
} |
} |
429 |
|
|
430 |
|
|
431 |
|
|
432 |
function get_msg($label) { |
function get_msg($label) { |
433 |
if($label == "welcome") { |
if($label == "welcome") { |
434 |
$msg = "Welcome to the Explorer."; |
$msg = "Welcome to the Explorer."; |
435 |
} |
} |
436 |
return $msg; |
return $msg; |
437 |
} |
} |
438 |
|
|
439 |
|
|
440 |
|
|
441 |
function render() { |
function render() { |
442 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |