4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.11 2003/04/07 22:31:51 jonen |
8 |
|
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
9 |
|
## - removed recent added ecom type chooser |
10 |
|
## |
11 |
|
## Revision 1.10 2003/04/05 20:32:04 joko |
12 |
|
## added Chooser |
13 |
|
## |
14 |
|
## Revision 1.9 2003/04/04 02:22:37 joko |
15 |
|
## minor fix: querySchema now issues argument |
16 |
|
## |
17 |
|
## Revision 1.8 2003/04/04 01:16:03 jonen |
18 |
|
## + integrated different mode's for 'DataItem' |
19 |
|
## |
20 |
|
## Revision 1.7 2003/03/29 07:49:55 joko |
21 |
|
## show boxes in DEBUG-mode only! |
22 |
|
## |
23 |
|
## Revision 1.6 2003/03/28 06:42:37 joko |
24 |
|
## fix: propagating rpc-debugging-options to constants here |
25 |
|
## |
26 |
|
## Revision 1.5 2003/03/27 01:24:29 jonen |
27 |
|
## + enabled navigation ecom (only list yet) |
28 |
|
## |
29 |
|
## Revision 1.4 2003/03/20 08:02:11 jonen |
30 |
|
## + purged code |
31 |
|
## |
32 |
|
## Revision 1.3 2003/03/20 07:54:52 jonen |
33 |
|
## + added docu |
34 |
|
## |
35 |
## Revision 1.2 2003/03/20 07:44:31 jonen |
## Revision 1.2 2003/03/20 07:44:31 jonen |
36 |
## + removed dumper |
## + removed dumper |
37 |
## |
## |
57 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
58 |
*/ |
*/ |
59 |
|
|
60 |
|
/** |
61 |
|
* WebExplorer::AbstractExplorer - this can be simple compared to a container, |
62 |
|
* which modular GUI classes can be register, manipulated and rendered... |
63 |
|
* |
64 |
|
* @author Sebastian Utz <seut@tunemedia.de> |
65 |
|
* @package org.netfrag.app |
66 |
|
* @name WebExplorer::AbstractExplorer |
67 |
|
*/ |
68 |
|
|
69 |
|
|
70 |
class WebExplorer_AbstractExplorer { |
class WebExplorer_AbstractExplorer { |
71 |
|
|
94 |
*/ |
*/ |
95 |
var $_e_state = array(); |
var $_e_state = array(); |
96 |
|
|
|
// needed (old)? |
|
|
var $_control = array(); |
|
|
var $_hidden_elements = array(); |
|
|
|
|
97 |
|
|
98 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
99 |
$this->_data_locators = $data_locators; |
$this->_data_locators = $data_locators; |
100 |
$this->init_default_gui_modules(); |
$this->init_default_gui_modules(); |
|
|
|
101 |
$this->set_e_state(); |
$this->set_e_state(); |
102 |
|
|
103 |
|
//debug |
104 |
//print "State: " . Dumper($this->_state) ."<br>"; |
//print "State: " . Dumper($this->_state) ."<br>"; |
105 |
print "Explorer_State: " . Dumper($this->_e_state) ."<br>"; |
$div = html_div(); |
106 |
//$this->init_state(); |
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
107 |
|
$div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;'); |
108 |
|
if (constants::get('DEBUG')) { |
109 |
|
print $div->render(); |
110 |
|
} |
111 |
} |
} |
112 |
|
|
113 |
|
|
122 |
$rpcinfo = $app->getConfig("rpcinfo"); |
$rpcinfo = $app->getConfig("rpcinfo"); |
123 |
define('RPC_HOSTNAME', $rpcinfo[Host]); |
define('RPC_HOSTNAME', $rpcinfo[Host]); |
124 |
define('RPC_PORT', $rpcinfo[Port]); |
define('RPC_PORT', $rpcinfo[Port]); |
125 |
|
define('RPC_DEBUG', $rpcinfo[DEBUG]); |
126 |
|
define('RPC_TRACE', $rpcinfo[TRACE]); |
127 |
|
define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]); |
128 |
} else { |
} else { |
129 |
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!"); |
130 |
} |
} |
151 |
|
|
152 |
function init_default_gui_modules() { |
function init_default_gui_modules() { |
153 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
154 |
$this->register_gui_module("list", "nav", array( 'name' => "NavigationList", 'type' => "list") ); |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
155 |
$this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") ); |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
156 |
$this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") ); |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
157 |
|
// 2003-04-05 - Chooser |
158 |
|
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
159 |
} |
} |
160 |
|
|
161 |
function register_source_module($label, $args) { |
function register_source_module($label, $args) { |
162 |
$this->_module['source'][$label] = $args; |
$this->_module['source'][$label] = $args; |
163 |
} |
} |
164 |
|
|
165 |
function register_gui_module($abstract_type, $ecom_type, $args) { |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
166 |
$this->_module['gui'][$ecom_type][$abstract_type] = $args; |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
167 |
} |
} |
168 |
|
|
169 |
|
|
170 |
function &get_ecom($label) { |
function &get_ecom($label) { |
171 |
//return "Hello World"; |
//return "Hello World"; |
172 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
173 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
174 |
} |
} |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
function _load_ecoms() { |
function _load_ecoms() { |
179 |
|
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
180 |
foreach($this->_e_state[ecoms] as $label => $val) { |
foreach($this->_e_state[ecoms] as $label => $val) { |
181 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
182 |
} |
} |
183 |
} |
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
function _load_ecom($label) { |
function _load_ecom($label) { |
188 |
|
// fetch values from state |
189 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
190 |
// find right gui module |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
191 |
$com_type = $val['ecom_type']; |
|
192 |
|
// find right ecom gui module |
193 |
|
$ecom_type = $val['ecom_type']; |
194 |
$abstract_type = $val['ecom_abstract_type']; |
$abstract_type = $val['ecom_abstract_type']; |
195 |
$gui_module = $this->_module['gui'][$com_type][$abstract_type]['name']; |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
196 |
|
//print Dumper($gui_module); |
197 |
if(!$gui_module) { |
if(!$gui_module) { |
198 |
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]']"); |
199 |
return; |
return; |
200 |
} |
} |
201 |
// get arguments needed for gui module |
|
202 |
|
// get arguments needed for ecom gui module |
203 |
$args = $this->_prepare_component_args($label); |
$args = $this->_prepare_component_args($label); |
204 |
//print Dumper($args); |
//print Dumper($args); |
205 |
|
|
206 |
// get GUI module |
// get ecom GUI module |
207 |
$ecom = php::mkComponent($gui_module, $args); |
$ecom = php::mkComponent($gui_module, $args); |
208 |
//print Dumper($ecom); |
//print Dumper($ecom); |
209 |
|
|
210 |
// get phphtmllib GUI object |
// load phphtmllib GUI object |
211 |
$gui_ecom = &$ecom->get(); |
$gui_ecom = &$ecom->get(); |
212 |
|
|
213 |
// add hidden vars, needed for explorer control |
// add hidden vars, needed for explorer control |
214 |
$hidden_items = $this->_get_hidden_items($label); |
$hidden_items = $this->_get_hidden_items($label); |
215 |
$ecom->add_hidden_items($hidden_items); |
if(is_array($hidden_items) ) { |
216 |
//print "Hidden: " . Dumper($gui_ecom->_hidden_items); |
$ecom->add_hidden_items($hidden_items); |
217 |
|
//print "Hidden: " . Dumper($hidden_items); |
218 |
|
} |
219 |
|
|
220 |
|
// attempt: |
221 |
|
//$gui_ecom->make_transparent(); |
222 |
|
|
223 |
|
// store phphtmllib GUI object |
224 |
$this->_ecom[$label] = &$gui_ecom; |
$this->_ecom[$label] = &$gui_ecom; |
225 |
} |
} |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
function _get_hidden_items($label) { |
function _get_hidden_items($label) { |
230 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
$ecom_state = $this->_e_state['ecoms'][$label]; |
231 |
if($ecom_state['ecom_abstract_type'] == "list") { |
if($ecom_state['ecom_type'] == "data") { |
232 |
$hidden_items = array( |
if($ecom_state['ecom_abstract_type'] == "list") { |
233 |
|
$hidden_items = array( |
234 |
|
'ecl' => $label, |
235 |
|
'ecat' => "item", |
236 |
|
'ecmod' => "view", |
237 |
|
); |
238 |
|
} |
239 |
|
elseif($ecom_state['ecom_abstract_type'] == "item") { |
240 |
|
$hidden_items = array( |
241 |
'ecl' => $label, |
'ecl' => $label, |
242 |
|
'ecat' => "item", |
243 |
|
'ecmod' => "view", |
244 |
); |
); |
245 |
|
/* |
246 |
|
if($ecom_state['ecom_mode'] == "view") { |
247 |
|
$hidden_items['ecmod'] = "edit"; |
248 |
|
} |
249 |
|
elseif($ecom_state['ecom_mode'] == "edit") { |
250 |
|
$hidden_items['ecmod'] = "edit"; |
251 |
|
} |
252 |
|
*/ |
253 |
|
} |
254 |
|
$hidden_items['ap'] = "explorer"; |
255 |
} |
} |
|
// set default hidden item for whole explorer |
|
|
$hidden_items['ap'] = "explorer"; |
|
256 |
return $hidden_items; |
return $hidden_items; |
257 |
} |
} |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
function _prepare_component_args($label) { |
function _prepare_component_args($label) { |
262 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
263 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
264 |
if($val['ecom_abstract_type'] == "list") { |
|
265 |
if($val['ecom_data_locator_key'] == "rpc") { |
// detect and execute 'selectSource' action |
266 |
$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. |
267 |
} else { |
//print Dumper($this->_e_state['sources']); |
268 |
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']) { |
269 |
} |
//print "selectSource: $source<br/>"; |
270 |
$args = array( |
//global $app; |
271 |
'caption' => "Liste", |
//print Dumper($backend); |
272 |
|
//$app->backend->do(); |
273 |
|
} |
274 |
|
|
275 |
|
// switch component type |
276 |
|
if($val['ecom_type'] == "data") { |
277 |
|
// switch abstract type |
278 |
|
if($val['ecom_abstract_type'] == "list") { |
279 |
|
if($val['ecom_data_locator_key'] == "rpc") { |
280 |
|
//$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
281 |
|
$data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']); |
282 |
|
} else { |
283 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
284 |
|
} |
285 |
|
$args = array( |
286 |
|
'caption' => $val['ecom_data_ident'], |
287 |
'orderby' => "Guid", |
'orderby' => "Guid", |
288 |
'options' => array( |
'options' => array( |
289 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
294 |
), |
), |
295 |
), |
), |
296 |
); |
); |
297 |
} elseif ($ecom_type == "item") { |
// switch abstract type |
298 |
$args = array(); |
} elseif ($val['ecom_abstract_type'] == "item") { |
299 |
} elseif ($ecom_type == "nav") { |
if($val['ecom_data_locator_key'] == "rpc") { |
300 |
$args = array(); |
//$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
301 |
|
$data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']); |
302 |
|
} else { |
303 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
304 |
|
} |
305 |
|
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
306 |
|
print "Mode: $val[ecom_mode]<br>"; |
307 |
|
$args = array( |
308 |
|
'caption' => $val['ecom_data_meta'], |
309 |
|
'mode' => $val['ecom_mode'], |
310 |
|
'options' => array( |
311 |
|
'data_locator_meta' => $data_locator_meta, |
312 |
|
'decode' => 1, |
313 |
|
'decode_args' => array( |
314 |
|
'seperator' => "_", |
315 |
|
), |
316 |
|
), |
317 |
|
); |
318 |
|
if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
319 |
|
} |
320 |
|
|
321 |
|
// switch component type |
322 |
|
} elseif ($val['ecom_type'] == "nav") { |
323 |
|
// switch abstract type |
324 |
|
if($val['ecom_abstract_type'] == "list") { |
325 |
|
$args = array(); |
326 |
|
if($val['ecom_data_locator_key'] == "rpc") { |
327 |
|
// switch component label |
328 |
|
if($label == "nav") { |
329 |
|
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
330 |
|
$args['caption'] = "Objekt Typen"; |
331 |
|
} |
332 |
|
// NEW [2003-04-05]: DataSource.Chooser |
333 |
|
elseif ($label == "chooser") { |
334 |
|
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
335 |
|
$args['caption'] = "Datenquellen"; |
336 |
|
} |
337 |
|
$args['options']['data_locator_meta'] = $data_locator_meta; |
338 |
|
} else { |
339 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !"); |
340 |
|
} |
341 |
|
} elseif ($val['ecom_abstract_type'] == "tree") { |
342 |
|
$args = array(); |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
} |
} |
347 |
return $args; |
return $args; |
348 |
} |
} |
349 |
|
|
350 |
|
|
351 |
|
|
352 |
function get_msg($label) { |
function get_msg($label) { |
353 |
if($label == "welcome") { |
if($label == "welcome") { |
354 |
$msg = "Welcome to the Explorer."; |
$msg = "Welcome to the Explorer."; |
355 |
} |
} |
356 |
return $msg; |
return $msg; |
357 |
} |
} |
358 |
|
|
359 |
|
|
360 |
|
|
361 |
function render() { |
function render() { |
362 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |