/[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.12 - (hide annotations)
Fri Apr 18 13:40:54 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.11: +11 -1 lines
+ added 'topic' to requested vars which will currently be merged with the 'ap' var

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

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