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