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