| 4 |
* $Id$ |
* $Id$ |
| 5 |
* |
* |
| 6 |
* $Log$ |
* $Log$ |
| 7 |
|
* Revision 1.6 2003/04/06 01:32:57 jonen |
| 8 |
|
* + minor changes |
| 9 |
|
* |
| 10 |
|
* Revision 1.5 2003/04/05 21:18:29 joko |
| 11 |
|
* added Chooser and associated 'ecds'-parameter |
| 12 |
|
* new rule (at bottom) to dispatch datasource-keys to each ecom-component |
| 13 |
|
* |
| 14 |
|
* Revision 1.4 2003/04/04 23:59:19 jonen |
| 15 |
|
* + minor changes according to data form submits |
| 16 |
|
* |
| 17 |
|
* Revision 1.3 2003/04/04 01:28:13 jonen |
| 18 |
|
* + added function to purge unwanted merged vars |
| 19 |
|
* + handle form submit's now |
| 20 |
|
* |
| 21 |
|
* Revision 1.2 2003/03/20 07:54:52 jonen |
| 22 |
|
* + added docu |
| 23 |
|
* |
| 24 |
* Revision 1.1 2003/03/20 03:48:47 jonen |
* Revision 1.1 2003/03/20 03:48:47 jonen |
| 25 |
* + initial commit |
* + initial commit |
| 26 |
* |
* |
| 39 |
* |
* |
| 40 |
* |
* |
| 41 |
*/ |
*/ |
| 42 |
|
|
| 43 |
|
/** |
| 44 |
|
* WebExplorer::MVC - this the MVC used by the WebExplorer. |
| 45 |
|
* Its derived from the 'Site::WebAppMVC' module. |
| 46 |
|
* |
| 47 |
|
* @author Sebastian Utz <seut@tunemedia.de> |
| 48 |
|
* @package org.netfrag.app |
| 49 |
|
* @name WebExplorer::MVC |
| 50 |
|
*/ |
| 51 |
|
|
| 52 |
loadModule('Site::WebAppMVC'); |
loadModule('Site::WebAppMVC'); |
| 53 |
|
|
| 54 |
class WebExplorer_MVC extends Site_WebAppMVC { |
class WebExplorer_MVC extends Site_WebAppMVC { |
| 78 |
|
|
| 79 |
$this->add_model( array( |
$this->add_model( array( |
| 80 |
//args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ), |
//args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ), |
| 81 |
request_args => array( 'ap', 'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_action', 'ecom_data_locator_key', |
request_args => array( |
| 82 |
'ecom_data_ident', 'ecom_data_meta' ), |
// ApplicationPage |
| 83 |
|
'ap', |
| 84 |
|
// important/required parameters for valid ecom-components |
| 85 |
|
'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_mode', |
| 86 |
|
// parameters about data identifiers, locations, sources and associated meta-information |
| 87 |
|
'ecom_data_locator_key', |
| 88 |
|
'ecom_data_ident', |
| 89 |
|
'ecom_data_meta', |
| 90 |
|
'ecom_data_form_edit', 'ecom_data_form_cancel', |
| 91 |
|
'ecom_data_source_key' |
| 92 |
|
), |
| 93 |
request_arg => array( |
request_arg => array( |
| 94 |
'ap' => array( query_arg => 'ap' ), |
'ap' => array( query_arg => 'ap' ), |
| 95 |
'ecom_label' => array( query_arg => 'ecl' ), |
'ecom_label' => array( query_arg => 'ecl' ), |
| 96 |
'ecom_type' => array( query_arg => 'ect' ), |
'ecom_type' => array( query_arg => 'ect' ), |
| 97 |
'ecom_abstract_type' => array( query_arg => 'ecat' ), |
'ecom_abstract_type' => array( query_arg => 'ecat' ), |
| 98 |
'ecom_action' => array( query_arg => 'ecac' ), |
'ecom_mode' => array( query_arg => 'ecmod' ), |
| 99 |
'ecom_data_locator_key' => array( query_arg => 'ecdlk' ), |
'ecom_data_locator_key' => array( query_arg => 'ecdlk' ), |
| 100 |
'ecom_data_ident' => array( query_arg => 'ecdid' ), |
'ecom_data_ident' => array( query_arg => 'ecdid' ), |
| 101 |
'ecom_data_meta' => array( query_arg => 'ecdm' ), |
'ecom_data_meta' => array( query_arg => 'ecdm' ), |
| 102 |
|
'ecom_data_form_edit' => array( query_arg => 'ecdfe' ), |
| 103 |
|
'ecom_data_form_cancel' => array( query_arg => 'ecdfc' ), |
| 104 |
|
'ecom_data_source_key' => array( query_arg => 'ecds' ), |
| 105 |
), |
), |
| 106 |
|
|
| 107 |
/* |
/* |
| 145 |
// COID => '123', |
// COID => '123', |
| 146 |
caption => "Explorer - ExplorerDataItem", |
caption => "Explorer - ExplorerDataItem", |
| 147 |
)); |
)); |
| 148 |
|
|
| 149 |
// FIXME!!! enhance!?!? |
// FIXME!!! enhance!?!? |
| 150 |
// AIM: "dispatch a Request to a View by using rules..." |
// AIM: "dispatch a Request to a View by using rules..." |
| 151 |
// Todo: |
// Todo: |
| 154 |
// Enhance this backend and introduce a mechanism to trigger |
// Enhance this backend and introduce a mechanism to trigger |
| 155 |
// 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. |
| 156 |
$this->add_controller( array( |
$this->add_controller( array( |
| 157 |
|
|
| 158 |
// 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 |
| 159 |
module => 'Application::Request::HttpController', |
module => 'Application::Request::HttpController', |
| 160 |
|
//module_options => blah |
| 161 |
|
|
| 162 |
rules => array( |
rules => array( |
| 163 |
|
|
| 164 |
// get last page state |
// get last page state |
| 165 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
| 166 |
$requestTracker = mkObject("Application::Request::Tracker"); |
$requestTracker = mkObject("Application::Request::Tracker"); |
| 167 |
$page_state = $requestTracker->getPointer(); |
$page_state = $requestTracker->getPointer(); |
| 168 |
$_out = $page_state[options]; |
$pre_out = $page_state[options]; |
| 169 |
|
//print Dumper($pre_out); |
| 170 |
|
// clean-up unwanted variables |
| 171 |
|
$label = $_in[ecom_label]; |
| 172 |
|
switch ($_in[ecom_abstract_type]) { |
| 173 |
|
case "list": |
| 174 |
|
if($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); } |
| 175 |
|
break; |
| 176 |
|
} |
| 177 |
|
$_out = $pre_out; |
| 178 |
'), |
'), |
| 179 |
|
|
| 180 |
// rewrite idents |
// rewrite idents |
| 186 |
'), |
'), |
| 187 |
|
|
| 188 |
// check right $_GET[ap] |
// check right $_GET[ap] |
| 189 |
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;'), |
| 190 |
|
|
| 191 |
// write components variables to out |
// write components variables to out |
| 192 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
| 193 |
$vars = array( ecom_type, ecom_abstract_type, ecom_action, ecom_data_locator_key, ecom_data_ident, ecom_data_meta ); |
$vars = array( ecom_type, ecom_abstract_type, ecom_mode, ecom_data_locator_key, ecom_data_ident, ecom_data_meta ); |
| 194 |
if($_in[ecom_label]) { |
if($_in[ecom_label]) { |
| 195 |
foreach($vars as $key) { |
foreach($vars as $key) { |
| 196 |
if($_in[$key]) { |
if($_in[$key]) { |
| 203 |
return; |
return; |
| 204 |
'), |
'), |
| 205 |
|
|
| 206 |
// create default ecoms (navigation, etc.) |
// create default ecoms (navigation, chooser [as of 2003-04-05] etc.) |
| 207 |
create_function('&$_in, &$_out', ' |
create_function('&$_in, &$_out', ' |
| 208 |
if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) { |
if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) { |
| 209 |
$_out[options][ecoms] = array( |
$_out[options][ecoms] = array( |
| 210 |
nav => array( |
nav => array( |
| 211 |
ecom_type => "nav", |
ecom_type => "nav", |
| 212 |
ecom_abstract_type => "list", |
ecom_abstract_type => "list", |
| 213 |
ecom_action => "nav", |
ecom_mode => "nav", |
| 214 |
|
ecom_data_locator_key => "rpc", |
| 215 |
|
), |
| 216 |
|
chooser => array( |
| 217 |
|
ecom_type => "chooser", |
| 218 |
|
ecom_abstract_type => "list", |
| 219 |
|
ecom_mode => "nav", |
| 220 |
ecom_data_locator_key => "rpc", |
ecom_data_locator_key => "rpc", |
| 221 |
), |
), |
| 222 |
); |
); |
| 225 |
return; |
return; |
| 226 |
'), |
'), |
| 227 |
|
|
| 228 |
|
// handle data form buttons |
| 229 |
|
create_function('&$_in, &$_out', ' |
| 230 |
|
$label = $_in[ecom_label]; |
| 231 |
|
if($_in[ecom_data_form_edit]) { $_out[options][ecoms][$label][ecom_mode] = "edit"; } |
| 232 |
|
if($_in[ecom_data_form_cancel]) { $_out[options][ecoms][$label][ecom_mode] = "view"; } |
| 233 |
|
'), |
| 234 |
|
|
| 235 |
|
// propagate datasources to ecoms |
| 236 |
|
// datasource-change requested? enhance logic here! |
| 237 |
|
// by now each ecom-component gets injected the very same |
| 238 |
|
// datasource if requested - otherwise everything will fall back to defaults |
| 239 |
|
create_function('&$_in, &$_out', ' |
| 240 |
|
if ($_in[ecom_data_source_key]) { |
| 241 |
|
//print Dumper($_out[options][ecoms]); |
| 242 |
|
//print "ds: " . $_in[ecom_data_source_key] . "<br/>"; |
| 243 |
|
/* |
| 244 |
|
foreach ($_out[options][ecoms] as $name => $ecom) { |
| 245 |
|
print "name: $name<br/>"; |
| 246 |
|
//$_out[options][sources][selected] = $_in[ecom_data_source]; |
| 247 |
|
$_out[options][ecoms][$name][ecom_data_source_key] = $_in[ecom_data_source_key]; |
| 248 |
|
} |
| 249 |
|
*/ |
| 250 |
|
$_out[options][main][ecom_data_source_key] = $_in[ecom_data_source_key]; |
| 251 |
|
} |
| 252 |
|
'), |
| 253 |
|
|
| 254 |
|
|
| 255 |
/* |
/* |
| 256 |
// translate value of argument "action" (olist => list.view, oedit => item.edit) |
// translate value of argument "action" (olist => list.view, oedit => item.edit) |
| 257 |
// action dispatcher |
// action dispatcher |