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

Annotation of /nfo/php/libs/org.netfrag.app/WebExplorer/Module/DataTree.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue May 13 14:57:33 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +92 -31 lines
logic revamp & cleanup

1 joko 1.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 joko 1.2 * $Id: DataTree.php,v 1.1 2003/04/16 16:16:15 joko Exp $
14     *
15     * $Log: DataTree.php,v $
16     * Revision 1.1 2003/04/16 16:16:15 joko
17     * initial commit
18 joko 1.1 *
19     *
20     */
21    
22     /**
23     * Make sure we have required base classes on board.
24     *
25     */
26     loadModule('WebExplorer::Module::AbstractGUIModule');
27    
28     /**
29     * DataTree
30     *
31     * Display linked list data with a tree widget.
32 joko 1.2 * Enable simple tree navigation.
33     *
34     * @todo Enhance tree navigation: Prefix anchor if state == DivedIntoNode.
35 joko 1.1 *
36     *
37     * @package org.netfrag.app
38     * @subpackage WebExplorer
39     * @name DataTree
40     *
41     */
42     class WebExplorer_Module_DataTree extends WebExplorer_Module_AbstractGUIModule {
43    
44 joko 1.2 // the reference to an adapter of a DataSource::Generic acting as a proxy
45 joko 1.1 var $source;
46 joko 1.2
47     // the result of the query
48     //var $result;
49     var $treedata;
50    
51     // a reference to a PEAR::Tree object.
52     var $topictree;
53     var $treeobject;
54 joko 1.1 var $tree;
55 joko 1.2 var $widget;
56    
57 joko 1.1
58     function set_gui_object() {
59 joko 1.2
60     // Build & lift the tree's data.
61     $this->query_source();
62     $this->lift_tree();
63    
64     // Encapsulate the tree into a container widget together with some navigation boxes.
65     $this->prepare_header();
66     $this->build_widget();
67    
68     // Transfer reference to widget object to
69     // object attribute the ecom module logic
70     // knows about.
71     $this->_gui_object = $this->widget;
72    
73 joko 1.1 }
74    
75    
76 joko 1.2 function prepare_header() {
77     // declare some links
78 joko 1.1 $this->_args[links] = array(
79     'list' => array(
80     array( name => 'tree', url => url::view_as('tree') ),
81 joko 1.2 //array( name => 'item', url => url::view_as('item') ),
82     // HACK!!!
83     array( name => 'item', url => url::view_as('item', array( ecdid => "n/a", ecdm => $_GET[ecdid] ) ) ),
84     array( name => 'reset filter', url => url::filter('tree') ),
85     array( name => 'parent', url => url::parent('tree') ),
86 joko 1.1 ),
87     'meta' => array(
88 joko 1.2 'selected' => $this->_args['options']['data_locator_meta']['abstract_type']
89 joko 1.1 )
90     );
91 joko 1.2 }
92    
93    
94     function query_source() {
95    
96     //print "args: " . Dumper($this->_args);
97    
98     $locator_meta = $this->_args['options']['data_locator_meta'];
99     if (!$this->_args[caption]) { $this->_args[caption] = $locator_meta[ident] . " as " . $locator_meta[abstract_type]; }
100 joko 1.1
101     // query data
102     $initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'free' ) );
103     $proxy = php::mkComponent('DataSource::Generic', $initial_locator, $this->_args['options']['data_locator_meta']);
104     //print "proxy: " . Dumper($proxy);
105    
106     if ($this->source = $proxy->get_adapter()) {
107     //print "source: " . Dumper($this->source);
108     $this->source->do_query();
109     }
110    
111     //print "result: " . Dumper($this->source->_result);
112    
113     // get navigation data structure (nested tree) from backend object
114     // remote or locally? we just don't care here....
115     //global $backend;
116    
117     // V1 - HACK!!!
118     //$this->backend = new TsBackend();
119     //$treedata = $this->backend->getNavigationTree();
120    
121     // V2 - better
122 joko 1.2 $this->treedata = $this->source->get_result();
123 joko 1.1
124 joko 1.2 //print Dumper($this->treedata);
125    
126     }
127    
128    
129     function lift_tree() {
130 joko 1.1
131     /*
132     $treedata = array(
133     //'name' => '', attributes => array( url => '123' ),
134     'children' => array(
135     array( name => 'Login', attributes => array( url => linkargs::topic('Login') ) ),
136     array( name => 'Verwaltung', attributes => array( url => linkargs::topic('Overview') ),
137     'children' => array(
138     array( name => 'Jobs', attributes => array( url => linkargs::topic('Jobs') ) ),
139     array( name => 'Daten:Backend', attributes => array( url => linkargs::topic('DataBrowser') ) ),
140     array( name => 'Daten:Frontend', attributes => array( url => linkargs::topic('DataBrowser') ) ),
141     array( name => 'Daten:Steuerung', attributes => array( url => linkargs::topic('DataBrowser') ) ),
142     ),
143     ),
144     ));
145     */
146    
147    
148     // convert (speak "lift") data from nested arrays/hashes to a hashified topic tree
149     // this step is required to satisfy the following lifting
150 joko 1.2 $lift = mkObject('Data::Lift', $this->treedata, array( metatype => 'topic' ) );
151 joko 1.1 $this->topictree = $lift->to('EasyTree');
152     //print "topictree: " . Dumper($this->topictree) . "<br/>";
153    
154     //return;
155    
156     // convert (speak "lift") data from nested arrays/hashes to a PEAR::Tree object
157     $lift = mkObject('Data::Lift', $this->topictree, array( metatype => 'tree' ) );
158     $this->treeobject = $lift->to('PEAR::Tree');
159     //print "treeobject: " . Dumper($this->treeobject) . "<br/>";
160    
161     // trace
162     //print Dumper($initial_locator);
163     //print Dumper($this->_args);
164    
165     //$this->nav = new VerticalCSSNavTable($this->_args['caption'], "", $width="100%");
166     //$this->tree = new VerticalCSSNavTable($this->_args['caption'], "", $width="100%");
167     $this->tree = new DHTMLTreeNav( $this->treeobject );
168    
169     //$this->tree->add(link::topic('DataBrowser'), "No data.");
170    
171    
172     /*
173     // check valid/non-empty result
174     //if ($itemCount = $this->source->get_total_rows()) {
175     if (1) {
176     $this->result = $this->source->_result;
177    
178     // trace
179     //print Dumper($source->_result);
180    
181     //if (is_array($result)) {
182     $this->propagate();
183     //}
184    
185     } else {
186    
187     // both are valid! (at least - should be...)
188     //$nav->add(pageLink('explorer'), "No data.");
189     //$this->nav->add(link::topic('DataBrowser'), "No data.");
190     print "No data.<br/>";
191    
192     }
193     */
194 joko 1.2
195     }
196    
197     function build_widget() {
198 joko 1.1
199 joko 1.2 // Encapsulate tree into a floating span container.
200     // This will be displayed on the left side of the content area.
201     $this->content = html_span();
202     $this->content->set_style("float: left;");
203     $this->content->add( $this->tree );
204    
205     // TODO: Choose one of these two metabox types.
206     // Having *both* on one page seems overkill.
207     // That's just for demonstration purposes!
208    
209     // Build a bar-style MetaBox.
210     // This will get injected on top of (before) the content.
211     $this->header = php::mkComponent('MetaBox', array(
212     box_mode => 'bar',
213     caption => $this->_args['caption'],
214     payload => $this->_args['links'],
215     ) );
216    
217     // Build a portrait-style MetaBox.
218     // This will get injected besides / after the content.
219     // This will be displayed on the right side of the content area.
220     $this->sidebox = php::mkComponent('MetaBox', array(
221     box_mode => 'portrait',
222     //caption => $this->_args['caption'],
223     payload => $this->_args['links'],
224     ) );
225 joko 1.1
226     //print Dumper($this->header);
227    
228 joko 1.2 // Layout of the page:
229 joko 1.1 $container = html_div();
230     $container->add( $this->header, html_br() );
231 joko 1.2 $container->add( $this->content );
232     $container->add( $this->sidebox );
233 joko 1.1
234 joko 1.2 $this->widget = $container;
235 joko 1.1
236     }
237    
238     function propagate_old() {
239     //print get_class($this) . ": " . "Please implement 'propagate
240     //$this->_abstract_method('propagate', get_class($this));
241     }
242    
243     }
244    
245    
246     ?>

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