1 |
<? |
2 |
/** |
3 |
* This file contains the DataTree child class. |
4 |
* |
5 |
* @package org.netfrag.app |
6 |
* @name WebExplorer::Module::DataTree |
7 |
* |
8 |
*/ |
9 |
|
10 |
/** |
11 |
* Cvs-Log |
12 |
* |
13 |
* $Id: FlexibleNegotiation.php,v 1.3 2003/04/11 01:34:46 joko Exp $ |
14 |
* |
15 |
* $Log: FlexibleNegotiation.php,v $ |
16 |
* |
17 |
*/ |
18 |
|
19 |
/** |
20 |
* Make sure we have required base classes on board. |
21 |
* |
22 |
*/ |
23 |
loadModule('WebExplorer::Module::AbstractGUIModule'); |
24 |
|
25 |
/** |
26 |
* DataTree |
27 |
* |
28 |
* Display linked list data with a tree widget. |
29 |
* |
30 |
* |
31 |
* @package org.netfrag.app |
32 |
* @subpackage WebExplorer |
33 |
* @name DataTree |
34 |
* |
35 |
*/ |
36 |
class WebExplorer_Module_DataTree extends WebExplorer_Module_AbstractGUIModule { |
37 |
|
38 |
var $source; |
39 |
var $result; |
40 |
var $tree; |
41 |
|
42 |
function set_gui_object() { |
43 |
$this->_gui_object = $this->buildTree(); |
44 |
} |
45 |
|
46 |
|
47 |
function buildTree() { |
48 |
|
49 |
//print "args: " . Dumper($this->_args); |
50 |
|
51 |
$locator_meta = $this->_args['options']['data_locator_meta']; |
52 |
if (!$this->_args[caption]) { $this->_args[caption] = $locator_meta[ident] . " as " . $locator_meta[abstract_type]; } |
53 |
|
54 |
$this->_args[links] = array( |
55 |
'list' => array( |
56 |
array( name => 'tree', url => url::view_as('tree') ), |
57 |
array( name => 'item', url => url::view_as('item') ), |
58 |
), |
59 |
'meta' => array( |
60 |
'selected' => $locator_meta[abstract_type] |
61 |
) |
62 |
); |
63 |
|
64 |
// query data |
65 |
$initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'free' ) ); |
66 |
$proxy = php::mkComponent('DataSource::Generic', $initial_locator, $this->_args['options']['data_locator_meta']); |
67 |
//print "proxy: " . Dumper($proxy); |
68 |
|
69 |
if ($this->source = $proxy->get_adapter()) { |
70 |
//print "source: " . Dumper($this->source); |
71 |
$this->source->do_query(); |
72 |
} |
73 |
|
74 |
//print "result: " . Dumper($this->source->_result); |
75 |
|
76 |
// get navigation data structure (nested tree) from backend object |
77 |
// remote or locally? we just don't care here.... |
78 |
//global $backend; |
79 |
|
80 |
// V1 - HACK!!! |
81 |
//$this->backend = new TsBackend(); |
82 |
//$treedata = $this->backend->getNavigationTree(); |
83 |
|
84 |
// V2 - better |
85 |
$treedata = $this->source->get_result(); |
86 |
|
87 |
//print Dumper($treedata); |
88 |
|
89 |
/* |
90 |
$treedata = array( |
91 |
//'name' => '', attributes => array( url => '123' ), |
92 |
'children' => array( |
93 |
array( name => 'Login', attributes => array( url => linkargs::topic('Login') ) ), |
94 |
array( name => 'Verwaltung', attributes => array( url => linkargs::topic('Overview') ), |
95 |
'children' => array( |
96 |
array( name => 'Jobs', attributes => array( url => linkargs::topic('Jobs') ) ), |
97 |
array( name => 'Daten:Backend', attributes => array( url => linkargs::topic('DataBrowser') ) ), |
98 |
array( name => 'Daten:Frontend', attributes => array( url => linkargs::topic('DataBrowser') ) ), |
99 |
array( name => 'Daten:Steuerung', attributes => array( url => linkargs::topic('DataBrowser') ) ), |
100 |
), |
101 |
), |
102 |
)); |
103 |
*/ |
104 |
|
105 |
|
106 |
// convert (speak "lift") data from nested arrays/hashes to a hashified topic tree |
107 |
// this step is required to satisfy the following lifting |
108 |
$lift = mkObject('Data::Lift', $treedata, array( metatype => 'topic' ) ); |
109 |
$this->topictree = $lift->to('EasyTree'); |
110 |
//print "topictree: " . Dumper($this->topictree) . "<br/>"; |
111 |
|
112 |
//return; |
113 |
|
114 |
// convert (speak "lift") data from nested arrays/hashes to a PEAR::Tree object |
115 |
$lift = mkObject('Data::Lift', $this->topictree, array( metatype => 'tree' ) ); |
116 |
$this->treeobject = $lift->to('PEAR::Tree'); |
117 |
//print "treeobject: " . Dumper($this->treeobject) . "<br/>"; |
118 |
|
119 |
// trace |
120 |
//print Dumper($initial_locator); |
121 |
//print Dumper($this->_args); |
122 |
|
123 |
//$this->nav = new VerticalCSSNavTable($this->_args['caption'], "", $width="100%"); |
124 |
//$this->tree = new VerticalCSSNavTable($this->_args['caption'], "", $width="100%"); |
125 |
$this->tree = new DHTMLTreeNav( $this->treeobject ); |
126 |
|
127 |
//$this->tree->add(link::topic('DataBrowser'), "No data."); |
128 |
|
129 |
|
130 |
/* |
131 |
// check valid/non-empty result |
132 |
//if ($itemCount = $this->source->get_total_rows()) { |
133 |
if (1) { |
134 |
$this->result = $this->source->_result; |
135 |
|
136 |
// trace |
137 |
//print Dumper($source->_result); |
138 |
|
139 |
//if (is_array($result)) { |
140 |
$this->propagate(); |
141 |
//} |
142 |
|
143 |
} else { |
144 |
|
145 |
// both are valid! (at least - should be...) |
146 |
//$nav->add(pageLink('explorer'), "No data."); |
147 |
//$this->nav->add(link::topic('DataBrowser'), "No data."); |
148 |
print "No data.<br/>"; |
149 |
|
150 |
} |
151 |
*/ |
152 |
|
153 |
$this->header = html_div(); |
154 |
$this->header->set_style("border: 1px black solid; padding:2px;"); |
155 |
//$this->header->set_class("contentnovertical"); |
156 |
$this->header->add( $this->_args['caption'] ); |
157 |
if ($this->_args['links']['list']) { |
158 |
//$this->header->add( "Change abstract type to (ViewAs): " ); |
159 |
$this->header->add( ", ViewAs: " ); |
160 |
foreach ($this->_args['links']['list'] as $link) { |
161 |
if ($this->_args['links'][meta][selected] == $link[name]) { $link[name] = '[ ' . $link[name] . ' ]'; } |
162 |
$this->header->add( html_a( $link[url], $link[name] ), _HTML_SPACE ); |
163 |
} |
164 |
} |
165 |
|
166 |
//print Dumper($this->header); |
167 |
|
168 |
$container = html_div(); |
169 |
$container->add( $this->header, html_br() ); |
170 |
$container->add( $this->tree, html_br() ); |
171 |
|
172 |
return $container; |
173 |
|
174 |
} |
175 |
|
176 |
function propagate_old() { |
177 |
//print get_class($this) . ": " . "Please implement 'propagate |
178 |
//$this->_abstract_method('propagate', get_class($this)); |
179 |
|
180 |
} |
181 |
|
182 |
} |
183 |
|
184 |
|
185 |
?> |