/[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.7 - (hide annotations)
Sat Mar 29 07:49:55 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.6: +7 -2 lines
show boxes in DEBUG-mode only!

1 jonen 1.1 <?
2     /*
3     ## -----------------------------------------------------------------------------
4 joko 1.7 ## $Id: AbstractExplorer.php,v 1.6 2003/03/28 06:42:37 joko Exp $
5 jonen 1.1 ## -----------------------------------------------------------------------------
6     ## $Log: AbstractExplorer.php,v $
7 joko 1.7 ## Revision 1.6 2003/03/28 06:42:37 joko
8     ## fix: propagating rpc-debugging-options to constants here
9     ##
10 joko 1.6 ## Revision 1.5 2003/03/27 01:24:29 jonen
11     ## + enabled navigation ecom (only list yet)
12     ##
13 jonen 1.5 ## Revision 1.4 2003/03/20 08:02:11 jonen
14     ## + purged code
15     ##
16 jonen 1.4 ## Revision 1.3 2003/03/20 07:54:52 jonen
17     ## + added docu
18     ##
19 jonen 1.3 ## Revision 1.2 2003/03/20 07:44:31 jonen
20     ## + removed dumper
21     ##
22 jonen 1.2 ## Revision 1.1 2003/03/20 03:48:46 jonen
23     ## + initial commit
24     ##
25 jonen 1.1 ## Revision 1.1 2003/03/08 02:36:17 cvsmax
26     ## + moved from *.inc
27     ## + mungled namespace with WebExplorer
28     ##
29     ## Revision 1.3 2003/03/03 22:25:21 joko
30     ## fixed minor typos
31     ## namespace mungling
32     ##
33     ## Revision 1.2 2003/03/02 00:48:49 cvsmax
34     ## + set up gui module registry
35     ## - purged old/sample code
36     ##
37     ## Revision 1.1 2003/03/01 22:57:32 cvsmax
38     ## + inital commit
39     ##
40     ##
41     ## -----------------------------------------------------------------------------
42     */
43 jonen 1.3
44     /**
45     * WebExplorer::AbstractExplorer - this can be simple compared to a container,
46     * which modular GUI classes can be register, manipulated and rendered...
47     *
48     * @author Sebastian Utz <seut@tunemedia.de>
49     * @package org.netfrag.app
50     * @name WebExplorer::AbstractExplorer
51     */
52 jonen 1.1
53    
54     class WebExplorer_AbstractExplorer {
55    
56     /**
57     * container holds meta information of data locators
58     */
59     var $_data_locators = array();
60    
61     /**
62     * container for registered modules
63     */
64     var $_module = array();
65    
66     /**
67     * container holds references to each ecom
68     */
69     var $_ecom = array();
70    
71     /**
72     * holds the whole page state
73     */
74     var $_state = array();
75    
76     /**
77     * holds state variables only needed for explorer
78     */
79     var $_e_state = array();
80    
81    
82     function WebExplorer_AbstractExplorer($data_locators=array()) {
83     $this->_data_locators = $data_locators;
84     $this->init_default_gui_modules();
85    
86     $this->set_e_state();
87 jonen 1.2 //print "State: " . Dumper($this->_state) ."<br>";
88 joko 1.6 $div = html_div();
89     $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
90     $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
91 joko 1.7 if (constants::get('DEBUG')) {
92     print $div->render();
93     }
94 jonen 1.1 //$this->init_state();
95     }
96    
97    
98     function add_data_locator($label, $args) {
99     $this->_data_locators[$label] = $args;
100     }
101    
102     function set_data_locator($label, $new_args=array() ) {
103     global $app;
104     //print Dumper($app) . "<br>";
105     if($label == "rpc") {
106     $rpcinfo = $app->getConfig("rpcinfo");
107     define('RPC_HOSTNAME', $rpcinfo[Host]);
108     define('RPC_PORT', $rpcinfo[Port]);
109 joko 1.6 define('RPC_DEBUG', $rpcinfo[DEBUG]);
110     define('RPC_TRACE', $rpcinfo[TRACE]);
111     define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
112 jonen 1.1 } else {
113     user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");
114     }
115     }
116    
117     function get_data_locator($label) {
118     }
119    
120     function get_page_state() {
121     $requestTracker = mkObject("Application::Request::Tracker");
122     $this->_state = $requestTracker->getPointer();
123     }
124    
125     function set_e_state() {
126     $this->get_page_state();
127     $this->_e_state = $this->_state[options][options];
128     }
129    
130    
131     function set_page_state() {
132     user_error("AbstractExplorer::set_page_state - please implement me....");
133     }
134    
135    
136     function init_default_gui_modules() {
137     //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
138 jonen 1.5 $this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") );
139 jonen 1.1 $this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") );
140     $this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") );
141     }
142    
143     function register_source_module($label, $args) {
144     $this->_module['source'][$label] = $args;
145     }
146    
147     function register_gui_module($abstract_type, $ecom_type, $args) {
148     $this->_module['gui'][$ecom_type][$abstract_type] = $args;
149     }
150    
151     function &get_ecom($label) {
152     //return "Hello World";
153     $this->_load_ecom($label);
154     return $this->_ecom[$label];
155     }
156    
157     function _load_ecoms() {
158     foreach($this->_e_state[ecoms] as $label => $val) {
159     $this->_load_ecom($label);
160     }
161     }
162    
163     function _load_ecom($label) {
164     $val = $this->_e_state['ecoms'][$label];
165     // find right gui module
166     $com_type = $val['ecom_type'];
167     $abstract_type = $val['ecom_abstract_type'];
168     $gui_module = $this->_module['gui'][$com_type][$abstract_type]['name'];
169     if(!$gui_module) {
170     user_error("AbstractExplorer::_load_component - No GUI module found for abstract type $val[ecom_abstract_type] ecom type $val[ecom_type] !");
171     return;
172     }
173     // get arguments needed for gui module
174     $args = $this->_prepare_component_args($label);
175     //print Dumper($args);
176    
177     // get GUI module
178     $ecom = php::mkComponent($gui_module, $args);
179     //print Dumper($ecom);
180    
181     // get phphtmllib GUI object
182     $gui_ecom = &$ecom->get();
183    
184     // add hidden vars, needed for explorer control
185     $hidden_items = $this->_get_hidden_items($label);
186 jonen 1.5 if(is_array($hidden_items) ) { $ecom->add_hidden_items($hidden_items); }
187 jonen 1.1 //print "Hidden: " . Dumper($gui_ecom->_hidden_items);
188    
189     $this->_ecom[$label] = &$gui_ecom;
190     }
191    
192     function _get_hidden_items($label) {
193     $ecom_state = $this->_e_state['ecoms'][$label];
194 jonen 1.5 if($ecom_state['ecom_type'] == "data") {
195     if($ecom_state['ecom_abstract_type'] == "list") {
196     $hidden_items = array(
197 jonen 1.1 'ecl' => $label,
198     );
199 jonen 1.5 }
200     // set default hidden item for whole explorer
201     $hidden_items['ap'] = "explorer";
202 jonen 1.1 }
203     return $hidden_items;
204     }
205    
206     function _prepare_component_args($label) {
207     $val = $this->_e_state['ecoms'][$label];
208     $this->set_data_locator($val['ecom_data_locator_key']);
209 jonen 1.5 // switch component type
210     if($val['ecom_type'] == "data") {
211     // switch abstract type
212     if($val['ecom_abstract_type'] == "list") {
213     if($val['ecom_data_locator_key'] == "rpc") {
214     //$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
215     $data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
216     } else {
217     user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
218     }
219     $args = array(
220 jonen 1.1 'caption' => "Liste",
221     'orderby' => "Guid",
222     'options' => array(
223     'data_locator_meta' => $data_locator_meta,
224     'decode' => 1,
225     'decode_args' => array(
226     'seperator' => "_",
227     'form' => 1,
228     ),
229     ),
230     );
231 jonen 1.5 // switch abstract type
232     } elseif ($val['ecom_abstract_type'] == "item") {
233     $args = array();
234     }
235     // switch component type
236     } elseif ($val['ecom_type'] == "nav") {
237     // switch abstract type
238     if($val['ecom_abstract_type'] == "list") {
239     if($val['ecom_data_locator_key'] == "rpc") {
240     $data_locator_meta = array( datasource => 'rpc', metatype => 'schema' );
241     } else {
242     user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
243     }
244     $args = array(
245     'caption' => "Objekt Typen",
246     'options' => array(
247     'data_locator_meta' => $data_locator_meta,
248     ),
249     );
250     } elseif ($val['ecom_abstract_type'] == "tree") {
251     $args = array();
252     }
253 jonen 1.1 }
254     return $args;
255     }
256    
257     function get_msg($label) {
258     if($label == "welcome") {
259     $msg = "Welcome to the Explorer.";
260     }
261     return $msg;
262     }
263    
264     function render() {
265     user_error("AbstractExplorer::render - please implement me....");
266     }
267    
268     }
269    
270    
271     ?>

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