/[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.9 - (show annotations)
Wed Apr 9 00:05:50 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.8: +28 -2 lines
added request values and functions needed for extended form handling

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

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