/[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.4 - (show annotations)
Thu Mar 20 08:02:11 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.3: +4 -5 lines
+ purged code

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

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