forked from resnostyle/mediafrontpage
/
widgets.php
executable file
·73 lines (66 loc) · 2.24 KB
/
widgets.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
<?php
require_once "config.php";
require_once "functions.php";
$wIndex = array();
foreach (glob("widgets/*.php") as $filename) {
include_once $filename;
}
function renderWidget($widget, $params = "") {
global $DEBUG;
switch ($widget["type"]) {
case "inline":
if($DEBUG) { echo "\n<!-- Calling Function:".$widget["function"]." -->\n"; }
eval($widget["function"]);
echo "\n";
break;
case "ajax":
echo "\n\t\t\t<div id=\"".$widget["block"]."\"></div>\n";
break;
case "header":
//Support header only widgets.
break;
case "mixed":
foreach( $widget["parts"] as $widgetsub ) {
renderWidget($widgetsub);
}
break;
default:
if(!empty($widget)) {
echo "\n\n<strong>INVALID WIDGET SPECIFIED (".$widget["block"].") in section ".$sectionId."</strong>\n<pre>".print_r($widget)."</pre>\n";
}
}
}
//Support the Widget "sytlesheet", "headerfunction", "headerinclude", "script" properties
function renderWidgetHeaders($widget, $params = "") {
global $DEBUG;
switch ($widget["type"]) {
case "ajax":
echo "\t\t<script type=\"text/javascript\" language=\"javascript\">\n";
$loader = (!empty($widget["loader"])) ? $widget["loader"] : "ajaxPageLoad('".$widget["call"]."', '".$widget["block"]."');";
if((int)$widget["interval"] > 0) {
echo "\t\t\tvar ".$widget["block"]."_interval = setInterval(\"".$loader."\", ".$widget["interval"].");\n";
}
echo "\t\t\t".$loader."\n";
echo "\t\t</script>\n";
break;
case "mixed":
foreach( $widget["parts"] as $widgetsub ) {
renderWidgetHeaders($widgetsub);
}
break;
}
if(!empty($widget["stylesheet"]) && (strlen($widget["stylesheet"]) > 0)) {
echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$widget["stylesheet"]."\">\n";
}
if(!empty($widget["script"]) && (strlen($widget["script"]) > 0)) {
echo "\t\t<link type=\"text/javascript\" language=\"javascript\ src=\"".$widget["script"]."\">\n";
}
if(!empty($widget["headerinclude"]) && (strlen($widget["headerinclude"]) > 0)) {
echo "\t\t".$widget["headerinclude"]."\n";
}
if(!empty($widget["headerfunction"]) && (strlen($widget["headerfunction"]) > 0)) {
if($DEBUG) { echo "\n<!-- Calling Function:".$widget["headerfunction"]." -->\n"; }
eval($widget["headerfunction"]);
}
}
?>