/[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.17 - (show annotations)
Wed Jun 25 23:45:05 2003 UTC (21 years, 2 months ago) by joko
Branch: MAIN
Changes since 1.16: +17 -8 lines
trying to switch from "ap" completely to "t"

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

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