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