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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Sun Apr 6 01:32:57 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.5: +9 -3 lines
+ minor changes

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

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