1 |
cvsjoko |
1.1 |
<? |
2 |
|
|
|
3 |
|
|
// ====================================================== |
4 |
|
|
class HTMLWidgetFactory_TreeView { |
5 |
|
|
|
6 |
|
|
var $http_base_data; |
7 |
|
|
|
8 |
|
|
// -------------------------------------------------------- |
9 |
|
|
function Main( $args ) { |
10 |
|
|
|
11 |
|
|
// get args to local variables |
12 |
|
|
|
13 |
|
|
// http-base-url |
14 |
|
|
$this->http_base_data = $args['http_base_data']; |
15 |
|
|
|
16 |
|
|
// the name of a javascript-variable the packet is stored in |
17 |
|
|
$data_IdentKey = $args['data_IdentKey']; |
18 |
|
|
|
19 |
|
|
// the name of a javascript-variable the packet is stored in |
20 |
|
|
$bool_reload_data = $args['reload_data']; |
21 |
|
|
|
22 |
|
|
// the offset (in pixels) from the top of the page where to start the menu |
23 |
|
|
$offsetFromTop = $args['offset_from_top']; |
24 |
|
|
|
25 |
|
|
// array of callbacks |
26 |
|
|
$php_callbacks = $args['php_callbacks']; |
27 |
|
|
|
28 |
|
|
// shall the root-node be opened on startup? |
29 |
|
|
$bool_openRootNode = $args['openRootNode']; |
30 |
|
|
|
31 |
|
|
$jsGlobalScope_RelativeDomAddress = $args['jsGlobalScope_RelativeDomAddress']; |
32 |
|
|
$jsWorkerScope_AbsoluteDomAddress = $args['jsWorkerScope_AbsoluteDomAddress']; |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
$js_libbase = $this->http_base_data . 'inc/js/libraries'; |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
// call callback-function |
39 |
|
|
if (isset($args['php_callbacks']['begin'])) { |
40 |
|
|
call_user_func($args['php_callbacks']['begin']); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
?><script language="javascript"> |
44 |
|
|
|
45 |
|
|
// reference to global scope |
46 |
|
|
//var GlobalScope = <?= $jsGlobalScope_RelativeDomAddress ?>; |
47 |
|
|
var GlobalScope = controlWindow.top; |
48 |
|
|
var WorkerScope_AbsoluteAddress = '<?= $jsWorkerScope_AbsoluteDomAddress ?>' + '.' + self.name; |
49 |
|
|
// new TreeView-object |
50 |
|
|
var treeview = GlobalScope.createTreeView(self, WorkerScope_AbsoluteAddress); |
51 |
|
|
|
52 |
|
|
// insert joust-variables from global scope here |
53 |
|
|
treeview.joustInitialize(); |
54 |
|
|
var theBrowser = treeview.joustBrowser; |
55 |
|
|
var theMenu = treeview.joustMenu; |
56 |
|
|
|
57 |
|
|
</script><? |
58 |
|
|
|
59 |
|
|
// load javascript for joust-menu |
60 |
|
|
$this->joust_loadClientLibraries($js_libbase); |
61 |
|
|
|
62 |
|
|
// start with main html here |
63 |
|
|
?> |
64 |
|
|
|
65 |
|
|
<DIV ID="menuTop"> |
66 |
|
|
<!-- Place anything you want to appear before the menu between these DIV tags. --> |
67 |
|
|
<FONT FACE="Verdana, Helvetica, ARIAL, MS SANS SERIF, SANS-SERIF" SIZE="1"><!-- <b>Kategorie-Baum:</b></FONT><BR> --> |
68 |
|
|
</DIV> |
69 |
|
|
|
70 |
|
|
<SCRIPT LANGUAGE="JavaScript"><!-- |
71 |
|
|
setTop(<?= $offsetFromTop ?>); |
72 |
|
|
//--></SCRIPT> |
73 |
|
|
|
74 |
|
|
<!-- Set up any font's, colours, etc. that should apply to the menu here --> |
75 |
|
|
<FONT FACE="Verdana, GENEVA, ARIAL, MS SANS SERIF, SANS-SERIF" SIZE="1"> |
76 |
|
|
|
77 |
|
|
<SCRIPT LANGUAGE="JavaScript"> |
78 |
|
|
|
79 |
|
|
// determine data-contexts |
80 |
|
|
var requestedDataContext = '<?= $data_IdentKey ?>'; |
81 |
|
|
if (!GlobalScope.currentDataContext) { |
82 |
|
|
GlobalScope.setDataContext(requestedDataContext); |
83 |
|
|
} |
84 |
|
|
var currentDataContext = GlobalScope.currentDataContext; |
85 |
|
|
|
86 |
|
|
// get wddx-packet |
87 |
|
|
//alert('getwddx: ' + requestedDataContext); |
88 |
|
|
//wddxPacket = top.datastore["wddx"][requestedDataContext]; |
89 |
|
|
//alert(requestedDataContext); |
90 |
|
|
var wddxPacket = GlobalScope.datastore["wddx"][requestedDataContext]; |
91 |
|
|
|
92 |
|
|
// calculate reload |
93 |
|
|
//alert('calc reload'); |
94 |
|
|
bool_dataIsPresent = (wddxPacket) && (wddxPacket.length); |
95 |
|
|
bool_notYetInitialized = (theMenu.count == -1); |
96 |
|
|
bool_forceReInit = (<?= $bool_reload_data ?>); |
97 |
|
|
bool_DataContextChanged = (requestedDataContext != currentDataContext); |
98 |
|
|
//alert('bool_dataIsPresent: ' + bool_dataIsPresent); |
99 |
|
|
//alert('bool_notYetInitialized: ' + bool_notYetInitialized); |
100 |
|
|
//alert('bool_forceReInit: ' + bool_forceReInit); |
101 |
|
|
//alert('bool_DataContextChanged: ' + bool_DataContextChanged); |
102 |
|
|
|
103 |
|
|
bool_reinit = bool_dataIsPresent && (bool_notYetInitialized || bool_forceReInit || bool_DataContextChanged); |
104 |
|
|
//alert('bool_reinit: ' + bool_reinit); |
105 |
|
|
|
106 |
|
|
// reinit treeview |
107 |
|
|
if (bool_reinit) { |
108 |
|
|
// reset joust |
109 |
|
|
theMenu.count = -1; |
110 |
|
|
// initialize joust with wddx-packet |
111 |
|
|
//var rsTree = new GlobalScope.WddxRecordset; |
112 |
|
|
//GlobalScope.alert('abc'); |
113 |
|
|
var rsTree = GlobalScope.createWddxRecordset(); |
114 |
|
|
treeview.initMenuFromWddxPacket(theMenu, rsTree, wddxPacket, <?= $bool_openRootNode ?>); |
115 |
|
|
// remember new data-context |
116 |
|
|
GlobalScope.currentDataContext = requestedDataContext; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
<? |
120 |
|
|
if (isset($args['php_callbacks']['draw_begin'])) { |
121 |
|
|
call_user_func($args['php_callbacks']['draw_begin']); |
122 |
|
|
} |
123 |
|
|
?> |
124 |
|
|
|
125 |
|
|
//alert('draw0'); |
126 |
|
|
if (theMenu) { |
127 |
|
|
//top.DrawMenu(theMenu); |
128 |
|
|
//alert('draw'); |
129 |
|
|
theMenu.draw(); |
130 |
|
|
} else { |
131 |
|
|
alert("Couldn't draw TreeView because needed data-structure 'top.theMenu' could not be accessed."); |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
<? |
135 |
|
|
if (isset($args['php_callbacks']['draw_end'])) { |
136 |
|
|
call_user_func($args['php_callbacks']['draw_end']); |
137 |
|
|
} |
138 |
|
|
?> |
139 |
|
|
|
140 |
|
|
</SCRIPT> |
141 |
|
|
|
142 |
|
|
<!-- Close any tags you set up for the menu here --> |
143 |
|
|
</FONT> |
144 |
|
|
|
145 |
|
|
<DIV ID="menuBottom"> |
146 |
|
|
<!-- Place anything you want to appear after the menu between these DIV tags. --> |
147 |
|
|
|
148 |
|
|
</DIV> |
149 |
|
|
|
150 |
|
|
<SCRIPT LANGUAGE="JavaScript"><!-- |
151 |
|
|
setBottom(); |
152 |
|
|
//--></SCRIPT> |
153 |
|
|
|
154 |
|
|
|
155 |
|
|
<? |
156 |
|
|
|
157 |
|
|
if (isset($args['php_callbacks']['end'])) { |
158 |
|
|
call_user_func($args['php_callbacks']['end']); |
159 |
|
|
} |
160 |
|
|
|
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
// -------------------------------------------------------- |
164 |
|
|
function joust_loadClientLibraries($js_libbase) { |
165 |
|
|
|
166 |
|
|
// include jousts disclaimer |
167 |
|
|
?> |
168 |
|
|
|
169 |
|
|
<!-- |
170 |
|
|
Joust Outliner Version 2.4.1 |
171 |
|
|
(c) Copyright 1996-1999, Alchemy Computing Limited. All rights reserved. |
172 |
|
|
This code may be freely copied and distributed provided that it is accompanied by this header. |
173 |
|
|
|
174 |
|
|
Do not modify anything between here and the "End of Joust" marker unless you know what you |
175 |
|
|
are doing. You can find the latest version of Joust and all associated files and help at |
176 |
|
|
http://www.alchemy-computing.co.uk/joust/. If you have any questions/problems or you want to be |
177 |
|
|
added to the Joust mailing list, send an eMail to joust@alchemy.demon.co.uk. |
178 |
|
|
--> |
179 |
|
|
|
180 |
|
|
<? |
181 |
|
|
|
182 |
|
|
// include the stylesheet needed by joust |
183 |
|
|
$url_stylesheet = $this->http_base_data . 'inc/css/jouststyles.css'; |
184 |
|
|
?><link rel="stylesheet" type="text/css" href="<?= $url_stylesheet ?>"><? |
185 |
|
|
|
186 |
|
|
// include wddx2joust-engine |
187 |
|
|
?><script language="javascript" src="<?= "$js_libbase/joust+/wddx2joust2.js" ?>"></script><? |
188 |
|
|
|
189 |
|
|
// include jousts menu-startup |
190 |
|
|
?><script language="javascript" src="<?= "$js_libbase/joust/joust_start.js" ?>"></script><? |
191 |
|
|
|
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
|
195 |
|
|
} |
196 |
|
|
|
197 |
|
|
?> |