-
Notifications
You must be signed in to change notification settings - Fork 0
/
e_dashboard.php
148 lines (104 loc) · 3.57 KB
/
e_dashboard.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
<?php
if (!defined('e107_INIT')) { exit; }
class lscache_dashboard // include plugin-folder in the name.
{
private $title; // dynamic title.
function chart()
{
$config = array();
$config[] = array(
'text' => $this->activity(),
'caption' => $this->title,
);
return $config;
}
/**
* Non-functional example.
* Chart of last 30 days.
* @return bool|string
*/
function activity()
{
$sql = e107::getDb();
$cht = e107::getChart();
$cht->setProvider('google');
$id = 'lscache_activity_chart';
$amt = array();
$ticks = array();
$data = array();
$width = '100%';
$height = 450;
$month_start = strtotime('1 month ago');
$month_end = time()+7200;
$label = date('M Y', $month_start)." - ".date('M Y', $month_end);
if(!$sql->gen("SELECT lscache_id,lscache_date,lscache_folder FROM `#lscache` WHERE lscache_date BETWEEN ".$month_start." AND ".$month_end))
{
return false;
}
while($row = $sql->fetch())
{
$key = date('Y-n-j', $row['lscache_date']);
switch($row['lscache_folder'])
{
case "Facebook":
$amt[$key]['facebook'] += 1;
break;
case "Google":
$amt[$key]['google'] += 1;
break;
case "Bing":
$amt[$key]['bing'] += 1;
break;
case "Friend":
$amt[$key]['friend'] += 1;
break;
default:
$amt[$key]['other'] += 1;
}
$dateName[$key] = date('jS', $row['lscache_date']);
}
$sum = array_sum($amt);
$data[] = array('Day', "Other", "Friend", "Bing", "Google", "Facebook" );
$this->title = 'Referrals ('.$sum.')';
// $c = 0;
foreach($amt as $k=>$v)
{
list($yearNumber,$monthNumber,$day) = explode('-',$k);
$diz = date('D jS', mktime(1,1,1,$monthNumber,$day, $yearNumber));
$data[] = array($diz, $v['other'], $v['friend'], $v['bing'], $v['google'], $v['facebook']); // $dateName[$i]
$ticks[] = $k;
// $c++;
}
$options = array(
'chartArea' =>array('left'=>'40', 'right'=>20, 'width'=>'100%', 'top'=>'30'),
'legend' => array('position'=> 'none', 'alignment'=>'center', 'textStyle' => array('fontSize' => 14, 'color' => '#ccc')),
'vAxis' => array('title'=>null, 'minValue'=>0, 'maxValue'=>10, 'titleFontSize'=>16, 'titleTextStyle'=>array('color' => '#ccc'), 'gridlines'=>array('color'=>'#696969', 'count'=>5), 'format'=>'', 'textStyle'=>array('color' => '#ccc') ),
'hAxis' => array('title'=>$label, 'slantedText'=>true, 'slantedTextAngle'=>60, 'ticks'=>$ticks, 'titleFontSize'=>14, 'titleTextStyle'=>array('color' => '#ccc'), 'gridlines' => array('color'=>'transparent'), 'textStyle'=>array('color' => '#ccc') ),
'colors' => array('#999999', '#0D9071','#FEB801', '#DC493C', '#3B5999'),
'animation' => array('duration'=>1000, 'easing' => 'out'),
'areaOpacity' => 0.8,
'isStacked' => true,
'backgroundColor' => array('fill' => 'transparent' )
);
$cht->setType('column');
$cht->setOptions($options);
$cht->setData($data);
return "<div>".$cht->render($id, $width, $height)."</div>";
}
function status() // Status Panel in the admin area
{
$var[0]['icon'] = "<img src='".e_PLUGIN."lscache/images/lscache_16.png' alt='' />";
$var[0]['title'] = "My Title";
$var[0]['url'] = e_PLUGIN_ABS."lscache/lscache.php";
$var[0]['total'] = 10;
return $var;
}
function latest() // Latest panel in the admin area.
{
$var[0]['icon'] = "<img src='".e_PLUGIN."lscache/images/lscache_16.png' alt='' />";
$var[0]['title'] = "My Title";
$var[0]['url'] = e_PLUGIN_ABS."lscache/lscache.php";
$var[0]['total'] = 10;
return $var;
}
}