/[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.16 - (show annotations)
Tue May 13 14:53:56 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.15: +8 -1 lines
reset mvc-params "filter" and "meta" in tree mode!?

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

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