4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.14 2003/04/09 00:31:27 jonen |
8 |
|
## + added arguments for data list ecom |
9 |
|
## |
10 |
|
## Revision 1.13 2003/04/09 00:03:11 jonen |
11 |
|
## disabled form rendering for inheritanced items at 'list' |
12 |
|
## |
13 |
|
## Revision 1.12 2003/04/08 17:52:12 joko |
14 |
|
## CHANGE: renamed property 'datasource' to 'transport' |
15 |
|
## NEW: Module 'RemoteAction' |
16 |
|
## |
17 |
|
## Revision 1.11 2003/04/07 22:31:51 jonen |
18 |
|
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
19 |
|
## - removed recent added ecom type chooser |
20 |
|
## |
21 |
## Revision 1.10 2003/04/05 20:32:04 joko |
## Revision 1.10 2003/04/05 20:32:04 joko |
22 |
## added Chooser |
## added Chooser |
23 |
## |
## |
107 |
|
|
108 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
109 |
$this->_data_locators = $data_locators; |
$this->_data_locators = $data_locators; |
110 |
$this->init_default_gui_modules(); |
$this->init_default_gui_modules(); |
|
|
|
111 |
$this->set_e_state(); |
$this->set_e_state(); |
112 |
|
|
113 |
|
//debug |
114 |
//print "State: " . Dumper($this->_state) ."<br>"; |
//print "State: " . Dumper($this->_state) ."<br>"; |
115 |
$div = html_div(); |
$div = html_div(); |
116 |
$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)); |
118 |
if (constants::get('DEBUG')) { |
if (constants::get('DEBUG')) { |
119 |
print $div->render(); |
print $div->render(); |
120 |
} |
} |
|
//$this->init_state(); |
|
121 |
} |
} |
122 |
|
|
123 |
|
|
160 |
|
|
161 |
|
|
162 |
function init_default_gui_modules() { |
function init_default_gui_modules() { |
163 |
|
|
164 |
|
// format of parameters: label, ecom_type, abstract_type, module_name |
165 |
|
|
166 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
167 |
$this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") ); |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
168 |
$this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") ); |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
169 |
$this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") ); |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
170 |
// 2003-04-05 - Chooser |
// 2003-04-05 - Chooser |
171 |
$this->register_gui_module("list", "chooser", array( 'name' => "WebExplorer::Module::Chooser", 'type' => "list") ); |
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
172 |
|
// 2003-04-07 - RemoteAction |
173 |
|
$this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction"); |
174 |
} |
} |
175 |
|
|
176 |
function register_source_module($label, $args) { |
function register_source_module($label, $args) { |
177 |
$this->_module['source'][$label] = $args; |
$this->_module['source'][$label] = $args; |
178 |
} |
} |
179 |
|
|
180 |
function register_gui_module($abstract_type, $ecom_type, $args) { |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
181 |
$this->_module['gui'][$ecom_type][$abstract_type] = $args; |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
182 |
} |
} |
183 |
|
|
184 |
|
|
185 |
function &get_ecom($label) { |
function &get_ecom($label) { |
186 |
//return "Hello World"; |
//return "Hello World"; |
187 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
188 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
189 |
} |
} |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
function _load_ecoms() { |
function _load_ecoms() { |
194 |
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
196 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
197 |
} |
} |
198 |
} |
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
function _load_ecom($label) { |
function _load_ecom($label) { |
203 |
|
// fetch values from state |
204 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
205 |
debug::info("_load_ecom: " . Dumper($val) . "<br/>"); |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
206 |
// find right gui module |
|
207 |
$com_type = $val['ecom_type']; |
// find right ecom gui module |
208 |
|
$ecom_type = $val['ecom_type']; |
209 |
$abstract_type = $val['ecom_abstract_type']; |
$abstract_type = $val['ecom_abstract_type']; |
210 |
$gui_module = $this->_module['gui'][$com_type][$abstract_type]['name']; |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
211 |
|
//print Dumper($gui_module); |
212 |
if(!$gui_module) { |
if(!$gui_module) { |
213 |
user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', 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]']"); |
214 |
return; |
return; |
215 |
} |
} |
216 |
// get arguments needed for gui module |
|
217 |
|
// get arguments needed for ecom gui module |
218 |
$args = $this->_prepare_component_args($label); |
$args = $this->_prepare_component_args($label); |
219 |
//print Dumper($args); |
//print Dumper($args); |
220 |
|
|
221 |
// get GUI module |
// get ecom GUI module |
222 |
$ecom = php::mkComponent($gui_module, $args); |
if (!$ecom = php::mkComponent($gui_module, $args)) { |
223 |
|
return; |
224 |
|
} |
225 |
//print Dumper($ecom); |
//print Dumper($ecom); |
226 |
|
|
227 |
// get phphtmllib GUI object |
// load phphtmllib GUI object |
228 |
$gui_ecom = &$ecom->get(); |
$gui_ecom = &$ecom->get(); |
229 |
|
|
230 |
// add hidden vars, needed for explorer control |
// add hidden vars, needed for explorer control |
234 |
//print "Hidden: " . Dumper($hidden_items); |
//print "Hidden: " . Dumper($hidden_items); |
235 |
} |
} |
236 |
|
|
237 |
|
// attempt: |
238 |
|
//$gui_ecom->make_transparent(); |
239 |
|
|
240 |
|
// store phphtmllib GUI object |
241 |
$this->_ecom[$label] = &$gui_ecom; |
$this->_ecom[$label] = &$gui_ecom; |
242 |
} |
} |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
function _get_hidden_items($label) { |
function _get_hidden_items($label) { |
247 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
$ecom_state = $this->_e_state['ecoms'][$label]; |
248 |
if($ecom_state['ecom_type'] == "data") { |
if($ecom_state['ecom_type'] == "data") { |
273 |
return $hidden_items; |
return $hidden_items; |
274 |
} |
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
function _prepare_component_args($label) { |
function _prepare_component_args($label) { |
279 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
280 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
294 |
// switch abstract type |
// switch abstract type |
295 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
296 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
297 |
//$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', classname => $val['ecom_data_ident']); |
298 |
$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', classname => $val['ecom_data_ident']); |
299 |
} else { |
} else { |
300 |
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] !"); |
301 |
} |
} |
302 |
$args = array( |
$args = array( |
303 |
'caption' => "Liste", |
'caption' => $val['ecom_data_ident'], |
304 |
'orderby' => "Guid", |
'orderby' => "Guid", |
305 |
'options' => array( |
'options' => array( |
306 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
307 |
'decode' => 1, |
'decode' => 1, |
308 |
'decode_args' => array( |
'decode_args' => array( |
309 |
'seperator' => "_", |
'seperator' => "_", |
310 |
'form' => 1, |
//'form' => 1, |
311 |
|
), |
312 |
|
'actionbar' => array( |
313 |
|
'name' => "ecdfa", |
314 |
|
'list' => array( |
315 |
|
"View" => 'view', |
316 |
|
"Edit" => 'edit', |
317 |
|
"Delete" => 'delete', |
318 |
|
"Add new" => 'add', |
319 |
|
), |
320 |
), |
), |
321 |
), |
), |
322 |
); |
); |
323 |
// switch abstract type |
// switch abstract type |
324 |
} elseif ($val['ecom_abstract_type'] == "item") { |
} elseif ($val['ecom_abstract_type'] == "item") { |
325 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
326 |
//$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', classname => $val['ecom_data_ident']); |
327 |
$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'], classname => $val['ecom_data_meta']); |
328 |
} else { |
} else { |
329 |
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] !"); |
330 |
} |
} |
331 |
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
332 |
print "Mode: $val[ecom_mode]<br>"; |
print "Mode: $val[ecom_mode]<br>"; |
333 |
$args = array( |
$args = array( |
334 |
'caption' => "Item", |
'caption' => $val['ecom_data_meta'], |
335 |
'mode' => $val['ecom_mode'], |
'mode' => $val['ecom_mode'], |
336 |
'options' => array( |
'options' => array( |
337 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
348 |
} elseif ($val['ecom_type'] == "nav") { |
} elseif ($val['ecom_type'] == "nav") { |
349 |
// switch abstract type |
// switch abstract type |
350 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
351 |
|
$args = array(); |
352 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
353 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
// switch component label |
354 |
|
if($label == "nav") { |
355 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
356 |
|
$args['caption'] = "Objekt Typen"; |
357 |
|
} |
358 |
|
// NEW [2003-04-05]: DataSource.Chooser |
359 |
|
elseif ($label == "chooser") { |
360 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
361 |
|
$args['caption'] = "Datenquellen"; |
362 |
|
} |
363 |
|
$args['options']['data_locator_meta'] = $data_locator_meta; |
364 |
} else { |
} else { |
365 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema 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] !"); |
366 |
} |
} |
|
$args = array( |
|
|
'caption' => "Objekt Typen", |
|
|
'options' => array( |
|
|
'data_locator_meta' => $data_locator_meta, |
|
|
), |
|
|
); |
|
367 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
} elseif ($val['ecom_abstract_type'] == "tree") { |
368 |
$args = array(); |
$args = array(); |
369 |
} |
} |
370 |
|
|
371 |
|
// NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser) |
372 |
// switch component type |
// switch component type |
373 |
// NEW [2003-04-05]: DataSource.Chooser |
} elseif ($val['ecom_type'] == "call") { |
|
} elseif ($val['ecom_type'] == "chooser") { |
|
374 |
|
|
375 |
// switch abstract type |
// responses of RemoteActions are not predictable! |
376 |
if($val['ecom_abstract_type'] == "list") { |
if ($val['ecom_abstract_type'] == "auto") { |
377 |
if ($val['ecom_data_locator_key'] == "rpc") { |
|
378 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
// Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere! |
379 |
} else { |
|
380 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !"); |
// Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently. |
381 |
} |
// Really - just a remote call is issued, no data-/schema-structures or similar are expected. |
382 |
$args = array( |
|
383 |
'caption' => "Datenquellen", |
// The RemoteMethod 'method' is called directly with arguments in 'args'! |
384 |
'options' => array( |
// As response (important for widget assignement!) you may expect an arbitrary payload. |
385 |
'data_locator_meta' => $data_locator_meta, |
$args['options']['data_locator_meta'] = array( |
386 |
), |
transport => 'rpc', |
387 |
|
metatype => 'method', |
388 |
|
method => $val['ecom_call_method'], |
389 |
|
args => $val['ecom_call_args'] |
390 |
); |
); |
391 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
|
392 |
$args = array(); |
} else { |
393 |
} |
// FIXME: implement automatic re-dispatching to available ecoms here! |
394 |
|
user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?"); |
395 |
|
} |
396 |
|
|
397 |
} |
} |
398 |
return $args; |
return $args; |
399 |
} |
} |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
function get_msg($label) { |
function get_msg($label) { |
404 |
if($label == "welcome") { |
if($label == "welcome") { |
405 |
$msg = "Welcome to the Explorer."; |
$msg = "Welcome to the Explorer."; |
406 |
} |
} |
407 |
return $msg; |
return $msg; |
408 |
} |
} |
409 |
|
|
410 |
|
|
411 |
|
|
412 |
function render() { |
function render() { |
413 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |