/[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.5 - (hide annotations)
Sat Apr 5 21:18:29 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.4: +45 -5 lines
added Chooser and associated 'ecds'-parameter
new rule (at bottom) to dispatch datasource-keys to each ecom-component

1 jonen 1.1 <?php
2    
3     /**
4 joko 1.5 * $Id: MVC.php,v 1.4 2003/04/04 23:59:19 jonen Exp $
5 jonen 1.1 *
6     * $Log: MVC.php,v $
7 joko 1.5 * Revision 1.4 2003/04/04 23:59:19 jonen
8     * + minor changes according to data form submits
9     *
10 jonen 1.4 * Revision 1.3 2003/04/04 01:28:13 jonen
11     * + added function to purge unwanted merged vars
12     * + handle form submit's now
13     *
14 jonen 1.3 * Revision 1.2 2003/03/20 07:54:52 jonen
15     * + added docu
16     *
17 jonen 1.2 * Revision 1.1 2003/03/20 03:48:47 jonen
18     * + initial commit
19     *
20 jonen 1.1 * Revision 1.2 2003/03/18 00:00:20 cvsmax
21     * + added thoughts and models for preparing control data to Explorer
22     *
23     * Revision 1.1 2003/03/08 02:36:39 cvsmax
24     * + moved from *.inc
25     * + mungled namespace with WebExplorer
26     *
27     * Revision 1.1 2003/03/03 22:26:16 joko
28     * + initial commit, inherits from WebMVC
29     *
30     * Revision 1.1 2003/03/02 00:49:36 joko
31     * + initial commit
32     *
33     *
34     */
35 jonen 1.2
36     /**
37     * WebExplorer::MVC - this the MVC used by the WebExplorer.
38     * Its derived from the 'Site::WebAppMVC' module.
39     *
40     * @author Sebastian Utz <seut@tunemedia.de>
41     * @package org.netfrag.app
42     * @name WebExplorer::MVC
43     */
44    
45 jonen 1.1 loadModule('Site::WebAppMVC');
46    
47     class WebExplorer_MVC extends Site_WebAppMVC {
48    
49     //var $_backend = null;
50     var $_raw = array();
51     var $_registry = array();
52    
53     function WebExplorer_MVC(&$args) {
54    
55     parent::constructor();
56    
57     // new!!! a registry for Views!!!
58     //$regdb = $this->getStaticRegistryDatabase();
59     //$this->_registry = mkObject('Application::ComponentRegistry', &$regdb, 'REGDB_PAYLOAD');
60    
61     // new!!! storing the raw request here
62     $this->_raw[request] = &$args[request];
63    
64     // new!!! user_setup, phpHtmlLib-style...
65     $this->user_setup();
66    
67     }
68    
69     // setup MVC (model-view-controller) metadata information
70     function user_setup() {
71    
72     $this->add_model( array(
73     //args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ),
74 joko 1.5 request_args => array(
75     // ApplicationPage
76     'ap',
77     // important/required parameters for valid ecom-components
78     'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_mode',
79     // parameters about data identifiers, locations, sources and associated meta-information
80     'ecom_data_locator_key',
81     'ecom_data_ident',
82     'ecom_data_meta',
83     'ecom_data_form_edit', 'ecom_data_form_cancel',
84     'ecom_data_source_key'
85     ),
86 jonen 1.1 request_arg => array(
87     'ap' => array( query_arg => 'ap' ),
88     'ecom_label' => array( query_arg => 'ecl' ),
89     'ecom_type' => array( query_arg => 'ect' ),
90     'ecom_abstract_type' => array( query_arg => 'ecat' ),
91 jonen 1.3 'ecom_mode' => array( query_arg => 'ecmod' ),
92 jonen 1.1 'ecom_data_locator_key' => array( query_arg => 'ecdlk' ),
93     'ecom_data_ident' => array( query_arg => 'ecdid' ),
94     'ecom_data_meta' => array( query_arg => 'ecdm' ),
95 jonen 1.4 'ecom_data_form_edit' => array( query_arg => 'ecdfe' ),
96     'ecom_data_form_cancel' => array( query_arg => 'ecdfc' ),
97 joko 1.5 'ecom_data_source_key' => array( query_arg => 'ecds' ),
98 jonen 1.1 ),
99    
100     /*
101     // block model (what is used for each block)
102     block => array(
103     'ident' => array( query_arg => 'ident' ),
104     'meta' => array( query_arg => 'meta' ),
105     'action' => array( query_arg => 'action'),
106     'data_locator_key' => array( query_arg => 'dlk' ),
107     'gui_module' => array( query_arg => 'gm' ),
108     'abstract_type' => array( query_arg => 'at' ),
109     ),
110     */
111    
112     ));
113    
114     //$this->setup_views( &$this->_registry );
115    
116     // associate behaviour with "View"-components
117     // identify component by: module name or component identifier (COID)
118     // 'name' is looked up in that to get metadata information about the comp.
119     // component: for 'component = 1', a component registry is required!!!
120     // name: registry-lookup: by-name
121     // COID: registry-lookup: by-COID
122     // caption: caption of area or title of page
123     $this->add_view( array(
124     component => 1,
125     name => 'NavigationList',
126     // COID => '123',
127     caption => "Explorer - NavigationList",
128     ));
129     $this->add_view( array(
130     component => 1,
131     name => 'ExplorerDataList',
132     // COID => '123',
133     caption => "Explorer - ExplorerDataList",
134     ));
135     $this->add_view( array(
136     component => 1,
137     name => 'ExplorerDataItem',
138     // COID => '123',
139     caption => "Explorer - ExplorerDataItem",
140     ));
141    
142     // FIXME!!! enhance!?!?
143     // AIM: "dispatch a Request to a View by using rules..."
144     // Todo:
145     // 'HttpController' is *very* dumb by now, it just iterates
146     // this flat list below triggering the lambdas with their arguments.
147     // Enhance this backend and introduce a mechanism to trigger
148     // a true callback to process a rule (or: "as a rule") on top of that.
149     $this->add_controller( array(
150 joko 1.5
151 jonen 1.1 // for "module", no component registry is required, just does 'mkObject' under the hood
152     module => 'Application::Request::HttpController',
153     rules => array(
154    
155     // get last page state
156     create_function('&$_in, &$_out', '
157     $requestTracker = mkObject("Application::Request::Tracker");
158     $page_state = $requestTracker->getPointer();
159 jonen 1.3 $pre_out = $page_state[options];
160     //print Dumper($pre_out);
161     // clean-up unwanted variables
162     $label = $_in[ecom_label];
163     switch ($_in[ecom_abstract_type]) {
164     case "list":
165     if($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); }
166     break;
167     }
168     $_out = $pre_out;
169 jonen 1.1 '),
170    
171     // rewrite idents
172     create_function('&$_in, &$_out', '
173     $idents = array ( ap, );
174     foreach($idents as $key) {
175     $_out[options][idents][$key] = $_in[$key];
176     }
177     '),
178    
179     // check right $_GET[ap]
180     create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value $_in[ap], sure this is right here?" : null;'),
181    
182     // write components variables to out
183     create_function('&$_in, &$_out', '
184 jonen 1.3 $vars = array( ecom_type, ecom_abstract_type, ecom_mode, ecom_data_locator_key, ecom_data_ident, ecom_data_meta );
185 jonen 1.1 if($_in[ecom_label]) {
186     foreach($vars as $key) {
187     if($_in[$key]) {
188     $label = $_in[ecom_label];
189     $_out[options][ecoms][$label][$key] = $_in[$key];
190     }
191     }
192     }
193    
194     return;
195     '),
196    
197 joko 1.5 // create default ecoms (navigation, chooser [as of 2003-04-05] etc.)
198 jonen 1.1 create_function('&$_in, &$_out', '
199     if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) {
200     $_out[options][ecoms] = array(
201     nav => array(
202     ecom_type => "nav",
203     ecom_abstract_type => "list",
204 jonen 1.3 ecom_mode => "nav",
205 jonen 1.1 ecom_data_locator_key => "rpc",
206     ),
207 joko 1.5 chooser => array(
208     ecom_type => "chooser",
209     ecom_abstract_type => "list",
210     ecom_mode => "nav",
211     ecom_data_locator_key => "rpc",
212     ),
213 jonen 1.1 );
214     }
215     //$_out[options][components] = $_in[components];
216     return;
217     '),
218    
219 jonen 1.4 // handle data form buttons
220 jonen 1.3 create_function('&$_in, &$_out', '
221     $label = $_in[ecom_label];
222 jonen 1.4 if($_in[ecom_data_form_edit]) { $_out[options][ecoms][$label][ecom_mode] = "edit"; }
223     if($_in[ecom_data_form_cancel]) { $_out[options][ecoms][$label][ecom_mode] = "view"; }
224 jonen 1.3 '),
225 joko 1.5
226     // propagate datasources to ecoms
227     // datasource-change requested? enhance logic here!
228     // by now each ecom-component gets injected the very same
229     // datasource if requested - otherwise everything will fall back to defaults
230     create_function('&$_in, &$_out', '
231     if ($_in[ecom_data_source_key]) {
232     //print Dumper($_out[options][ecoms]);
233     //print "ds: " . $_in[ecom_data_source_key] . "<br/>";
234     /*
235     foreach ($_out[options][ecoms] as $name => $ecom) {
236     print "name: $name<br/>";
237     //$_out[options][sources][selected] = $_in[ecom_data_source];
238     $_out[options][ecoms][$name][ecom_data_source_key] = $_in[ecom_data_source_key];
239     }
240     */
241     $_out[options][main][ecom_data_source_key] = $_in[ecom_data_source_key];
242     }
243     '),
244    
245 jonen 1.4
246 jonen 1.1 /*
247     // translate value of argument "action" (olist => list.view, oedit => item.edit)
248     // action dispatcher
249     create_function('&$_in, &$_out', '
250     $_out = $_in;
251     switch ($_out[action]) {
252     case "olist":
253     $_out[action] = "list.view";
254     break;
255     case "oedit":
256     $_out[action] = "item.edit";
257     break;
258     case "":
259     print "ExplorerController: selecting default action \"list.view\" in rule #2.<br/>";
260     $_out[options][action] = "list.view";
261     return;
262     break;
263     }
264     //return "last";
265     '),
266    
267    
268     // dummy rule - just returns
269     create_function('&$_in, &$_out', '
270     return;
271     if ($_in[topic] == "DataBrowser.item.edit" || $_in[page] == "oedit") {
272     $_out[view] = "Page::DataBrowser";
273     $_out[options] = array( caption_context => "Item - [edit]", args => array(HTML, "UB_ITEM"));
274     }
275     '),
276     */
277    
278    
279     // tracing-rule - dumps $_in and $_out
280     /*
281     create_function('&$_in, &$_out', '
282     print "I am here: AnyMVC<br/>";
283     print "in: " . Dumper($_in);
284     print "out: " . Dumper($_out);
285     //exit;
286     return;
287     '),
288     */
289     ),
290     ));
291    
292     }
293    
294    
295     }
296    
297     ?>

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