4 |
* $Id$ |
* $Id$ |
5 |
* |
* |
6 |
* $Log$ |
* $Log$ |
7 |
|
* Revision 1.20 2003/11/22 18:46:33 udo |
8 |
|
* update for expand data item |
9 |
|
* |
10 |
|
* Revision 1.19 2003/07/14 09:54:58 jonen |
11 |
|
* fixed bug related to 'item delete' |
12 |
|
* |
13 |
|
* Revision 1.18 2003/07/02 12:18:00 jonen |
14 |
|
* fixed bugs |
15 |
|
* |
16 |
|
* Revision 1.17 2003/06/25 23:45:05 joko |
17 |
|
* trying to switch from "ap" completely to "t" |
18 |
|
* |
19 |
|
* Revision 1.16 2003/05/13 14:53:56 joko |
20 |
|
* reset mvc-params "filter" and "meta" in tree mode!? |
21 |
|
* |
22 |
|
* Revision 1.15 2003/05/10 18:19:55 jonen |
23 |
|
* + added stuff relating to 'create/add new' links/buttons |
24 |
|
* |
25 |
|
* Revision 1.14 2003/04/19 16:20:47 jonen |
26 |
|
* + added handle of ecom 'UMnav' according to page 'Benutzverwaltung' |
27 |
|
* |
28 |
|
* Revision 1.13 2003/04/18 15:30:24 joko |
29 |
|
* NEW: parameter 'ecom_data_filter' - used for 'items' |
30 |
|
* (introduced to filter xml-payload at backend side via xpath queries) |
31 |
|
* documented global state parameters |
32 |
|
* some comments |
33 |
|
* |
34 |
|
* Revision 1.12 2003/04/18 13:40:54 jonen |
35 |
|
* + added 'topic' to requested vars which will currently be merged with the 'ap' var |
36 |
|
* |
37 |
|
* Revision 1.11 2003/04/11 00:51:10 joko |
38 |
|
* minor update: just testing stuff... |
39 |
|
* |
40 |
|
* Revision 1.10 2003/04/10 06:03:26 joko |
41 |
|
* ++ renamed keys: 'ecom_data_form_edit', 'ecom_data_form_cancel' through 'ecom_data_action_edit', 'ecom_data_action_cancel' |
42 |
|
* + new key: 'ecom_data_action_delete' |
43 |
|
* + Action.Delete: not really, since it's inside component in fact (self-contained ecom) |
44 |
|
* |
45 |
|
* Revision 1.9 2003/04/09 00:05:50 jonen |
46 |
|
* added request values and functions needed for extended form handling |
47 |
|
* |
48 |
|
* Revision 1.8 2003/04/08 17:53:08 joko |
49 |
|
* NEW: Module 'RemoteAction' in 'phase_startup' |
50 |
|
* |
51 |
|
* Revision 1.7 2003/04/07 22:32:27 jonen |
52 |
|
* + minor changes related to new ecom 'chooser' |
53 |
|
* |
54 |
|
* Revision 1.6 2003/04/06 01:32:57 jonen |
55 |
|
* + minor changes |
56 |
|
* |
57 |
|
* Revision 1.5 2003/04/05 21:18:29 joko |
58 |
|
* added Chooser and associated 'ecds'-parameter |
59 |
|
* new rule (at bottom) to dispatch datasource-keys to each ecom-component |
60 |
|
* |
61 |
|
* Revision 1.4 2003/04/04 23:59:19 jonen |
62 |
|
* + minor changes according to data form submits |
63 |
|
* |
64 |
|
* Revision 1.3 2003/04/04 01:28:13 jonen |
65 |
|
* + added function to purge unwanted merged vars |
66 |
|
* + handle form submit's now |
67 |
|
* |
68 |
* Revision 1.2 2003/03/20 07:54:52 jonen |
* Revision 1.2 2003/03/20 07:54:52 jonen |
69 |
* + added docu |
* + added docu |
70 |
* |
* |
125 |
|
|
126 |
$this->add_model( array( |
$this->add_model( array( |
127 |
//args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ), |
//args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ), |
128 |
request_args => array( 'ap', 'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_action', 'ecom_data_locator_key', |
request_args => array( |
129 |
'ecom_data_ident', 'ecom_data_meta' ), |
// ApplicationTopic |
130 |
|
'topic', |
131 |
|
// ApplicationPage |
132 |
|
'ap', |
133 |
|
// important/required parameters for valid ecom-components |
134 |
|
'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_mode', |
135 |
|
// parameters about data identifiers, locations, sources and associated meta-information |
136 |
|
'ecom_data_locator_key', |
137 |
|
'ecom_data_ident', |
138 |
|
'ecom_data_meta', 'ecom_data_meta_x', |
139 |
|
'ecom_data_action_edit', 'ecom_data_action_cancel', 'ecom_data_action_delete', 'ecom_data_action_create', |
140 |
|
'ecom_data_action_expand_edit', |
141 |
|
'ecom_data_form_checkbox', 'ecom_data_form_action', |
142 |
|
'ecom_data_source_key', |
143 |
|
'ecom_data_filter', |
144 |
|
), |
145 |
request_arg => array( |
request_arg => array( |
146 |
'ap' => array( query_arg => 'ap' ), |
|
147 |
'ecom_label' => array( query_arg => 'ecl' ), |
// a key identifying the current topic |
148 |
'ecom_type' => array( query_arg => 'ect' ), |
'topic' => array( query_arg => 't' ), |
149 |
'ecom_abstract_type' => array( query_arg => 'ecat' ), |
|
150 |
'ecom_action' => array( query_arg => 'ecac' ), |
// a key identifying the current page |
151 |
'ecom_data_locator_key' => array( query_arg => 'ecdlk' ), |
'ap' => array( query_arg => 'ap' ), |
152 |
'ecom_data_ident' => array( query_arg => 'ecdid' ), |
|
153 |
'ecom_data_meta' => array( query_arg => 'ecdm' ), |
// ecom, ecom, ecom |
154 |
|
|
155 |
|
// component specific arguments (important for the main dispatcher, etc.) |
156 |
|
// a label identifying a component |
157 |
|
'ecom_label' => array( query_arg => 'ecl' ), |
158 |
|
// data or schema |
159 |
|
'ecom_type' => array( query_arg => 'ect' ), |
160 |
|
// item, list or tree |
161 |
|
'ecom_abstract_type' => array( query_arg => 'ecat' ), |
162 |
|
|
163 |
|
|
164 |
|
// data, data, data |
165 |
|
|
166 |
|
// e.g. view, edit |
167 |
|
'ecom_mode' => array( query_arg => 'ecmod' ), |
168 |
|
// This should be renamed to 'ecom_data_transport_key'. |
169 |
|
'ecom_data_locator_key' => array( query_arg => 'ecdlk' ), |
170 |
|
|
171 |
|
// This should be enough to identify data Xyz. |
172 |
|
// e.g. an OID, a GUID, a filename or similar stuff |
173 |
|
'ecom_data_ident' => array( query_arg => 'ecdid' ), |
174 |
|
// e.g. a classname or a filename |
175 |
|
'ecom_data_meta' => array( query_arg => 'ecdm' ), |
176 |
|
// extended meta, e.g. 2nd parent identifier |
177 |
|
'ecom_data_meta_x' => array( query_arg => 'ecdmx' ), |
178 |
|
// filter the data: e.g. |
179 |
|
// - an xpath-query (xpq), |
180 |
|
// - an abstract/custom filter string or |
181 |
|
// - a parent node identifier (maybe revamp as 'ecdpnid')? |
182 |
|
'ecom_data_filter' => array( query_arg => 'ecdf' ), |
183 |
|
|
184 |
|
// Some actions ... |
185 |
|
// ... required for data items. |
186 |
|
'ecom_data_action_edit' => array( query_arg => 'ecdfe' ), |
187 |
|
'ecom_data_action_cancel' => array( query_arg => 'ecdfc' ), |
188 |
|
'ecom_data_action_delete' => array( query_arg => 'ecdfd' ), |
189 |
|
'ecom_data_action_create' => array( query_arg => 'ecdfcr' ), |
190 |
|
// ... required for data lists. |
191 |
|
'ecom_data_form_action' => array( query_arg => 'ecdfa' ), |
192 |
|
'ecom_data_form_checkbox' => array( query_arg => 'checkbox' ), |
193 |
|
// ... required for expanded data items. |
194 |
|
'ecom_data_action_expand_edit' => array( query_arg => 'ecdfee' ), |
195 |
|
|
196 |
|
// Special argument (should become a non-data-action). |
197 |
|
// Triggers 'selectSource' at backend api (remote api) which causes a database handle switch. |
198 |
|
'ecom_data_source_key' => array( query_arg => 'ecds' ), |
199 |
|
|
200 |
), |
), |
201 |
|
|
202 |
/* |
/* |
203 |
// block model (what is used for each block) |
// block model (what is used for each block) |
204 |
|
// is this deprecated??? |
205 |
block => array( |
block => array( |
206 |
'ident' => array( query_arg => 'ident' ), |
'ident' => array( query_arg => 'ident' ), |
207 |
'meta' => array( query_arg => 'meta' ), |
'meta' => array( query_arg => 'meta' ), |
214 |
|
|
215 |
)); |
)); |
216 |
|
|
217 |
|
|
218 |
|
// TODO: activate MVC-Views!!! |
219 |
|
// - Here: Picture a ecom-component as a MVC-View. |
220 |
|
// - Assign a GUID to each ecom-component! |
221 |
|
// - Build WebExplorer-Introspection-Module to show stuff like this... (->WebExplorer::Designer) |
222 |
|
|
223 |
|
|
224 |
//$this->setup_views( &$this->_registry ); |
//$this->setup_views( &$this->_registry ); |
225 |
|
|
226 |
// associate behaviour with "View"-components |
// associate behaviour with "View"-components |
248 |
// COID => '123', |
// COID => '123', |
249 |
caption => "Explorer - ExplorerDataItem", |
caption => "Explorer - ExplorerDataItem", |
250 |
)); |
)); |
251 |
|
|
252 |
// FIXME!!! enhance!?!? |
// FIXME!!! enhance!?!? |
253 |
// AIM: "dispatch a Request to a View by using rules..." |
// AIM: "dispatch a Request to a View by using rules..." |
254 |
// Todo: |
// Todo: |
257 |
// Enhance this backend and introduce a mechanism to trigger |
// Enhance this backend and introduce a mechanism to trigger |
258 |
// a true callback to process a rule (or: "as a rule") on top of that. |
// a true callback to process a rule (or: "as a rule") on top of that. |
259 |
$this->add_controller( array( |
$this->add_controller( array( |
260 |
|
|
261 |
// for "module", no component registry is required, just does 'mkObject' under the hood |
// for "module", no component registry is required, just does 'mkObject' under the hood |
262 |
module => 'Application::Request::HttpController', |
module => 'Application::Request::HttpController', |
263 |
|
//module_options => blah |
264 |
|
|
265 |
rules => array( |
rules => array( |
266 |
|
|
267 |
// get last page state |
// get last page state |
268 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
269 |
$requestTracker = mkObject("Application::Request::Tracker"); |
$requestTracker = mkObject("Application::Request::Tracker"); |
270 |
$page_state = $requestTracker->getPointer(); |
$page_state = $requestTracker->getPointer(); |
271 |
$_out = $page_state[options]; |
$pre_out = $page_state[options]; |
272 |
|
//print "pre_out: " . Dumper($pre_out); |
273 |
|
|
274 |
|
// clean-up unwanted variables |
275 |
|
$label = $_in[ecom_label]; |
276 |
|
switch ($_in[ecom_abstract_type]) { |
277 |
|
case "list": |
278 |
|
if ($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); } |
279 |
|
if ($pre_out[options][ecoms][$label][ecom_data_meta_x]) { unset($pre_out[options][ecoms][$label][ecom_data_meta_x]); } |
280 |
|
break; |
281 |
|
// 2003-04-16: required for xmltree-to-item transition |
282 |
|
// if we dont do this the "dotted" filter expression would persist across views |
283 |
|
case "item": |
284 |
|
if ($pre_out[options][ecoms][$label][ecom_data_filter]) { unset($pre_out[options][ecoms][$label][ecom_data_filter]); } |
285 |
|
break; |
286 |
|
case "tree": |
287 |
|
if ($pre_out[options][ecoms][$label][ecom_data_filter]) { unset($pre_out[options][ecoms][$label][ecom_data_filter]); } |
288 |
|
if ($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); } |
289 |
|
break; |
290 |
|
} |
291 |
|
$_out = $pre_out; |
292 |
|
'), |
293 |
|
|
294 |
|
// reset machine |
295 |
|
create_function('&$_in, &$_out', ' |
296 |
|
// HACK!!! |
297 |
|
// FIXME: review and implement in a more clean way? |
298 |
|
//print "RESET!<br/>"; |
299 |
|
$_out[options][ecoms][phase_startup] = "RESET"; |
300 |
'), |
'), |
301 |
|
|
302 |
// rewrite idents |
// rewrite idents |
303 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
304 |
$idents = array ( ap, ); |
|
305 |
foreach($idents as $key) { |
// old version: ap == explorer |
306 |
$_out[options][idents][$key] = $_in[$key]; |
// map Topic to Page if exists |
307 |
} |
//if ($_in[topic]) { |
308 |
|
// $_in[ap] = $_in[topic]; |
309 |
|
//} |
310 |
|
//$idents = array ( ap ); |
311 |
|
//foreach($idents as $key) { |
312 |
|
// $_out[options][idents][$key] = $_in[$key]; |
313 |
|
//} |
314 |
|
|
315 |
|
// 2003-06-26: switched from ap=explorer to t=DataBrowser |
316 |
|
$_out[options][idents][t] = $_in[topic]; |
317 |
|
|
318 |
'), |
'), |
319 |
|
|
320 |
// check right $_GET[ap] |
// check right $_GET[ap] - depreciated |
321 |
create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value $_in[ap], sure this is right here?" : null;'), |
//create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value [ap]: $_in[ap], sure this is right here?<br>" : null;'), |
322 |
|
|
323 |
// write components variables to out |
// write components variables to out |
324 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
325 |
$vars = array( ecom_type, ecom_abstract_type, ecom_action, ecom_data_locator_key, ecom_data_ident, ecom_data_meta ); |
$vars = array( |
326 |
|
ecom_type, ecom_abstract_type, ecom_mode, ecom_data_locator_key, |
327 |
|
ecom_data_ident, ecom_data_meta, ecom_data_filter, ecom_data_meta_x |
328 |
|
); |
329 |
|
// ecom_call_method, ecom_call_args |
330 |
if($_in[ecom_label]) { |
if($_in[ecom_label]) { |
331 |
foreach($vars as $key) { |
foreach($vars as $key) { |
332 |
if($_in[$key]) { |
if($_in[$key]) { |
333 |
|
//print "var: " . $key . " value: " . $_in[$key] . "<br>"; |
334 |
$label = $_in[ecom_label]; |
$label = $_in[ecom_label]; |
335 |
$_out[options][ecoms][$label][$key] = $_in[$key]; |
$_out[options][ecoms][$label][$key] = $_in[$key]; |
336 |
} |
} |
340 |
return; |
return; |
341 |
'), |
'), |
342 |
|
|
343 |
// create default ecoms (navigation, etc.) |
// create default ecoms (navigation, chooser [as of 2003-04-05] etc.) |
344 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
345 |
if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) { |
if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) { |
346 |
$_out[options][ecoms] = array( |
$_out[options][ecoms] = array( |
347 |
nav => array( |
nav => array( |
348 |
ecom_type => "nav", |
ecom_type => "nav", |
349 |
ecom_abstract_type => "list", |
ecom_abstract_type => "list", |
350 |
ecom_action => "nav", |
ecom_mode => "link", |
351 |
|
ecom_data_locator_key => "rpc", |
352 |
|
), |
353 |
|
chooser => array( |
354 |
|
ecom_type => "nav", |
355 |
|
ecom_abstract_type => "list", |
356 |
|
ecom_mode => "link", |
357 |
ecom_data_locator_key => "rpc", |
ecom_data_locator_key => "rpc", |
358 |
), |
), |
359 |
); |
); |
362 |
return; |
return; |
363 |
'), |
'), |
364 |
|
|
365 |
|
// handle data form action(button) |
366 |
|
create_function('&$_in, &$_out', ' |
367 |
|
if($_in[ap] == "Benutzerverwaltung" || $_in[topic] == "Benutzerverwaltung") { |
368 |
|
if(!$_out[options][ecoms][UMnav]) { |
369 |
|
$_out[options][ecoms][UMnav] = array( |
370 |
|
ecom_type => "nav", |
371 |
|
ecom_abstract_type => "tree", |
372 |
|
ecom_mode => "link", |
373 |
|
ecom_data_locator_key => "rpc", |
374 |
|
); |
375 |
|
} |
376 |
|
} |
377 |
|
'), |
378 |
|
|
379 |
|
// handle data form action(button) |
380 |
|
create_function('&$_in, &$_out', ' |
381 |
|
$label = $_in[ecom_label]; |
382 |
|
if($_in[ecom_data_form_action]) { |
383 |
|
//print "from action button pressed!<br>"; |
384 |
|
if(is_array($_in[ecom_data_form_checkbox])) { |
385 |
|
$cnt = sizeof($_in[ecom_data_form_checkbox]); |
386 |
|
$tmp = array(); |
387 |
|
foreach($_in[ecom_data_form_checkbox] as $ident) { |
388 |
|
if($ident) { array_push($tmp, $ident); } |
389 |
|
} |
390 |
|
if($cnt == 1) { |
391 |
|
print "Single selection, ident : " . $tmp[0] . "<br>"; |
392 |
|
$_out[options][ecoms][$label][ecom_data_ident] = $tmp[0]; |
393 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
394 |
|
} elseif($cnt > 1) { |
395 |
|
// TODO: implement multi-selection actions on rows(items) here!! |
396 |
|
print "Multi-Selection!! Current Ident(s) $tmp" . "<br>"; |
397 |
|
$_out[options][ecoms][$label][ecom_data_ident] = $tmp; |
398 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
399 |
|
} |
400 |
|
} else { |
401 |
|
print "ident: " . Dumper($_out[options][ecoms][$label][ecom_data_ident]) . "<br>"; |
402 |
|
} |
403 |
|
$_out[options][ecoms][$label][ecom_data_meta] = $_in[ecom_data_ident]; |
404 |
|
$_out[options][ecoms][$label][ecom_mode] = $_in[ecom_data_form_action]; |
405 |
|
//print "in: " . Dumper($_in) . "<br>"; |
406 |
|
//print "out: " . Dumper($_out) . "<br>"; |
407 |
|
} |
408 |
|
'), |
409 |
|
|
410 |
|
|
411 |
|
// handle data form buttons |
412 |
|
create_function('&$_in, &$_out', ' |
413 |
|
$label = $_in[ecom_label]; |
414 |
|
if($_in[ecom_data_action_edit]) { |
415 |
|
$_out[options][ecoms][$label][ecom_mode] = "edit"; |
416 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
417 |
|
} |
418 |
|
if($_in[ecom_data_action_cancel]) { |
419 |
|
$_out[options][ecoms][$label][ecom_mode] = "view"; |
420 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
421 |
|
} |
422 |
|
|
423 |
|
// Action.Create |
424 |
|
if($_in[ecom_data_action_create]) { |
425 |
|
//print Dumper($_out[options][ecoms][$label]); |
426 |
|
$_out[options][ecoms][$label][ecom_mode] = "create"; |
427 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
428 |
|
} |
429 |
|
if($_in[ecom_data_action_expand_edit]) { |
430 |
|
//print Dumper($_out[options][ecoms][$label]); |
431 |
|
$_out[options][ecoms][$label][ecom_mode] = "expandedit"; |
432 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
433 |
|
} |
434 |
|
|
435 |
|
// Action.Delete [new of 2003-04-09] |
436 |
|
if ($_in[ecom_data_action_delete]) { |
437 |
|
|
438 |
|
//$_out[options][ecoms][content][ecom_mode] = "view"; |
439 |
|
|
440 |
|
// the code here vanished to the component itself! |
441 |
|
// could/should we do this for "edit" and/or "view" actions as well? |
442 |
|
// look at ecom/FlexibleDataItem! |
443 |
|
|
444 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
445 |
|
} |
446 |
|
'), |
447 |
|
|
448 |
|
// propagate datasources to ecoms |
449 |
|
// datasource-change requested? enhance logic here! |
450 |
|
// by now each ecom-component gets injected the very same |
451 |
|
// datasource if requested - otherwise everything will fall back to defaults |
452 |
|
create_function('&$_in, &$_out', ' |
453 |
|
if ($_in[ecom_data_source_key]) { |
454 |
|
|
455 |
|
print "YAI: ecom_data_source_key<br/>"; |
456 |
|
|
457 |
|
//print Dumper($_out[options][ecoms]); |
458 |
|
//print "ds: " . $_in[ecom_data_source_key] . "<br/>"; |
459 |
|
/* |
460 |
|
foreach ($_out[options][ecoms] as $name => $ecom) { |
461 |
|
print "name: $name<br/>"; |
462 |
|
//$_out[options][sources][selected] = $_in[ecom_data_source]; |
463 |
|
$_out[options][ecoms][$name][ecom_data_source_key] = $_in[ecom_data_source_key]; |
464 |
|
} |
465 |
|
*/ |
466 |
|
$_out[options][main][ecom_data_source_key] = $_in[ecom_data_source_key]; |
467 |
|
|
468 |
|
|
469 |
|
// 2003-04-07 - enhanced |
470 |
|
// now activates a special ecom-component - a "RemoteAction" - replacing |
471 |
|
// the "content"-ecom instead of displaying an empty page / overriding any |
472 |
|
// view reached by "normal dispatching" |
473 |
|
|
474 |
|
$_out[options][ecoms][phase_startup] = array( |
475 |
|
ecom_type => "call", |
476 |
|
ecom_abstract_type => "auto", |
477 |
|
ecom_mode => "link", |
478 |
|
ecom_data_locator_key => "rpc", |
479 |
|
// new attributes/properties/arguments that control further / trigger different DataFlow: |
480 |
|
// FIXME: add these to declaration at top! |
481 |
|
ecom_call_method => "selectSource", |
482 |
|
ecom_call_args => $_in[ecom_data_source_key] |
483 |
|
); |
484 |
|
|
485 |
|
} |
486 |
|
'), |
487 |
|
|
488 |
|
|
489 |
/* |
/* |
490 |
// translate value of argument "action" (olist => list.view, oedit => item.edit) |
// translate value of argument "action" (olist => list.view, oedit => item.edit) |
491 |
// action dispatcher |
// action dispatcher |