/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Mar 20 07:44:31 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.1: +6 -3 lines
+ removed dumper

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

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