-
Notifications
You must be signed in to change notification settings - Fork 0
/
clsPage.php
302 lines (265 loc) · 10.9 KB
/
clsPage.php
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
/*
*
* MAWStats 0.8 Web Statistics
*
* Copyright (c) 2009 Asaf Ohaion (mawstats.lingnu.com)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
class clsPage {
var $sMenu = "";
var $sSubMenuJS = "";
var $aViews = array();
function clsPage($type="") {
if (strlen($type) == 0) {
$type = "web";
}
$uifile = "ui/".$type."menu.xml";
if (file_exists($uifile)) {
$xml = new DOMDocument();
$xml->load($uifile);
} else {
exit("Failed to open ui/".$type."menu.xml");
}
$aMenuString = "<ul>";
$aSubMenuString = "<script type=\"text/javascript\"> var oSubMenu = {};";
$tabs = $xml->getElementsByTagName("tab");
// Iterate Tabs
foreach ($tabs as $aTab) {
$children = $aTab->getElementsByTagName("subview");
$sId = $aTab->getAttribute("id");
$sTitle = Lang($aTab->getAttribute("label"));
$sSubView = $aTab->getAttribute("subview");
$aMenuString .= "<li id=\"tab".$sId."\"><span onclick=\"ChangeTab(this, '".$sId.".".$sSubView."')\">".$sTitle."</span></li>";
$aSubMenuString .= "oSubMenu.".$sId." = { ";
// Iterate Sub-Views
$aFirst = true;
$this->aViews[$sId.".".$sSubView]=10;
foreach ($children as $aSubmenu) {
if ($aFirst) {
$aFirst = false;
} else {
$aSubMenuString .= ", ";
$this->aViews[$sId.".".$aSubmenu->getAttribute("id")]=10;
}
$aSubMenuString .= "\"".Lang($aSubmenu->getAttribute("label"))."\" : \"".$sId.".".$aSubmenu->getAttribute("id")."\"";
}
$aSubMenuString .= " };";
}
$aMenuString .= "</ul>";
$aSubMenuString .= "</script>";
$this->sMenu = $aMenuString;
$this->sSubMenuJS = $aSubMenuString;
}
function DrawMenu() {
return $this->sMenu;
}
function SubMenuJSObj() {
return $this->sSubMenuJS;
}
function DrawHeader($dtDate) {
$aString = explode("_", str_replace("]", "]_", str_replace("[", "_[", Lang("Statistics for [SITE] in [MONTH] [YEAR]"))));
for ($i = 0; $i <count($aString); $i++) {
if ((strlen(trim($aString[$i])) > 0) && (substr($aString[$i], 0, 1) != "[")) {
$aString[$i] = ("<span>" . $aString[$i] . "</span>");
} else {
switch ($aString[$i]) {
case "[MONTH]":
$aString[$i] = Lang(date("F", $dtDate));
break;
case "[SITE]":
$aString[$i] = (GetSiteName() . "<a href=\"" . $GLOBALS["g_aConfig"]["siteurl"] .
"\" target=\"_blank\"><img src=\"themes/default/images/external_link.png\" class=\"externallink\" /></a>");
break;
case "[YEAR]":
$aString[$i] = date("Y", $dtDate);
break;
}
}
}
return ("<h1>" . implode($aString) . "</h1>");
}
function DrawFooter() {
$aString = explode("_", str_replace("]", "]_", str_replace("[", "_[", Lang("Powered by [AWSTART]AWStats[END]. Made beautiful by [MAWSTART]MAWStats Web Statistics and Analytics[END]."))));
for ($i = 0; $i <count($aString); $i++) {
if ((strlen(trim($aString[$i])) > 0) && (substr($aString[$i], 0, 1) != "[") && (substr($aString[$i + 1], 0, 5) != "[END]")) {
$aString[$i] = ("<span>" . $aString[$i] . "</span>");
} else {
switch ($aString[$i]) {
case "[AWSTART]":
$aString[$i] = "<a href=\"http://www.awstats.org/\" target=\"_blank\">";
break;
case "[END]":
$aString[$i] = "</a>";
break;
case "[MAWSTART]":
$aString[$i] = "<a href=\"http://mawstats.lingnu.com/\" target=\"_blank\">";
break;
}
}
}
return implode($aString);
}
function ValidateView($sView) {
return array_key_exists($sView, $this->aViews);
}
} // clsPage
function ToolChangeLanguage() {
if (count($GLOBALS["g_aTranslation"]) < 1) {
return "";
}
function LanguageSort($a, $b) {
return ($a["name"] < $b["name"]) ? -1 : 1;
}
// create html
$aHTML = array();
$aHTML[] = "<div id=\"toolLanguage\" class=\"tool\">\n<div>";
$aHTML[] = "<h1>" . Lang("Please select your language") . "<span onclick=\"ShowTools('toolLanguage')\">(" . Lang("Cancel") . ")</span></h1>";
$aHTML[] = "<table id=\"langpicker\" cellspacing=\"0\">\n<tr><td><ul>";
// copy array
array_push($GLOBALS["g_aTranslation"], array("code" => "en-gb", "name" => "English", "translations" => array()));
usort($GLOBALS["g_aTranslation"], "LanguageSort");
// loop through sites
$iColA = ceil(count($GLOBALS["g_aTranslation"]) / 3);
$iColB = ceil((count($GLOBALS["g_aTranslation"]) - $iColA) / 2) + $iColA;
for ($i = 0; $i < count($GLOBALS["g_aTranslation"]); $i++) {
$sCSS = "";
if ($GLOBALS["g_aTranslation"][$i]["code"] == $GLOBALS["sLanguageCode"]) {
$sCSS = " class=\"selected\"";
}
$aHTML[] = "<li" . $sCSS . " onclick=\"ChangeLanguage('" . $GLOBALS["g_aTranslation"][$i]["code"] . "')\">" . $GLOBALS["g_aTranslation"][$i]["name"] . "</li>";
if ((($i + 1) == $iColA) || (($i + 1) == $iColB)) {
$aHTML[] = "</ul>\n</td>\n<td><ul>";
if (count($GLOBALS["g_aTranslation"]) == $i) {
$aHTML[] = "<li> </li>";
}
}
}
// close html
$aHTML[] = "</ul>\n</td>\n</tr>\n</table>";
$aHTML[] = "</div></div>";
return implode($aHTML, "\n");
}
function ToolChangeMonth() {
$aHTML = array();
$aHTML[] = "<div id=\"toolMonth\" class=\"tool\">\n<div>";
$aHTML[] = "<h1>" . Lang("Please select the month you wish to view") . "<span onclick=\"ShowTools('toolMonth')\">(" . Lang("Cancel") . ")</span></h1>";
$aHTML[] = "<table id=\"datepicker\" cellspacing=\"0\">";
//loop through years
for ($iYear = date("Y", $GLOBALS["g_aLogFiles"][0][0]); $iYear >= date("Y", $GLOBALS["g_aLogFiles"][count($GLOBALS["g_aLogFiles"]) - 1][0]); $iYear--) {
$aHTML[] = "<tr>\n<td>" . $iYear . ":</td>";
// loop through months
for ($iMonth = 1; $iMonth < 13; $iMonth++) {
$dtTemp = mktime(0, 0, 0, $iMonth, 1, $iYear);
$bExists = false;
foreach ($GLOBALS["g_aLogFiles"] as $aLog) {
if (($aLog[0] == $dtTemp) && ($aLog[1] == true)) {
$bExists = true;
break;
}
}
if ($bExists == true) {
$sCSS = "";
if ((date("n", $GLOBALS["g_aLogFiles"][$GLOBALS["g_iThisLog"]][0]) == $iMonth) && (date("Y", $GLOBALS["g_aLogFiles"][$GLOBALS["g_iThisLog"]][0]) == $iYear)) {
$sCSS .= " selected";
}
$aHTML[] = "<td class='date" . $sCSS . "' onclick='ChangeMonth(" . date("Y,n", $dtTemp) . ")'>" . Lang(date("F", $dtTemp)) . "</td>";
} else {
if ($dtTemp > time()) {
$aHTML[] = "<td class='fade'> </td>";
} else {
$aHTML[] = "<td class='fade'>" . Lang(date("F", $dtTemp)) . "</td>";
}
}
}
$aHTML[] = "</tr>";
}
$aHTML[] = "</table>";
$aHTML[] = "</div></div>";
return implode($aHTML, "\n");
}
function ToolChangeSite() {
if (($GLOBALS["bConfigChangeSites"] != true) || (count($GLOBALS["aConfig"]) < 2)) {
return "";
}
// create html
$aHTML = array();
$aHTML[] = "<div id=\"toolSite\" class=\"tool\">\n<div>";
$aHTML[] = "<h1>" . Lang("Please select the site you wish to view") . "<span onclick=\"ShowTools('toolSite')\">(" . Lang("Cancel") . ")</span></h1>";
$aHTML[] = "<table id=\"sitepicker\" cellspacing=\"0\">\n<tr><td><ul>";
// loop through sites
$i = 0;
$iColA = ceil(count($GLOBALS["aConfig"]) / 3);
$iColB = ceil((count($GLOBALS["aConfig"]) - $iColA) / 2) + $iColA;
foreach ($GLOBALS["aConfig"] as $sSiteCode => $aSite) {
$sCSS = "";
if ($GLOBALS["g_sConfig"] == $sSiteCode) {
$sCSS = " class=\"selected\"";
}
$aHTML[] = "<li" . $sCSS . " onclick=\"ChangeSite('" . $sSiteCode . "')\">" .
(((isset($aSite["sitename"]) == true) && (strlen(trim($aSite["sitename"])) > 0)) ? $aSite["sitename"] : $aSite["siteurl"]) . "</li>";
$i++;
if (($i == $iColA) || ($i == $iColB)) {
$aHTML[] = "</ul>\n</td>\n<td><ul>";
if ((count($GLOBALS["aConfig"]) == 2) && ($i == 2)) {
$aHTML[] = "<li></li>";
}
}
}
// close html
$aHTML[] = "</ul>\n</td>\n</tr>\n</table>";
$aHTML[] = "</div></div>";
return implode($aHTML, "\n");
}
function ToolUpdateSite() {
if ($GLOBALS["bConfigUpdateSites"] != true) {
return "";
}
// create html
$aHTML = array();
$aHTML[] = "<div id=\"toolUpdate\" class=\"tool\">\n<div>";
$aHTML[] = "<h1>" . Lang("Please enter the password to update this site") . "<span onclick=\"ShowTools('toolUpdate')\">(" . Lang("Cancel") . ")</span></h1>\n<div id=\"siteupdate\">";
$aHTML[] = "<input type=\"password\" id=\"password\" onkeyup=\"UpdateSiteKeyUp(event)\" />";
$aHTML[] = "<input type=\"button\" onclick=\"UpdateSite()\" value=\"" . Lang("Update") . "\" />";
$aHTML[] = "</div>\n</div>\n</div>";
return implode($aHTML, "\n");
}
function ToolChangeParts($sParts, $arrMissingParts) {
$aHTML = array();
$aHTML[] = "<div id=\"toolParts\" class=\"tool\">\n<div>";
$aHTML[] = "<h1>" . Lang("Select parts to show") . "<span onclick=\"ShowTools('toolParts')\">(" . Lang("Close") . ")</span></h1>";
$aHTML[] = "<table id=\"partspicker\" cellspacing=\"0\">\n<tr><td>";
foreach (explode(',', $sParts) as $part) {
$class = "selected";
$title = "";
if (array_key_exists($part, $arrMissingParts)) {
$class .= " missing";
$title .= "Missing Log : " . $arrMissingParts[$part];
}
$aHTML[] = "<ul><li title=\"" . $title . "\" onclick=\"ChangePart(this, '" . $part . "')\" class=\"". $class ."\">" . ucwords($part) . " </li></ul></td> <td>\n";
}
$aHTML[] = "</td>\n</tr>\n</table>";
$aHTML[] = "</div>\n</div>";
return implode($aHTML, "\n");
}
?>