/[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.15 - (show annotations)
Sat May 10 18:19:55 2003 UTC (21 years, 3 months ago) by jonen
Branch: MAIN
Changes since 1.14: +36 -13 lines
+ added stuff relating to 'create/add new' links/buttons

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

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