/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/MVC.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.app/WebExplorer/MVC.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Thu Mar 20 07:54:52 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.1: +14 -1 lines
+ added docu

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

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