/[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.8 - (show annotations)
Tue Apr 8 17:53:08 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.7: +24 -1 lines
NEW: Module 'RemoteAction' in 'phase_startup'

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

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