/[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.11 - (hide annotations)
Fri Apr 11 00:51:10 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.10: +8 -1 lines
minor update: just testing stuff...

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

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