/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/MVC.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.app/WebExplorer/MVC.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations)
Sat Nov 22 18:46:33 2003 UTC (20 years, 9 months ago) by udo
Branch: MAIN
Changes since 1.19: +12 -1 lines
update for expand data item

1 <?php
2
3 /**
4 * $Id: MVC.php,v 1.19 2003/07/14 09:54:58 jonen Exp $
5 *
6 * $Log: MVC.php,v $
7 * Revision 1.19 2003/07/14 09:54:58 jonen
8 * fixed bug related to 'item delete'
9 *
10 * Revision 1.18 2003/07/02 12:18:00 jonen
11 * fixed bugs
12 *
13 * Revision 1.17 2003/06/25 23:45:05 joko
14 * trying to switch from "ap" completely to "t"
15 *
16 * Revision 1.16 2003/05/13 14:53:56 joko
17 * reset mvc-params "filter" and "meta" in tree mode!?
18 *
19 * Revision 1.15 2003/05/10 18:19:55 jonen
20 * + added stuff relating to 'create/add new' links/buttons
21 *
22 * Revision 1.14 2003/04/19 16:20:47 jonen
23 * + added handle of ecom 'UMnav' according to page 'Benutzverwaltung'
24 *
25 * Revision 1.13 2003/04/18 15:30:24 joko
26 * NEW: parameter 'ecom_data_filter' - used for 'items'
27 * (introduced to filter xml-payload at backend side via xpath queries)
28 * documented global state parameters
29 * some comments
30 *
31 * Revision 1.12 2003/04/18 13:40:54 jonen
32 * + added 'topic' to requested vars which will currently be merged with the 'ap' var
33 *
34 * Revision 1.11 2003/04/11 00:51:10 joko
35 * minor update: just testing stuff...
36 *
37 * Revision 1.10 2003/04/10 06:03:26 joko
38 * ++ renamed keys: 'ecom_data_form_edit', 'ecom_data_form_cancel' through 'ecom_data_action_edit', 'ecom_data_action_cancel'
39 * + new key: 'ecom_data_action_delete'
40 * + Action.Delete: not really, since it's inside component in fact (self-contained ecom)
41 *
42 * Revision 1.9 2003/04/09 00:05:50 jonen
43 * added request values and functions needed for extended form handling
44 *
45 * Revision 1.8 2003/04/08 17:53:08 joko
46 * NEW: Module 'RemoteAction' in 'phase_startup'
47 *
48 * Revision 1.7 2003/04/07 22:32:27 jonen
49 * + minor changes related to new ecom 'chooser'
50 *
51 * Revision 1.6 2003/04/06 01:32:57 jonen
52 * + minor changes
53 *
54 * Revision 1.5 2003/04/05 21:18:29 joko
55 * added Chooser and associated 'ecds'-parameter
56 * new rule (at bottom) to dispatch datasource-keys to each ecom-component
57 *
58 * Revision 1.4 2003/04/04 23:59:19 jonen
59 * + minor changes according to data form submits
60 *
61 * Revision 1.3 2003/04/04 01:28:13 jonen
62 * + added function to purge unwanted merged vars
63 * + handle form submit's now
64 *
65 * Revision 1.2 2003/03/20 07:54:52 jonen
66 * + added docu
67 *
68 * Revision 1.1 2003/03/20 03:48:47 jonen
69 * + initial commit
70 *
71 * Revision 1.2 2003/03/18 00:00:20 cvsmax
72 * + added thoughts and models for preparing control data to Explorer
73 *
74 * Revision 1.1 2003/03/08 02:36:39 cvsmax
75 * + moved from *.inc
76 * + mungled namespace with WebExplorer
77 *
78 * Revision 1.1 2003/03/03 22:26:16 joko
79 * + initial commit, inherits from WebMVC
80 *
81 * Revision 1.1 2003/03/02 00:49:36 joko
82 * + initial commit
83 *
84 *
85 */
86
87 /**
88 * WebExplorer::MVC - this the MVC used by the WebExplorer.
89 * Its derived from the 'Site::WebAppMVC' module.
90 *
91 * @author Sebastian Utz <seut@tunemedia.de>
92 * @package org.netfrag.app
93 * @name WebExplorer::MVC
94 */
95
96 loadModule('Site::WebAppMVC');
97
98 class WebExplorer_MVC extends Site_WebAppMVC {
99
100 //var $_backend = null;
101 var $_raw = array();
102 var $_registry = array();
103
104 function WebExplorer_MVC(&$args) {
105
106 parent::constructor();
107
108 // new!!! a registry for Views!!!
109 //$regdb = $this->getStaticRegistryDatabase();
110 //$this->_registry = mkObject('Application::ComponentRegistry', &$regdb, 'REGDB_PAYLOAD');
111
112 // new!!! storing the raw request here
113 $this->_raw[request] = &$args[request];
114
115 // new!!! user_setup, phpHtmlLib-style...
116 $this->user_setup();
117
118 }
119
120 // setup MVC (model-view-controller) metadata information
121 function user_setup() {
122
123 $this->add_model( array(
124 //args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ),
125 request_args => array(
126 // ApplicationTopic
127 'topic',
128 // ApplicationPage
129 'ap',
130 // important/required parameters for valid ecom-components
131 'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_mode',
132 // parameters about data identifiers, locations, sources and associated meta-information
133 'ecom_data_locator_key',
134 'ecom_data_ident',
135 'ecom_data_meta', 'ecom_data_meta_x',
136 'ecom_data_action_edit', 'ecom_data_action_cancel', 'ecom_data_action_delete', 'ecom_data_action_create',
137 'ecom_data_action_expand_edit',
138 'ecom_data_form_checkbox', 'ecom_data_form_action',
139 'ecom_data_source_key',
140 'ecom_data_filter',
141 ),
142 request_arg => array(
143
144 // a key identifying the current topic
145 'topic' => array( query_arg => 't' ),
146
147 // a key identifying the current page
148 'ap' => array( query_arg => 'ap' ),
149
150 // ecom, ecom, ecom
151
152 // component specific arguments (important for the main dispatcher, etc.)
153 // a label identifying a component
154 'ecom_label' => array( query_arg => 'ecl' ),
155 // data or schema
156 'ecom_type' => array( query_arg => 'ect' ),
157 // item, list or tree
158 'ecom_abstract_type' => array( query_arg => 'ecat' ),
159
160
161 // data, data, data
162
163 // e.g. view, edit
164 'ecom_mode' => array( query_arg => 'ecmod' ),
165 // This should be renamed to 'ecom_data_transport_key'.
166 'ecom_data_locator_key' => array( query_arg => 'ecdlk' ),
167
168 // This should be enough to identify data Xyz.
169 // e.g. an OID, a GUID, a filename or similar stuff
170 'ecom_data_ident' => array( query_arg => 'ecdid' ),
171 // e.g. a classname or a filename
172 'ecom_data_meta' => array( query_arg => 'ecdm' ),
173 // extended meta, e.g. 2nd parent identifier
174 'ecom_data_meta_x' => array( query_arg => 'ecdmx' ),
175 // filter the data: e.g.
176 // - an xpath-query (xpq),
177 // - an abstract/custom filter string or
178 // - a parent node identifier (maybe revamp as 'ecdpnid')?
179 'ecom_data_filter' => array( query_arg => 'ecdf' ),
180
181 // Some actions ...
182 // ... required for data items.
183 'ecom_data_action_edit' => array( query_arg => 'ecdfe' ),
184 'ecom_data_action_cancel' => array( query_arg => 'ecdfc' ),
185 'ecom_data_action_delete' => array( query_arg => 'ecdfd' ),
186 'ecom_data_action_create' => array( query_arg => 'ecdfcr' ),
187 // ... required for data lists.
188 'ecom_data_form_action' => array( query_arg => 'ecdfa' ),
189 'ecom_data_form_checkbox' => array( query_arg => 'checkbox' ),
190 // ... required for expanded data items.
191 'ecom_data_action_expand_edit' => array( query_arg => 'ecdfee' ),
192
193 // Special argument (should become a non-data-action).
194 // Triggers 'selectSource' at backend api (remote api) which causes a database handle switch.
195 'ecom_data_source_key' => array( query_arg => 'ecds' ),
196
197 ),
198
199 /*
200 // block model (what is used for each block)
201 // is this deprecated???
202 block => array(
203 'ident' => array( query_arg => 'ident' ),
204 'meta' => array( query_arg => 'meta' ),
205 'action' => array( query_arg => 'action'),
206 'data_locator_key' => array( query_arg => 'dlk' ),
207 'gui_module' => array( query_arg => 'gm' ),
208 'abstract_type' => array( query_arg => 'at' ),
209 ),
210 */
211
212 ));
213
214
215 // TODO: activate MVC-Views!!!
216 // - Here: Picture a ecom-component as a MVC-View.
217 // - Assign a GUID to each ecom-component!
218 // - Build WebExplorer-Introspection-Module to show stuff like this... (->WebExplorer::Designer)
219
220
221 //$this->setup_views( &$this->_registry );
222
223 // associate behaviour with "View"-components
224 // identify component by: module name or component identifier (COID)
225 // 'name' is looked up in that to get metadata information about the comp.
226 // component: for 'component = 1', a component registry is required!!!
227 // name: registry-lookup: by-name
228 // COID: registry-lookup: by-COID
229 // caption: caption of area or title of page
230 $this->add_view( array(
231 component => 1,
232 name => 'NavigationList',
233 // COID => '123',
234 caption => "Explorer - NavigationList",
235 ));
236 $this->add_view( array(
237 component => 1,
238 name => 'ExplorerDataList',
239 // COID => '123',
240 caption => "Explorer - ExplorerDataList",
241 ));
242 $this->add_view( array(
243 component => 1,
244 name => 'ExplorerDataItem',
245 // COID => '123',
246 caption => "Explorer - ExplorerDataItem",
247 ));
248
249 // FIXME!!! enhance!?!?
250 // AIM: "dispatch a Request to a View by using rules..."
251 // Todo:
252 // 'HttpController' is *very* dumb by now, it just iterates
253 // this flat list below triggering the lambdas with their arguments.
254 // Enhance this backend and introduce a mechanism to trigger
255 // a true callback to process a rule (or: "as a rule") on top of that.
256 $this->add_controller( array(
257
258 // for "module", no component registry is required, just does 'mkObject' under the hood
259 module => 'Application::Request::HttpController',
260 //module_options => blah
261
262 rules => array(
263
264 // get last page state
265 create_function('&$_in, &$_out', '
266 $requestTracker = mkObject("Application::Request::Tracker");
267 $page_state = $requestTracker->getPointer();
268 $pre_out = $page_state[options];
269 //print "pre_out: " . Dumper($pre_out);
270
271 // clean-up unwanted variables
272 $label = $_in[ecom_label];
273 switch ($_in[ecom_abstract_type]) {
274 case "list":
275 if ($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); }
276 if ($pre_out[options][ecoms][$label][ecom_data_meta_x]) { unset($pre_out[options][ecoms][$label][ecom_data_meta_x]); }
277 break;
278 // 2003-04-16: required for xmltree-to-item transition
279 // if we dont do this the "dotted" filter expression would persist across views
280 case "item":
281 if ($pre_out[options][ecoms][$label][ecom_data_filter]) { unset($pre_out[options][ecoms][$label][ecom_data_filter]); }
282 break;
283 case "tree":
284 if ($pre_out[options][ecoms][$label][ecom_data_filter]) { unset($pre_out[options][ecoms][$label][ecom_data_filter]); }
285 if ($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); }
286 break;
287 }
288 $_out = $pre_out;
289 '),
290
291 // reset machine
292 create_function('&$_in, &$_out', '
293 // HACK!!!
294 // FIXME: review and implement in a more clean way?
295 //print "RESET!<br/>";
296 $_out[options][ecoms][phase_startup] = "RESET";
297 '),
298
299 // rewrite idents
300 create_function('&$_in, &$_out', '
301
302 // old version: ap == explorer
303 // map Topic to Page if exists
304 //if ($_in[topic]) {
305 // $_in[ap] = $_in[topic];
306 //}
307 //$idents = array ( ap );
308 //foreach($idents as $key) {
309 // $_out[options][idents][$key] = $_in[$key];
310 //}
311
312 // 2003-06-26: switched from ap=explorer to t=DataBrowser
313 $_out[options][idents][t] = $_in[topic];
314
315 '),
316
317 // check right $_GET[ap] - depreciated
318 //create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value [ap]: $_in[ap], sure this is right here?<br>" : null;'),
319
320 // write components variables to out
321 create_function('&$_in, &$_out', '
322 $vars = array(
323 ecom_type, ecom_abstract_type, ecom_mode, ecom_data_locator_key,
324 ecom_data_ident, ecom_data_meta, ecom_data_filter, ecom_data_meta_x
325 );
326 // ecom_call_method, ecom_call_args
327 if($_in[ecom_label]) {
328 foreach($vars as $key) {
329 if($_in[$key]) {
330 //print "var: " . $key . " value: " . $_in[$key] . "<br>";
331 $label = $_in[ecom_label];
332 $_out[options][ecoms][$label][$key] = $_in[$key];
333 }
334 }
335 }
336
337 return;
338 '),
339
340 // create default ecoms (navigation, chooser [as of 2003-04-05] etc.)
341 create_function('&$_in, &$_out', '
342 if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) {
343 $_out[options][ecoms] = array(
344 nav => array(
345 ecom_type => "nav",
346 ecom_abstract_type => "list",
347 ecom_mode => "link",
348 ecom_data_locator_key => "rpc",
349 ),
350 chooser => array(
351 ecom_type => "nav",
352 ecom_abstract_type => "list",
353 ecom_mode => "link",
354 ecom_data_locator_key => "rpc",
355 ),
356 );
357 }
358 //$_out[options][components] = $_in[components];
359 return;
360 '),
361
362 // handle data form action(button)
363 create_function('&$_in, &$_out', '
364 if($_in[ap] == "Benutzerverwaltung" || $_in[topic] == "Benutzerverwaltung") {
365 if(!$_out[options][ecoms][UMnav]) {
366 $_out[options][ecoms][UMnav] = array(
367 ecom_type => "nav",
368 ecom_abstract_type => "tree",
369 ecom_mode => "link",
370 ecom_data_locator_key => "rpc",
371 );
372 }
373 }
374 '),
375
376 // handle data form action(button)
377 create_function('&$_in, &$_out', '
378 $label = $_in[ecom_label];
379 if($_in[ecom_data_form_action]) {
380 //print "from action button pressed!<br>";
381 if(is_array($_in[ecom_data_form_checkbox])) {
382 $cnt = sizeof($_in[ecom_data_form_checkbox]);
383 $tmp = array();
384 foreach($_in[ecom_data_form_checkbox] as $ident) {
385 if($ident) { array_push($tmp, $ident); }
386 }
387 if($cnt == 1) {
388 print "Single selection, ident : " . $tmp[0] . "<br>";
389 $_out[options][ecoms][$label][ecom_data_ident] = $tmp[0];
390 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
391 } elseif($cnt > 1) {
392 // TODO: implement multi-selection actions on rows(items) here!!
393 print "Multi-Selection!! Current Ident(s) $tmp" . "<br>";
394 $_out[options][ecoms][$label][ecom_data_ident] = $tmp;
395 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
396 }
397 } else {
398 print "ident: " . Dumper($_out[options][ecoms][$label][ecom_data_ident]) . "<br>";
399 }
400 $_out[options][ecoms][$label][ecom_data_meta] = $_in[ecom_data_ident];
401 $_out[options][ecoms][$label][ecom_mode] = $_in[ecom_data_form_action];
402 //print "in: " . Dumper($_in) . "<br>";
403 //print "out: " . Dumper($_out) . "<br>";
404 }
405 '),
406
407
408 // handle data form buttons
409 create_function('&$_in, &$_out', '
410 $label = $_in[ecom_label];
411 if($_in[ecom_data_action_edit]) {
412 $_out[options][ecoms][$label][ecom_mode] = "edit";
413 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
414 }
415 if($_in[ecom_data_action_cancel]) {
416 $_out[options][ecoms][$label][ecom_mode] = "view";
417 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
418 }
419
420 // Action.Create
421 if($_in[ecom_data_action_create]) {
422 //print Dumper($_out[options][ecoms][$label]);
423 $_out[options][ecoms][$label][ecom_mode] = "create";
424 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
425 }
426 if($_in[ecom_data_action_expand_edit]) {
427 //print Dumper($_out[options][ecoms][$label]);
428 $_out[options][ecoms][$label][ecom_mode] = "expandedit";
429 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
430 }
431
432 // Action.Delete [new of 2003-04-09]
433 if ($_in[ecom_data_action_delete]) {
434
435 //$_out[options][ecoms][content][ecom_mode] = "view";
436
437 // the code here vanished to the component itself!
438 // could/should we do this for "edit" and/or "view" actions as well?
439 // look at ecom/FlexibleDataItem!
440
441 $_out[options][ecoms][$label][ecom_abstract_type] = "item";
442 }
443 '),
444
445 // propagate datasources to ecoms
446 // datasource-change requested? enhance logic here!
447 // by now each ecom-component gets injected the very same
448 // datasource if requested - otherwise everything will fall back to defaults
449 create_function('&$_in, &$_out', '
450 if ($_in[ecom_data_source_key]) {
451
452 print "YAI: ecom_data_source_key<br/>";
453
454 //print Dumper($_out[options][ecoms]);
455 //print "ds: " . $_in[ecom_data_source_key] . "<br/>";
456 /*
457 foreach ($_out[options][ecoms] as $name => $ecom) {
458 print "name: $name<br/>";
459 //$_out[options][sources][selected] = $_in[ecom_data_source];
460 $_out[options][ecoms][$name][ecom_data_source_key] = $_in[ecom_data_source_key];
461 }
462 */
463 $_out[options][main][ecom_data_source_key] = $_in[ecom_data_source_key];
464
465
466 // 2003-04-07 - enhanced
467 // now activates a special ecom-component - a "RemoteAction" - replacing
468 // the "content"-ecom instead of displaying an empty page / overriding any
469 // view reached by "normal dispatching"
470
471 $_out[options][ecoms][phase_startup] = array(
472 ecom_type => "call",
473 ecom_abstract_type => "auto",
474 ecom_mode => "link",
475 ecom_data_locator_key => "rpc",
476 // new attributes/properties/arguments that control further / trigger different DataFlow:
477 // FIXME: add these to declaration at top!
478 ecom_call_method => "selectSource",
479 ecom_call_args => $_in[ecom_data_source_key]
480 );
481
482 }
483 '),
484
485
486 /*
487 // translate value of argument "action" (olist => list.view, oedit => item.edit)
488 // action dispatcher
489 create_function('&$_in, &$_out', '
490 $_out = $_in;
491 switch ($_out[action]) {
492 case "olist":
493 $_out[action] = "list.view";
494 break;
495 case "oedit":
496 $_out[action] = "item.edit";
497 break;
498 case "":
499 print "ExplorerController: selecting default action \"list.view\" in rule #2.<br/>";
500 $_out[options][action] = "list.view";
501 return;
502 break;
503 }
504 //return "last";
505 '),
506
507
508 // dummy rule - just returns
509 create_function('&$_in, &$_out', '
510 return;
511 if ($_in[topic] == "DataBrowser.item.edit" || $_in[page] == "oedit") {
512 $_out[view] = "Page::DataBrowser";
513 $_out[options] = array( caption_context => "Item - [edit]", args => array(HTML, "UB_ITEM"));
514 }
515 '),
516 */
517
518
519 // tracing-rule - dumps $_in and $_out
520 /*
521 create_function('&$_in, &$_out', '
522 print "I am here: AnyMVC<br/>";
523 print "in: " . Dumper($_in);
524 print "out: " . Dumper($_out);
525 //exit;
526 return;
527 '),
528 */
529 ),
530 ));
531
532 }
533
534
535 }
536
537 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed