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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations)
Sat Apr 19 16:20:47 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.13: +20 -1 lines
+ added handle of ecom 'UMnav' according to page 'Benutzverwaltung'

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

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