/[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.13 - (hide annotations)
Fri Apr 18 15:30:24 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.12: +73 -21 lines
NEW: parameter 'ecom_data_filter' - used for 'items'
  (introduced to filter xml-payload at backend side via xpath queries)
documented global state parameters
some comments

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

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