/[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.3 - (show annotations)
Fri Apr 4 01:28:13 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.2: +25 -7 lines
+ added function to purge unwanted merged vars
+ handle form submit's now

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

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