-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure.php
More file actions
270 lines (242 loc) · 11.9 KB
/
Copy pathstructure.php
File metadata and controls
270 lines (242 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
function HTMLHeader() {
?>
<html>
<head>
<title>LinuxMCE - Orbiter by hand</title>
<script type="text/javascript">
function main(nWidth,nHeight) {
var mainCanvas = document.getElementById("main");
var mainContext = mainCanvas.getContext("2d");
var mainBackground = new Image();
mainBackground.src = "skins/Basic/Media/PVRremote.png";
mainBackground.onload = function() {
mainContext.drawImage(mainBackground,0,0,nWidth,nHeight);
}
}
function drawDO(nWidth,nHeight,nPosX,nPosY,cImage) {
var mainCanvas = document.getElementById("main");
var mainContext = mainCanvas.getContext("2d");
var mainBackground = new Image();
mainBackground.src = cImage;
mainBackground.onload = function() {
mainContext.drawImage(mainBackground,nPosX,nPosY,nWidth,nHeight);
}
</script>
<style type="text/css">
<!--
li {
visibility: hidden;
}
-->
</style>
</head>
<body onload='main(640,480)'>
<?php
}
/*
structure reads the pluto_main database and deciphers a
given skin and UI into a tree containing all relevant
information to recreate the screen in another descriptive
language / layout engine
*/
include_once("lib.inc.php");
error_reporting(E_ALL);
function getBackground($FK_DesignObj,$x=0,$y=0) {
global $link;
$background = "";
$skin = "Basic";
// Now we get the background image from the main variation (if such a thing exists)
$query = "Select Value from DesignObjVariation_DesignObjParameter";
$query .= " Join DesignObjVariation On FK_DesignObjVariation = PK_DesignObjVariation";
$query .= " Where Value Is Not Null And Value <> '' And DesignObjVariation.FK_DesignObj = $FK_DesignObj and (FK_UI is null Or FK_UI = 1)";
$query .= " Order By FK_UI Desc";
$background = getMyValue($link,$query);
if (($background == 1) or ($background == "")) {
$background = "";
} else {
// some path names for images still contain a backslash instead
// of a forward slash, probably thanks to HADesigner's roots.
$background = str_replace("\\","/",$background);
// We do have spaces in there. Let's replace those with %20
$background = str_replace(" ","%20",$background);
// atm we hardcode the skin Basic
$background = "skins/$skin/" . $background;
}
return $background;
}
function getDesignObjText($FK_DesignObj,$x=0,$y=0,$parentwidth,$parentheight) {
global $link;
$query = "select PK_DesignObjVariation,Text_LS.FK_Text,Text_LS.FK_Language,Text_LS.Description,";
$query .= " DesignObjVariation_Text_Skin_Language.X, DesignObjVariation_Text_Skin_Language.Y,";
$query .= " DesignObjVariation_Text_Skin_Language.Width, DesignObjVariation_Text_Skin_Language.Height,";
$query .= " DesignObjVariation_Text_Skin_Language.*";
$query .= " from DesignObjVariation";
$query .= " Join DesignObjVariation_Text On PK_DesignObjVariation = FK_DesignObjVariation";
$query .= " Join Text_LS On Text_LS.FK_Text = DesignObjVariation_Text.FK_Text";
$query .= " Join DesignObjVariation_Text_Skin_Language On DesignObjVariation_Text_Skin_Language.FK_DesignObjVariation_Text = PK_DesignObjVariation_Text";
$query .= " Where DesignObjVariation.FK_DesignObj = " . $FK_DesignObj;
$query .= " And Text_LS.FK_Language = 1";
$query .= " And (DesignObjVariation.FK_UI = 1 or DesignObjVariation.FK_UI IS NULL)";
$query .= " And DesignObjVariation_Text_Skin_Language.FK_Skin Is Null";
$query .= " Order By Text_LS.FK_Language";
$arr = getMyArray($link,$query);
if (is_array($arr)) {
outputGroupOn($FK_DesignObj);
foreach ($arr as $designobj) {
$designobj["X"] = $designobj["X"]+$x;
$designobj["Y"] = $designobj["Y"]+$y;
outputText($designobj,$parentwidth,$parentheight);
}
outputGroupOff();
}
}
function getCommandGroup_D($FK_DesignObj,$onClick=0) {
global $link;
$query = "select FK_CommandGroup_D_OnActivate from DesignObjVariation Where FK_DesignObj = $FK_DesignObj;";
$arr = getMyArray($link,$query);
if (is_array($arr) > 0) {
if ($onClick==0) {
// print "<li>On ActivateCommandGroups</li>";
outputGroupOn($FK_DesignObj);
}
foreach ($arr as $commandOnActivate) {
if ($commandOnActivate[0] != "") {
if ($onClick==0) {
// print "<li>$commandOnActivate[0]</li>";
} else {
print "alert('The command $commandOnActivate[0] should be activated now');";
}
}
}
if ($onClick==0) {
outputGroupOff();
}
}
}
function getDesignObj($FK_DesignObj,$level=0,$x=0,$y=0) {
global $link;
// Return the position and designobj childs of the FK_DesignObj
$query = "Select PK_DesignObjVariation_DesignObj, DesignObj.Description, DesignObjVariation_DesignObj.FK_DesignObj_Child,";
$query .= " DesignObjVariation_DesignObj_Skin_Language.X, DesignObjVariation_DesignObj_Skin_Language.Y,";
$query .= " DesignObjVariation_DesignObj_Skin_Language.Width, DesignObjVariation_DesignObj_Skin_Language.Height";
$query .= " From DesignObjVariation_DesignObj_Skin_Language";
$query .= " Join DesignObjVariation_DesignObj On FK_DesignObjVariation_DesignObj = PK_DesignObjVariation_DesignObj";
$query .= " Join DesignObjVariation On FK_DesignObjVariation_Parent = PK_DesignObjVariation";
$query .= " Join DesignObj On PK_DesignObj = FK_DesignObj_Child";
$query .= " Where DesignObjVariation.FK_DesignObj = $FK_DesignObj";
$queryUI1 = $query . " And DesignObjVariation.FK_UI = 1";
$queryStandard = $query . " And DesignObjVariation.FK_UI Is Null";
$arrUI1 = getMyArray($link,$queryUI1);
// Sometimes a DesignObj itself is not available for UI1 one but only for the standard.
// if (count($arr)==0) {
$arrStandard = getMyArray($link,$queryStandard);
// }
$arr = array_merge($arrUI1,$arrStandard);
// outputGroupOn();
if (is_array($arr)) {
outputGroupOn($FK_DesignObj);
foreach ($arr as $designobj) {
$currentFK_DesignObj = $designobj["FK_DesignObj_Child"];
$designobj["X"] = $x + $designobj["X"];
$designobj["Y"] = $y + $designobj["Y"];
outputObject($designobj);
// getCommandGroup_D($designobj["FK_DesignObj_Child"]);
getDesignObj($currentFK_DesignObj,$level+1,$x+$designobj["X"],$y+$designobj["Y"]);
// print "<li>Return von getDesignObj</li>";
}
outputGroupOff();
}
// outputGroupOff();
return $arr;
}
function outputGroupOn($FK_DesignObj = "") {
if ($FK_DesignObj == "") {
print "<div>\n";
} else {
print "<div id=$FK_DesignObj>";
}
}
function outputGroupOff() {
print "</div>\n";
}
function outputObject($arrDesignObj) {
global $screen;
$currentFK_DesignObj = $arrDesignObj["FK_DesignObj_Child"];
/* print "<li><h3>Description: ". $arrDesignObj["Description"] . "</h3></li>\n";
print "<li>DesignObj: ". $arrDesignObj["FK_DesignObj_Child"] . "</li>\n";
print "<li>Position: " . $arrDesignObj["X"] . " x " . $arrDesignObj["Y"] . "</li>\n";
print "<li>Size: " . $arrDesignObj["Width"] . " x " . $arrDesignObj["Height"] . "</li>\n";
print "<li>Background: " . getBackground($currentFK_DesignObj) . "</li>\n";
print "<li>Text: " . . "</li>\n";
*/
getDesignObjText($currentFK_DesignObj,$arrDesignObj["X"],$arrDesignObj["Y"],$arrDesignObj["Width"],$arrDesignObj["Height"]);
if (getBackground($currentFK_DesignObj) != "") {
print "<img alt='". $arrDesignObj["Description"] ."' style='position:absolute;";
print "left:" . $arrDesignObj["X"]. "px;top:" . $arrDesignObj["Y"] . "px;";
print "width=" . $arrDesignObj["Width"] . "px;height=" . $arrDesignObj["Height"] ."px;";
print "'";
print " src='" . getBackground($currentFK_DesignObj) . "' ";
print " onClick=\"";
print "\$('#new-nav').load('structure.php?noheader&screen=$screen&designobj=" . $arrDesignObj["FK_DesignObj_Child"] . "');";
// getCommandGroup_D($arrDesignObj["FK_DesignObj_Child"],1);
print "\"";
print " />\n";
}
}
function outputText($arrDesignObj,$parentwidth,$parentheight) {
if ($arrDesignObj["Width"] == 0) {
$arrDesignObj["Width"] = $parentwidth;
}
if ($arrDesignObj["Height"] == 0) {
$arrDesignObj["Height"] = $parentheight;
}
/* print "<li><h3>Description: ". $arrDesignObj["Description"] . "</h3></li>\n";
print "<li>Position: " . $arrDesignObj["X"] . " x " . $arrDesignObj["Y"] . "</li>\n";
print "<li>Size: " . $arrDesignObj["Width"] . " x " . $arrDesignObj["Height"] . "</li>\n";
*/
// TODO: posde seems to be too stupid for vertical aligning next
// within a known box.
print "<div style='position: absolute; left:" . $arrDesignObj["X"] . "px;";
print "top:" . $arrDesignObj["Y"] . "px;z-index:1;'>";
print "<table><tr style='height:" . $arrDesignObj["Height"] . "px;'>";
print "<td style='vertical-align:middle;width:" . $arrDesignObj["Width"] . "px;'>";
print "<p style='text-align:center;font-size:50px;'>" . $arrDesignObj["Description"] . "</p>";
print "</td></tr></table>";
print "</div>";
}
connectDB();
global $currentUser, $currentScreen, $currentRoom, $currentEntertainArea, $link, $mediaLink;
// Get all data for the standard variation
$screen = 48; // MythTV Remote
if (isset($_GET["screen"])) {
$screen = $_GET["screen"];
}
if (isset($_GET["designobj"])) {
// We now check for all commands for that designobject
// and do a messagesend for most of them. If it contains a
// goto screen command, we change the $screen to reflect
// the new screen.
$designobj = $_GET["designobj"];
// getCommandGroup_D($designobj);
print "<h1>Now we should be executing all commands for designobj $designobj</h1>";
}
if (isset($_GET["noheader"])) {
$noheader=1;
} else {
$noheader=0;
HTMLHeader();
}
$query = "SELECT FK_DesignObj From Screen_DesignObj Where FK_Screen = $screen AND FK_UI Is Null AND FK_Skin Is Null";
$FK_DesignObj = getMyValue($link,$query);
$background = getBackground($FK_DesignObj);
print "<img alt='Background' src='$background' style='top:0;left:0;' />";
print "<h2>Screen $screen - Main Background=$background for $FK_DesignObj</h2>";
// Now that we have the basic background, let's try and find all the objects on this screen.
$arr = getDesignObj($FK_DesignObj);
mysql_close($mediaLink);
mysql_close($link);
if ($noheader == 0) {
print "</body></html>";
}
?>