4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.12 2003/04/08 17:52:12 joko |
8 |
|
## CHANGE: renamed property 'datasource' to 'transport' |
9 |
|
## NEW: Module 'RemoteAction' |
10 |
|
## |
11 |
|
## Revision 1.11 2003/04/07 22:31:51 jonen |
12 |
|
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
13 |
|
## - removed recent added ecom type chooser |
14 |
|
## |
15 |
|
## Revision 1.10 2003/04/05 20:32:04 joko |
16 |
|
## added Chooser |
17 |
|
## |
18 |
## Revision 1.9 2003/04/04 02:22:37 joko |
## Revision 1.9 2003/04/04 02:22:37 joko |
19 |
## minor fix: querySchema now issues argument |
## minor fix: querySchema now issues argument |
20 |
## |
## |
101 |
|
|
102 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
103 |
$this->_data_locators = $data_locators; |
$this->_data_locators = $data_locators; |
104 |
$this->init_default_gui_modules(); |
$this->init_default_gui_modules(); |
|
|
|
105 |
$this->set_e_state(); |
$this->set_e_state(); |
106 |
|
|
107 |
|
//debug |
108 |
//print "State: " . Dumper($this->_state) ."<br>"; |
//print "State: " . Dumper($this->_state) ."<br>"; |
109 |
$div = html_div(); |
$div = html_div(); |
110 |
$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)); |
112 |
if (constants::get('DEBUG')) { |
if (constants::get('DEBUG')) { |
113 |
print $div->render(); |
print $div->render(); |
114 |
} |
} |
|
//$this->init_state(); |
|
115 |
} |
} |
116 |
|
|
117 |
|
|
154 |
|
|
155 |
|
|
156 |
function init_default_gui_modules() { |
function init_default_gui_modules() { |
157 |
|
|
158 |
|
// format of parameters: label, ecom_type, abstract_type, module_name |
159 |
|
|
160 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
161 |
$this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") ); |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
162 |
$this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") ); |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
163 |
$this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") ); |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
164 |
|
// 2003-04-05 - Chooser |
165 |
|
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
166 |
|
// 2003-04-07 - RemoteAction |
167 |
|
$this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction"); |
168 |
} |
} |
169 |
|
|
170 |
function register_source_module($label, $args) { |
function register_source_module($label, $args) { |
171 |
$this->_module['source'][$label] = $args; |
$this->_module['source'][$label] = $args; |
172 |
} |
} |
173 |
|
|
174 |
function register_gui_module($abstract_type, $ecom_type, $args) { |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
175 |
$this->_module['gui'][$ecom_type][$abstract_type] = $args; |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
176 |
} |
} |
177 |
|
|
178 |
|
|
179 |
function &get_ecom($label) { |
function &get_ecom($label) { |
180 |
//return "Hello World"; |
//return "Hello World"; |
181 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
182 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
183 |
} |
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
function _load_ecoms() { |
function _load_ecoms() { |
188 |
|
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
189 |
foreach($this->_e_state[ecoms] as $label => $val) { |
foreach($this->_e_state[ecoms] as $label => $val) { |
190 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
191 |
} |
} |
192 |
} |
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
function _load_ecom($label) { |
function _load_ecom($label) { |
197 |
|
// fetch values from state |
198 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
199 |
// find right gui module |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
200 |
$com_type = $val['ecom_type']; |
|
201 |
|
// find right ecom gui module |
202 |
|
$ecom_type = $val['ecom_type']; |
203 |
$abstract_type = $val['ecom_abstract_type']; |
$abstract_type = $val['ecom_abstract_type']; |
204 |
$gui_module = $this->_module['gui'][$com_type][$abstract_type]['name']; |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
205 |
|
//print Dumper($gui_module); |
206 |
if(!$gui_module) { |
if(!$gui_module) { |
207 |
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]']"); |
208 |
return; |
return; |
209 |
} |
} |
210 |
// get arguments needed for gui module |
|
211 |
|
// get arguments needed for ecom gui module |
212 |
$args = $this->_prepare_component_args($label); |
$args = $this->_prepare_component_args($label); |
213 |
//print Dumper($args); |
//print Dumper($args); |
214 |
|
|
215 |
// get GUI module |
// get ecom GUI module |
216 |
$ecom = php::mkComponent($gui_module, $args); |
if (!$ecom = php::mkComponent($gui_module, $args)) { |
217 |
|
return; |
218 |
|
} |
219 |
//print Dumper($ecom); |
//print Dumper($ecom); |
220 |
|
|
221 |
// get phphtmllib GUI object |
// load phphtmllib GUI object |
222 |
$gui_ecom = &$ecom->get(); |
$gui_ecom = &$ecom->get(); |
223 |
|
|
224 |
// add hidden vars, needed for explorer control |
// add hidden vars, needed for explorer control |
228 |
//print "Hidden: " . Dumper($hidden_items); |
//print "Hidden: " . Dumper($hidden_items); |
229 |
} |
} |
230 |
|
|
231 |
|
// attempt: |
232 |
|
//$gui_ecom->make_transparent(); |
233 |
|
|
234 |
|
// store phphtmllib GUI object |
235 |
$this->_ecom[$label] = &$gui_ecom; |
$this->_ecom[$label] = &$gui_ecom; |
236 |
} |
} |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
function _get_hidden_items($label) { |
function _get_hidden_items($label) { |
241 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
$ecom_state = $this->_e_state['ecoms'][$label]; |
242 |
if($ecom_state['ecom_type'] == "data") { |
if($ecom_state['ecom_type'] == "data") { |
267 |
return $hidden_items; |
return $hidden_items; |
268 |
} |
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
function _prepare_component_args($label) { |
function _prepare_component_args($label) { |
273 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
274 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
275 |
|
|
276 |
|
// detect and execute 'selectSource' action |
277 |
|
// FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th. |
278 |
|
//print Dumper($this->_e_state['sources']); |
279 |
|
if ($source = $this->_e_state['main']['ecom_data_source_key']) { |
280 |
|
//print "selectSource: $source<br/>"; |
281 |
|
//global $app; |
282 |
|
//print Dumper($backend); |
283 |
|
//$app->backend->do(); |
284 |
|
} |
285 |
|
|
286 |
// switch component type |
// switch component type |
287 |
if($val['ecom_type'] == "data") { |
if($val['ecom_type'] == "data") { |
288 |
// switch abstract type |
// switch abstract type |
289 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
290 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
291 |
//$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']); |
292 |
$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']); |
293 |
} else { |
} else { |
294 |
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] !"); |
295 |
} |
} |
296 |
$args = array( |
$args = array( |
297 |
'caption' => "Liste", |
'caption' => $val['ecom_data_ident'], |
298 |
'orderby' => "Guid", |
'orderby' => "Guid", |
299 |
'options' => array( |
'options' => array( |
300 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
308 |
// switch abstract type |
// switch abstract type |
309 |
} elseif ($val['ecom_abstract_type'] == "item") { |
} elseif ($val['ecom_abstract_type'] == "item") { |
310 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
311 |
//$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']); |
312 |
$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']); |
313 |
} else { |
} else { |
314 |
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] !"); |
315 |
} |
} |
316 |
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
317 |
print "Mode: $val[ecom_mode]<br>"; |
print "Mode: $val[ecom_mode]<br>"; |
318 |
$args = array( |
$args = array( |
319 |
'caption' => "Item", |
'caption' => $val['ecom_data_meta'], |
320 |
'mode' => $val['ecom_mode'], |
'mode' => $val['ecom_mode'], |
321 |
'options' => array( |
'options' => array( |
322 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
328 |
); |
); |
329 |
if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
330 |
} |
} |
331 |
|
|
332 |
// switch component type |
// switch component type |
333 |
} elseif ($val['ecom_type'] == "nav") { |
} elseif ($val['ecom_type'] == "nav") { |
334 |
// switch abstract type |
// switch abstract type |
335 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
336 |
|
$args = array(); |
337 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
338 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'concrete' ); |
// switch component label |
339 |
|
if($label == "nav") { |
340 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
341 |
|
$args['caption'] = "Objekt Typen"; |
342 |
|
} |
343 |
|
// NEW [2003-04-05]: DataSource.Chooser |
344 |
|
elseif ($label == "chooser") { |
345 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
346 |
|
$args['caption'] = "Datenquellen"; |
347 |
|
} |
348 |
|
$args['options']['data_locator_meta'] = $data_locator_meta; |
349 |
} else { |
} else { |
350 |
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] !"); |
351 |
} |
} |
|
$args = array( |
|
|
'caption' => "Objekt Typen", |
|
|
'options' => array( |
|
|
'data_locator_meta' => $data_locator_meta, |
|
|
), |
|
|
); |
|
352 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
} elseif ($val['ecom_abstract_type'] == "tree") { |
353 |
$args = array(); |
$args = array(); |
354 |
} |
} |
355 |
|
|
356 |
|
// NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser) |
357 |
|
// switch component type |
358 |
|
} elseif ($val['ecom_type'] == "call") { |
359 |
|
|
360 |
|
// responses of RemoteActions are not predictable! |
361 |
|
if ($val['ecom_abstract_type'] == "auto") { |
362 |
|
|
363 |
|
// Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere! |
364 |
|
|
365 |
|
// Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently. |
366 |
|
// Really - just a remote call is issued, no data-/schema-structures or similar are expected. |
367 |
|
|
368 |
|
// The RemoteMethod 'method' is called directly with arguments in 'args'! |
369 |
|
// As response (important for widget assignement!) you may expect an arbitrary payload. |
370 |
|
$args['options']['data_locator_meta'] = array( |
371 |
|
transport => 'rpc', |
372 |
|
metatype => 'method', |
373 |
|
method => $val['ecom_call_method'], |
374 |
|
args => $val['ecom_call_args'] |
375 |
|
); |
376 |
|
|
377 |
|
} else { |
378 |
|
// FIXME: implement automatic re-dispatching to available ecoms here! |
379 |
|
user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?"); |
380 |
|
} |
381 |
|
|
382 |
} |
} |
383 |
return $args; |
return $args; |
384 |
} |
} |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
function get_msg($label) { |
function get_msg($label) { |
389 |
if($label == "welcome") { |
if($label == "welcome") { |
390 |
$msg = "Welcome to the Explorer."; |
$msg = "Welcome to the Explorer."; |
391 |
} |
} |
392 |
return $msg; |
return $msg; |
393 |
} |
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
function render() { |
function render() { |
398 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |