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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations)
Sat Apr 5 20:32:04 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.9: +46 -4 lines
added Chooser

1 jonen 1.1 <?
2     /*
3     ## -----------------------------------------------------------------------------
4 joko 1.10 ## $Id: AbstractExplorer.php,v 1.9 2003/04/04 02:22:37 joko Exp $
5 jonen 1.1 ## -----------------------------------------------------------------------------
6     ## $Log: AbstractExplorer.php,v $
7 joko 1.10 ## Revision 1.9 2003/04/04 02:22:37 joko
8     ## minor fix: querySchema now issues argument
9     ##
10 joko 1.9 ## Revision 1.8 2003/04/04 01:16:03 jonen
11     ## + integrated different mode's for 'DataItem'
12     ##
13 jonen 1.8 ## Revision 1.7 2003/03/29 07:49:55 joko
14     ## show boxes in DEBUG-mode only!
15     ##
16 joko 1.7 ## Revision 1.6 2003/03/28 06:42:37 joko
17     ## fix: propagating rpc-debugging-options to constants here
18     ##
19 joko 1.6 ## Revision 1.5 2003/03/27 01:24:29 jonen
20     ## + enabled navigation ecom (only list yet)
21     ##
22 jonen 1.5 ## Revision 1.4 2003/03/20 08:02:11 jonen
23     ## + purged code
24     ##
25 jonen 1.4 ## Revision 1.3 2003/03/20 07:54:52 jonen
26     ## + added docu
27     ##
28 jonen 1.3 ## Revision 1.2 2003/03/20 07:44:31 jonen
29     ## + removed dumper
30     ##
31 jonen 1.2 ## Revision 1.1 2003/03/20 03:48:46 jonen
32     ## + initial commit
33     ##
34 jonen 1.1 ## Revision 1.1 2003/03/08 02:36:17 cvsmax
35     ## + moved from *.inc
36     ## + mungled namespace with WebExplorer
37     ##
38     ## Revision 1.3 2003/03/03 22:25:21 joko
39     ## fixed minor typos
40     ## namespace mungling
41     ##
42     ## Revision 1.2 2003/03/02 00:48:49 cvsmax
43     ## + set up gui module registry
44     ## - purged old/sample code
45     ##
46     ## Revision 1.1 2003/03/01 22:57:32 cvsmax
47     ## + inital commit
48     ##
49     ##
50     ## -----------------------------------------------------------------------------
51     */
52 jonen 1.3
53     /**
54     * WebExplorer::AbstractExplorer - this can be simple compared to a container,
55     * which modular GUI classes can be register, manipulated and rendered...
56     *
57     * @author Sebastian Utz <seut@tunemedia.de>
58     * @package org.netfrag.app
59     * @name WebExplorer::AbstractExplorer
60     */
61 jonen 1.1
62    
63     class WebExplorer_AbstractExplorer {
64    
65     /**
66     * container holds meta information of data locators
67     */
68     var $_data_locators = array();
69    
70     /**
71     * container for registered modules
72     */
73     var $_module = array();
74    
75     /**
76     * container holds references to each ecom
77     */
78     var $_ecom = array();
79    
80     /**
81     * holds the whole page state
82     */
83     var $_state = array();
84    
85     /**
86     * holds state variables only needed for explorer
87     */
88     var $_e_state = array();
89    
90    
91     function WebExplorer_AbstractExplorer($data_locators=array()) {
92     $this->_data_locators = $data_locators;
93     $this->init_default_gui_modules();
94    
95     $this->set_e_state();
96 jonen 1.2 //print "State: " . Dumper($this->_state) ."<br>";
97 joko 1.6 $div = html_div();
98     $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
99     $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
100 joko 1.7 if (constants::get('DEBUG')) {
101     print $div->render();
102     }
103 jonen 1.1 //$this->init_state();
104     }
105    
106    
107     function add_data_locator($label, $args) {
108     $this->_data_locators[$label] = $args;
109     }
110    
111     function set_data_locator($label, $new_args=array() ) {
112     global $app;
113     //print Dumper($app) . "<br>";
114     if($label == "rpc") {
115     $rpcinfo = $app->getConfig("rpcinfo");
116     define('RPC_HOSTNAME', $rpcinfo[Host]);
117     define('RPC_PORT', $rpcinfo[Port]);
118 joko 1.6 define('RPC_DEBUG', $rpcinfo[DEBUG]);
119     define('RPC_TRACE', $rpcinfo[TRACE]);
120     define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
121 jonen 1.1 } else {
122     user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");
123     }
124     }
125    
126     function get_data_locator($label) {
127     }
128    
129     function get_page_state() {
130     $requestTracker = mkObject("Application::Request::Tracker");
131     $this->_state = $requestTracker->getPointer();
132     }
133    
134     function set_e_state() {
135     $this->get_page_state();
136     $this->_e_state = $this->_state[options][options];
137     }
138    
139    
140     function set_page_state() {
141     user_error("AbstractExplorer::set_page_state - please implement me....");
142     }
143    
144    
145     function init_default_gui_modules() {
146     //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
147 jonen 1.5 $this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") );
148 jonen 1.1 $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );
149     $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );
150 joko 1.10 // 2003-04-05 - Chooser
151     $this->register_gui_module("list", "chooser", array( 'name' => "WebExplorer::Module::Chooser", 'type' => "list") );
152 jonen 1.1 }
153    
154     function register_source_module($label, $args) {
155     $this->_module['source'][$label] = $args;
156     }
157    
158     function register_gui_module($abstract_type, $ecom_type, $args) {
159     $this->_module['gui'][$ecom_type][$abstract_type] = $args;
160     }
161    
162     function &get_ecom($label) {
163     //return "Hello World";
164     $this->_load_ecom($label);
165     return $this->_ecom[$label];
166     }
167    
168     function _load_ecoms() {
169 joko 1.10 //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
170 jonen 1.1 foreach($this->_e_state[ecoms] as $label => $val) {
171     $this->_load_ecom($label);
172     }
173     }
174    
175     function _load_ecom($label) {
176 joko 1.10
177 jonen 1.1 $val = $this->_e_state['ecoms'][$label];
178 joko 1.10 debug::info("_load_ecom: " . Dumper($val) . "<br/>");
179 jonen 1.1 // find right gui module
180     $com_type = $val['ecom_type'];
181     $abstract_type = $val['ecom_abstract_type'];
182     $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];
183     if(!$gui_module) {
184 joko 1.10 user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
185 jonen 1.1 return;
186     }
187     // get arguments needed for gui module
188     $args = $this->_prepare_component_args($label);
189     //print Dumper($args);
190    
191     // get GUI module
192     $ecom = php::mkComponent($gui_module, $args);
193     //print Dumper($ecom);
194    
195     // get phphtmllib GUI object
196     $gui_ecom = &$ecom->get();
197    
198     // add hidden vars, needed for explorer control
199     $hidden_items = $this->_get_hidden_items($label);
200 jonen 1.8 if(is_array($hidden_items) ) {
201     $ecom->add_hidden_items($hidden_items);
202     //print "Hidden: " . Dumper($hidden_items);
203     }
204 jonen 1.1
205     $this->_ecom[$label] = &$gui_ecom;
206     }
207    
208     function _get_hidden_items($label) {
209     $ecom_state = $this->_e_state['ecoms'][$label];
210 jonen 1.5 if($ecom_state['ecom_type'] == "data") {
211     if($ecom_state['ecom_abstract_type'] == "list") {
212     $hidden_items = array(
213 jonen 1.1 'ecl' => $label,
214 jonen 1.8 'ecat' => "item",
215     'ecmod' => "view",
216 jonen 1.1 );
217 jonen 1.5 }
218 jonen 1.8 elseif($ecom_state['ecom_abstract_type'] == "item") {
219     $hidden_items = array(
220     'ecl' => $label,
221     'ecat' => "item",
222     'ecmod' => "view",
223     );
224     /*
225     if($ecom_state['ecom_mode'] == "view") {
226     $hidden_items['ecmod'] = "edit";
227     }
228     elseif($ecom_state['ecom_mode'] == "edit") {
229     $hidden_items['ecmod'] = "edit";
230     }
231     */
232     }
233 jonen 1.5 $hidden_items['ap'] = "explorer";
234 jonen 1.1 }
235     return $hidden_items;
236     }
237    
238     function _prepare_component_args($label) {
239     $val = $this->_e_state['ecoms'][$label];
240     $this->set_data_locator($val['ecom_data_locator_key']);
241 joko 1.10
242     // detect and execute 'selectSource' action
243     // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
244     //print Dumper($this->_e_state['sources']);
245     if ($source = $this->_e_state['main']['ecom_data_source_key']) {
246     //print "selectSource: $source<br/>";
247     //global $app;
248     //print Dumper($backend);
249     //$app->backend->do();
250     }
251    
252 jonen 1.5 // switch component type
253     if($val['ecom_type'] == "data") {
254     // switch abstract type
255     if($val['ecom_abstract_type'] == "list") {
256     if($val['ecom_data_locator_key'] == "rpc") {
257     //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
258     $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
259     } else {
260     user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
261     }
262     $args = array(
263 jonen 1.1 'caption' => "Liste",
264     'orderby' => "Guid",
265     'options' => array(
266     'data_locator_meta' => $data_locator_meta,
267     'decode' => 1,
268     'decode_args' => array(
269     'seperator' => "_",
270     'form' => 1,
271     ),
272     ),
273     );
274 jonen 1.5 // switch abstract type
275     } elseif ($val['ecom_abstract_type'] == "item") {
276 jonen 1.8 if($val['ecom_data_locator_key'] == "rpc") {
277     //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
278     $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);
279     } else {
280     user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
281     }
282     if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
283     print "Mode: $val[ecom_mode]<br>";
284     $args = array(
285     'caption' => "Item",
286     'mode' => $val['ecom_mode'],
287     'options' => array(
288     'data_locator_meta' => $data_locator_meta,
289     'decode' => 1,
290     'decode_args' => array(
291     'seperator' => "_",
292     ),
293     ),
294     );
295     if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
296 jonen 1.5 }
297 joko 1.10
298 jonen 1.5 // switch component type
299     } elseif ($val['ecom_type'] == "nav") {
300     // switch abstract type
301     if($val['ecom_abstract_type'] == "list") {
302     if($val['ecom_data_locator_key'] == "rpc") {
303 joko 1.10 $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
304 jonen 1.5 } else {
305 joko 1.10 user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
306 jonen 1.5 }
307     $args = array(
308     'caption' => "Objekt Typen",
309     'options' => array(
310     'data_locator_meta' => $data_locator_meta,
311     ),
312     );
313     } elseif ($val['ecom_abstract_type'] == "tree") {
314     $args = array();
315     }
316 joko 1.10
317     // switch component type
318     // NEW [2003-04-05]: DataSource.Chooser
319     } elseif ($val['ecom_type'] == "chooser") {
320    
321     // switch abstract type
322     if($val['ecom_abstract_type'] == "list") {
323     if ($val['ecom_data_locator_key'] == "rpc") {
324     $data_locator_meta = array( datasource => 'rpc', metatype => 'schema', filter => 'sources.all' );
325     } else {
326     user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
327     }
328     $args = array(
329     'caption' => "Datenquellen",
330     'options' => array(
331     'data_locator_meta' => $data_locator_meta,
332     ),
333     );
334     } elseif ($val['ecom_abstract_type'] == "tree") {
335     $args = array();
336     }
337    
338 jonen 1.1 }
339     return $args;
340     }
341    
342     function get_msg($label) {
343     if($label == "welcome") {
344     $msg = "Welcome to the Explorer.";
345     }
346     return $msg;
347     }
348    
349     function render() {
350     user_error("AbstractExplorer::render - please implement me....");
351     }
352    
353     }
354    
355    
356     ?>

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