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