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