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