| 4 |
* $Id$ |
* $Id$ |
| 5 |
* |
* |
| 6 |
* $Log$ |
* $Log$ |
| 7 |
|
* Revision 1.11 2003/04/11 00:51:10 joko |
| 8 |
|
* minor update: just testing stuff... |
| 9 |
|
* |
| 10 |
|
* Revision 1.10 2003/04/10 06:03:26 joko |
| 11 |
|
* ++ renamed keys: 'ecom_data_form_edit', 'ecom_data_form_cancel' through 'ecom_data_action_edit', 'ecom_data_action_cancel' |
| 12 |
|
* + new key: 'ecom_data_action_delete' |
| 13 |
|
* + Action.Delete: not really, since it's inside component in fact (self-contained ecom) |
| 14 |
|
* |
| 15 |
|
* Revision 1.9 2003/04/09 00:05:50 jonen |
| 16 |
|
* added request values and functions needed for extended form handling |
| 17 |
|
* |
| 18 |
|
* Revision 1.8 2003/04/08 17:53:08 joko |
| 19 |
|
* NEW: Module 'RemoteAction' in 'phase_startup' |
| 20 |
|
* |
| 21 |
|
* Revision 1.7 2003/04/07 22:32:27 jonen |
| 22 |
|
* + minor changes related to new ecom 'chooser' |
| 23 |
|
* |
| 24 |
|
* Revision 1.6 2003/04/06 01:32:57 jonen |
| 25 |
|
* + minor changes |
| 26 |
|
* |
| 27 |
|
* Revision 1.5 2003/04/05 21:18:29 joko |
| 28 |
|
* added Chooser and associated 'ecds'-parameter |
| 29 |
|
* new rule (at bottom) to dispatch datasource-keys to each ecom-component |
| 30 |
|
* |
| 31 |
|
* Revision 1.4 2003/04/04 23:59:19 jonen |
| 32 |
|
* + minor changes according to data form submits |
| 33 |
|
* |
| 34 |
|
* Revision 1.3 2003/04/04 01:28:13 jonen |
| 35 |
|
* + added function to purge unwanted merged vars |
| 36 |
|
* + handle form submit's now |
| 37 |
|
* |
| 38 |
|
* Revision 1.2 2003/03/20 07:54:52 jonen |
| 39 |
|
* + added docu |
| 40 |
|
* |
| 41 |
* Revision 1.1 2003/03/20 03:48:47 jonen |
* Revision 1.1 2003/03/20 03:48:47 jonen |
| 42 |
* + initial commit |
* + initial commit |
| 43 |
* |
* |
| 56 |
* |
* |
| 57 |
* |
* |
| 58 |
*/ |
*/ |
| 59 |
|
|
| 60 |
|
/** |
| 61 |
|
* WebExplorer::MVC - this the MVC used by the WebExplorer. |
| 62 |
|
* Its derived from the 'Site::WebAppMVC' module. |
| 63 |
|
* |
| 64 |
|
* @author Sebastian Utz <seut@tunemedia.de> |
| 65 |
|
* @package org.netfrag.app |
| 66 |
|
* @name WebExplorer::MVC |
| 67 |
|
*/ |
| 68 |
|
|
| 69 |
loadModule('Site::WebAppMVC'); |
loadModule('Site::WebAppMVC'); |
| 70 |
|
|
| 71 |
class WebExplorer_MVC extends Site_WebAppMVC { |
class WebExplorer_MVC extends Site_WebAppMVC { |
| 95 |
|
|
| 96 |
$this->add_model( array( |
$this->add_model( array( |
| 97 |
//args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ), |
//args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ), |
| 98 |
request_args => array( 'ap', 'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_action', 'ecom_data_locator_key', |
request_args => array( |
| 99 |
'ecom_data_ident', 'ecom_data_meta' ), |
// ApplicationPage |
| 100 |
|
'ap', |
| 101 |
|
// important/required parameters for valid ecom-components |
| 102 |
|
'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_mode', |
| 103 |
|
// parameters about data identifiers, locations, sources and associated meta-information |
| 104 |
|
'ecom_data_locator_key', |
| 105 |
|
'ecom_data_ident', |
| 106 |
|
'ecom_data_meta', |
| 107 |
|
'ecom_data_action_edit', 'ecom_data_action_cancel', 'ecom_data_action_delete', |
| 108 |
|
'ecom_data_form_checkbox', 'ecom_data_form_action', |
| 109 |
|
'ecom_data_source_key' |
| 110 |
|
), |
| 111 |
request_arg => array( |
request_arg => array( |
| 112 |
'ap' => array( query_arg => 'ap' ), |
'ap' => array( query_arg => 'ap' ), |
| 113 |
'ecom_label' => array( query_arg => 'ecl' ), |
'ecom_label' => array( query_arg => 'ecl' ), |
| 114 |
'ecom_type' => array( query_arg => 'ect' ), |
'ecom_type' => array( query_arg => 'ect' ), |
| 115 |
'ecom_abstract_type' => array( query_arg => 'ecat' ), |
'ecom_abstract_type' => array( query_arg => 'ecat' ), |
| 116 |
'ecom_action' => array( query_arg => 'ecac' ), |
'ecom_mode' => array( query_arg => 'ecmod' ), |
| 117 |
'ecom_data_locator_key' => array( query_arg => 'ecdlk' ), |
'ecom_data_locator_key' => array( query_arg => 'ecdlk' ), |
| 118 |
'ecom_data_ident' => array( query_arg => 'ecdid' ), |
'ecom_data_ident' => array( query_arg => 'ecdid' ), |
| 119 |
'ecom_data_meta' => array( query_arg => 'ecdm' ), |
'ecom_data_meta' => array( query_arg => 'ecdm' ), |
| 120 |
|
'ecom_data_action_edit' => array( query_arg => 'ecdfe' ), |
| 121 |
|
'ecom_data_action_cancel' => array( query_arg => 'ecdfc' ), |
| 122 |
|
'ecom_data_action_delete' => array( query_arg => 'ecdfd' ), |
| 123 |
|
'ecom_data_form_action' => array( query_arg => 'ecdfa' ), |
| 124 |
|
'ecom_data_form_checkbox' => array( query_arg => 'checkbox' ), |
| 125 |
|
'ecom_data_source_key' => array( query_arg => 'ecds' ), |
| 126 |
), |
), |
| 127 |
|
|
| 128 |
/* |
/* |
| 166 |
// COID => '123', |
// COID => '123', |
| 167 |
caption => "Explorer - ExplorerDataItem", |
caption => "Explorer - ExplorerDataItem", |
| 168 |
)); |
)); |
| 169 |
|
|
| 170 |
// FIXME!!! enhance!?!? |
// FIXME!!! enhance!?!? |
| 171 |
// AIM: "dispatch a Request to a View by using rules..." |
// AIM: "dispatch a Request to a View by using rules..." |
| 172 |
// Todo: |
// Todo: |
| 175 |
// Enhance this backend and introduce a mechanism to trigger |
// Enhance this backend and introduce a mechanism to trigger |
| 176 |
// a true callback to process a rule (or: "as a rule") on top of that. |
// a true callback to process a rule (or: "as a rule") on top of that. |
| 177 |
$this->add_controller( array( |
$this->add_controller( array( |
| 178 |
|
|
| 179 |
// for "module", no component registry is required, just does 'mkObject' under the hood |
// for "module", no component registry is required, just does 'mkObject' under the hood |
| 180 |
module => 'Application::Request::HttpController', |
module => 'Application::Request::HttpController', |
| 181 |
|
//module_options => blah |
| 182 |
|
|
| 183 |
rules => array( |
rules => array( |
| 184 |
|
|
| 185 |
// get last page state |
// get last page state |
| 186 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
| 187 |
$requestTracker = mkObject("Application::Request::Tracker"); |
$requestTracker = mkObject("Application::Request::Tracker"); |
| 188 |
$page_state = $requestTracker->getPointer(); |
$page_state = $requestTracker->getPointer(); |
| 189 |
$_out = $page_state[options]; |
$pre_out = $page_state[options]; |
| 190 |
|
//print Dumper($pre_out); |
| 191 |
|
// clean-up unwanted variables |
| 192 |
|
$label = $_in[ecom_label]; |
| 193 |
|
switch ($_in[ecom_abstract_type]) { |
| 194 |
|
case "list": |
| 195 |
|
if($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); } |
| 196 |
|
break; |
| 197 |
|
} |
| 198 |
|
$_out = $pre_out; |
| 199 |
|
'), |
| 200 |
|
|
| 201 |
|
// reset machine |
| 202 |
|
create_function('&$_in, &$_out', ' |
| 203 |
|
// HACK!!! |
| 204 |
|
// FIXME: review and implement in a more clean way? |
| 205 |
|
//print "RESET!<br/>"; |
| 206 |
|
|
| 207 |
|
$_out[options][ecoms][phase_startup] = "RESET"; |
| 208 |
'), |
'), |
| 209 |
|
|
| 210 |
// rewrite idents |
// rewrite idents |
| 216 |
'), |
'), |
| 217 |
|
|
| 218 |
// check right $_GET[ap] |
// check right $_GET[ap] |
| 219 |
create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value $_in[ap], sure this is right here?" : null;'), |
create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value: $_in[ap], sure this is right here?<br>" : null;'), |
| 220 |
|
|
| 221 |
// write components variables to out |
// write components variables to out |
| 222 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
| 223 |
$vars = array( ecom_type, ecom_abstract_type, ecom_action, ecom_data_locator_key, ecom_data_ident, ecom_data_meta ); |
$vars = array( |
| 224 |
|
ecom_type, ecom_abstract_type, ecom_mode, ecom_data_locator_key, ecom_data_ident, ecom_data_meta |
| 225 |
|
); |
| 226 |
|
// ecom_call_method, ecom_call_args |
| 227 |
if($_in[ecom_label]) { |
if($_in[ecom_label]) { |
| 228 |
foreach($vars as $key) { |
foreach($vars as $key) { |
| 229 |
if($_in[$key]) { |
if($_in[$key]) { |
| 236 |
return; |
return; |
| 237 |
'), |
'), |
| 238 |
|
|
| 239 |
// create default ecoms (navigation, etc.) |
// create default ecoms (navigation, chooser [as of 2003-04-05] etc.) |
| 240 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
| 241 |
if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) { |
if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) { |
| 242 |
$_out[options][ecoms] = array( |
$_out[options][ecoms] = array( |
| 243 |
nav => array( |
nav => array( |
| 244 |
ecom_type => "nav", |
ecom_type => "nav", |
| 245 |
ecom_abstract_type => "list", |
ecom_abstract_type => "list", |
| 246 |
ecom_action => "nav", |
ecom_mode => "link", |
| 247 |
|
ecom_data_locator_key => "rpc", |
| 248 |
|
), |
| 249 |
|
chooser => array( |
| 250 |
|
ecom_type => "nav", |
| 251 |
|
ecom_abstract_type => "list", |
| 252 |
|
ecom_mode => "link", |
| 253 |
ecom_data_locator_key => "rpc", |
ecom_data_locator_key => "rpc", |
| 254 |
), |
), |
| 255 |
); |
); |
| 258 |
return; |
return; |
| 259 |
'), |
'), |
| 260 |
|
|
| 261 |
|
|
| 262 |
|
// handle data form action(button) |
| 263 |
|
create_function('&$_in, &$_out', ' |
| 264 |
|
$label = $_in[ecom_label]; |
| 265 |
|
if($_in[ecom_data_form_action] && is_array($_in[ecom_data_form_checkbox])) { |
| 266 |
|
$cnt = sizeof($_in[ecom_data_form_checkbox]); |
| 267 |
|
if($cnt == 1) { |
| 268 |
|
foreach($_in[ecom_data_form_checkbox] as $ident) { |
| 269 |
|
$_out[options][ecoms][$label][ecom_data_ident] = $ident; |
| 270 |
|
} |
| 271 |
|
$_out[options][ecoms][$label][ecom_data_meta] = $_in[ecom_data_ident]; |
| 272 |
|
$_out[options][ecoms][$label][ecom_mode] = $_in[ecom_data_form_action]; |
| 273 |
|
$_out[options][ecoms][$label][ecom_abstract_type] = "item"; |
| 274 |
|
} else { |
| 275 |
|
// TODO: implement multi-selection actions on rows(items) here!! |
| 276 |
|
} |
| 277 |
|
} |
| 278 |
|
'), |
| 279 |
|
|
| 280 |
|
|
| 281 |
|
// handle data form buttons |
| 282 |
|
create_function('&$_in, &$_out', ' |
| 283 |
|
$label = $_in[ecom_label]; |
| 284 |
|
if($_in[ecom_data_action_edit]) { $_out[options][ecoms][$label][ecom_mode] = "edit"; } |
| 285 |
|
if($_in[ecom_data_action_cancel]) { $_out[options][ecoms][$label][ecom_mode] = "view"; } |
| 286 |
|
|
| 287 |
|
// Action.Delete [new of 2003-04-09] |
| 288 |
|
if ($_in[ecom_data_action_delete]) { |
| 289 |
|
|
| 290 |
|
//$_out[options][ecoms][content][ecom_mode] = "view"; |
| 291 |
|
|
| 292 |
|
// the code here vanished to the component itself! |
| 293 |
|
// could/should we do this for "edit" and/or "view" actions as well? |
| 294 |
|
// look at ecom/FlexibleDataItem! |
| 295 |
|
|
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
'), |
| 299 |
|
|
| 300 |
|
// propagate datasources to ecoms |
| 301 |
|
// datasource-change requested? enhance logic here! |
| 302 |
|
// by now each ecom-component gets injected the very same |
| 303 |
|
// datasource if requested - otherwise everything will fall back to defaults |
| 304 |
|
create_function('&$_in, &$_out', ' |
| 305 |
|
if ($_in[ecom_data_source_key]) { |
| 306 |
|
|
| 307 |
|
print "YAI: ecom_data_source_key<br/>"; |
| 308 |
|
|
| 309 |
|
//print Dumper($_out[options][ecoms]); |
| 310 |
|
//print "ds: " . $_in[ecom_data_source_key] . "<br/>"; |
| 311 |
|
/* |
| 312 |
|
foreach ($_out[options][ecoms] as $name => $ecom) { |
| 313 |
|
print "name: $name<br/>"; |
| 314 |
|
//$_out[options][sources][selected] = $_in[ecom_data_source]; |
| 315 |
|
$_out[options][ecoms][$name][ecom_data_source_key] = $_in[ecom_data_source_key]; |
| 316 |
|
} |
| 317 |
|
*/ |
| 318 |
|
$_out[options][main][ecom_data_source_key] = $_in[ecom_data_source_key]; |
| 319 |
|
|
| 320 |
|
|
| 321 |
|
// 2003-04-07 - enhanced |
| 322 |
|
// now activates a special ecom-component - a "RemoteAction" - replacing |
| 323 |
|
// the "content"-ecom instead of displaying an empty page / overriding any |
| 324 |
|
// view reached by "normal dispatching" |
| 325 |
|
|
| 326 |
|
$_out[options][ecoms][phase_startup] = array( |
| 327 |
|
ecom_type => "call", |
| 328 |
|
ecom_abstract_type => "auto", |
| 329 |
|
ecom_mode => "link", |
| 330 |
|
ecom_data_locator_key => "rpc", |
| 331 |
|
// new attributes/properties/arguments that control further / trigger different DataFlow: |
| 332 |
|
// FIXME: add these to declaration at top! |
| 333 |
|
ecom_call_method => "selectSource", |
| 334 |
|
ecom_call_args => $_in[ecom_data_source_key] |
| 335 |
|
); |
| 336 |
|
|
| 337 |
|
} |
| 338 |
|
'), |
| 339 |
|
|
| 340 |
|
|
| 341 |
/* |
/* |
| 342 |
// translate value of argument "action" (olist => list.view, oedit => item.edit) |
// translate value of argument "action" (olist => list.view, oedit => item.edit) |
| 343 |
// action dispatcher |
// action dispatcher |