mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Update logstats plugin to use chart class.
This commit is contained in:
@@ -89,7 +89,7 @@ foreach($incompat as $folder => $version)
|
|||||||
if($inCompatText)
|
if($inCompatText)
|
||||||
{
|
{
|
||||||
$text = "<ul>".$inCompatText."</ul>";
|
$text = "<ul>".$inCompatText."</ul>";
|
||||||
$mes->addWarning("The following plugins are not compatible with this version of e107 and should be <a href='".e_ADMIN."plugin.php'>uninstalled</a>: ".$text);
|
$mes->addWarning("The following plugins are not compatible with this version of e107 and should be uninstalled: ".$text."<a class='btn' href='".e_ADMIN."plugin.php'>uninstall</a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ class adminstyle_infopanel
|
|||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
|
|
||||||
$this->getStats();
|
|
||||||
|
|
||||||
global $user_pref; // quick fix.
|
global $user_pref; // quick fix.
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
@@ -306,64 +306,22 @@ EOF;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderChart()
|
private function renderChart()
|
||||||
{
|
{
|
||||||
$data = array();
|
|
||||||
|
|
||||||
$data['labels'] = array("Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday","Monday"); // change to this week.. ie. days of the week.
|
|
||||||
|
|
||||||
//TODO Stats for site visitors - members only.
|
|
||||||
$data['datasets'][] = array(
|
|
||||||
'fillColor' => "rgba(220,220,220,0.5)",
|
|
||||||
'strokeColor' => "rgba(220,220,220,1)",
|
|
||||||
'pointColor ' => "rgba(220,220,220,1)",
|
|
||||||
'pointStrokeColor' => "#fff",
|
|
||||||
'data' => array(65,59,90,81,56,55,40)
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//TODO Stats for site visitors - all
|
|
||||||
$data['datasets'][] = array(
|
|
||||||
'fillColor' => "rgba(151,187,205,0.5)",
|
|
||||||
'strokeColor' => "rgba(151,187,205,1)",
|
|
||||||
'pointColor ' => "rgba(151,187,205,1)",
|
|
||||||
'pointStrokeColor' => "#fff",
|
|
||||||
'data' => array(28,48,40,19,96,27,100)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$cht = e107::getChart();
|
|
||||||
$cht->setType('line');
|
|
||||||
$cht->setData($data,'canvas');
|
|
||||||
$text = $cht->render('canvas');
|
|
||||||
|
|
||||||
|
|
||||||
$text .= "<div class='center'><small>Please note: these are demo stats - upgrade work in progress.</small></div>";
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// REQUIRES Log Plugin to be installed.
|
// REQUIRES Log Plugin to be installed.
|
||||||
if (e107::isInstalled('log'))
|
if (e107::isInstalled('log'))
|
||||||
{
|
{
|
||||||
return $this->renderStats();
|
return $this->renderStats('log');
|
||||||
// $text2 .= $ns->tablerender("Visitors Last 10 Days", $this->renderStats(),"core-infopanel_stats",true);
|
|
||||||
}
|
}
|
||||||
elseif(e107::isInstalled('awstats'))
|
elseif(e107::isInstalled('awstats'))
|
||||||
{
|
{
|
||||||
return $this->renderStats();
|
return $this->renderStats('awstats');
|
||||||
// $text2 .= $ns->tablerender("Visitors this Month", $this->renderStats(),"core-infopanel_stats",true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "<div class='center' style='padding:20px'><a class='btn btn-small' href='".e_ADMIN."plugin.php?avail'>Install Site Stats Plugin</a></div>";
|
return $this->renderStats('demo');
|
||||||
// $text2 .= $ns->tablerender("Visitors This Week", "Log Statistics Plugin Not Installed","core-infopanel_stats",true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -707,20 +665,45 @@ EOF;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getStats()
|
private function getStats($type)
|
||||||
{
|
{
|
||||||
if(file_exists(e_PLUGIN."awstats/awstats.graph.php")) //FIXME Cam: Find a generic solution.
|
|
||||||
|
|
||||||
|
if(file_exists(e_PLUGIN."awstats/awstats.graph.php"))
|
||||||
{
|
{
|
||||||
require_once(e_PLUGIN."awstats/awstats.graph.php");
|
require_once(e_PLUGIN."awstats/awstats.graph.php");
|
||||||
return;
|
return $data;
|
||||||
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($type == 'demo')
|
||||||
if(!e107::isInstalled("log"))
|
|
||||||
{
|
{
|
||||||
return;
|
$data = array();
|
||||||
}
|
|
||||||
|
|
||||||
|
$data['labels'] = array("January","February","March","April","May","June","July");
|
||||||
|
|
||||||
|
|
||||||
|
$data['datasets'][] = array(
|
||||||
|
'fillColor' => "rgba(220,220,220,0.5)",
|
||||||
|
'strokeColor' => "rgba(220,220,220,1)",
|
||||||
|
'pointColor ' => "rgba(220,220,220,1)",
|
||||||
|
'pointStrokeColor' => "#fff",
|
||||||
|
'data' => array(65,59,90,81,56,55,40)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['datasets'][] = array(
|
||||||
|
'fillColor' => "rgba(151,187,205,0.5)",
|
||||||
|
'strokeColor' => "rgba(151,187,205,1)",
|
||||||
|
'pointColor ' => "rgba(151,187,205,1)",
|
||||||
|
'pointStrokeColor' => "#fff",
|
||||||
|
'data' => array(28,48,40,19,96,27,100)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql = e107::getDB();
|
$sql = e107::getDB();
|
||||||
|
|
||||||
@@ -812,58 +795,81 @@ EOF;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$visitors = array();
|
||||||
|
$unique = array();
|
||||||
|
|
||||||
|
|
||||||
ksort($dayarray);
|
ksort($dayarray);
|
||||||
foreach($dayarray as $k=>$v)
|
foreach($dayarray as $k=>$v)
|
||||||
{
|
{
|
||||||
$unix = strtotime($k);
|
$unix = strtotime($k);
|
||||||
|
|
||||||
$day[] = intval(vartrue($v['daytotal']));
|
$visitors[] = intval(vartrue($v['daytotal']));
|
||||||
|
$unique[] = intval(vartrue($v['dayunique']));
|
||||||
$label[] = "'".date("D",$unix)."'";
|
$label[] = "'".date("D",$unix)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
e107::js('log','js/awesomechart.js');
|
$data = array();
|
||||||
e107::js('inline',"
|
|
||||||
function drawMyChart()
|
$data['labels'] = $label;
|
||||||
{
|
|
||||||
if(!!document.createElement('canvas').getContext) //check that the canvas element is supported
|
//TODO Stats for site visitors - members only.
|
||||||
{
|
$data['datasets'][] = array(
|
||||||
var mychart = new AwesomeChart('canvas1');
|
'fillColor' => "rgba(220,220,220,0.5)",
|
||||||
|
'strokeColor' => "rgba(220,220,220,1)",
|
||||||
mychart.chartType = 'pareto';
|
'pointColor ' => "rgba(220,220,220,1)",
|
||||||
|
'pointStrokeColor' => "#fff",
|
||||||
|
'data' => $visitors
|
||||||
mychart.data = [".implode(", ",$day)."];
|
|
||||||
mychart.labels = [".implode(", ",$label)."];
|
);
|
||||||
mychart.colors = ['#0088CC', '#FF6600','#0088CC', '#FF6600','#0088CC', '#FF6600','#0088CC', '#FF6600','#0088CC'];
|
|
||||||
mychart.animate = true;
|
|
||||||
mychart.animationFrames = 30;
|
//TODO Stats for site visitors - all
|
||||||
// mychart.randomColors = true;
|
$data['datasets'][] = array(
|
||||||
// mychart.dataValueFontHeight = 20;
|
'fillColor' => "rgba(151,187,205,0.5)",
|
||||||
mychart.yAxisLabelFontHeight = 15;
|
'strokeColor' => "rgba(151,187,205,1)",
|
||||||
mychart.chartMarkerSize = 20;
|
'pointColor ' => "rgba(151,187,205,1)",
|
||||||
mychart.chartHorizontalLineStrokeStyle = '#999';
|
'pointStrokeColor' => "#fff",
|
||||||
mychart.chartHorizontalLineWidth = 1;
|
'data' => $unique
|
||||||
mychart.draw();
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = drawMyChart;
|
return $data;
|
||||||
|
|
||||||
");
|
|
||||||
|
|
||||||
// print_a($dayarray);;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderStats()
|
|
||||||
|
|
||||||
|
private function renderStats($type)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$data = $this->getStats($type);
|
||||||
|
|
||||||
|
|
||||||
return '<canvas id="canvas1" class="center" width="710" height="300" style="width:100%; height:100%">
|
$cht = e107::getChart();
|
||||||
Your web-browser does not support the HTML 5 canvas element.
|
$cht->setType('line');
|
||||||
</canvas>';
|
$cht->setData($data,'canvas');
|
||||||
|
$text = $cht->render('canvas');
|
||||||
|
|
||||||
|
|
||||||
|
if($type == 'demo')
|
||||||
|
{
|
||||||
|
$text .= "<div class='center'><small>These stats are for demonstration purposes only. <a class='btn btn-mini' href='".e_ADMIN."plugin.php?avail'>Install Site Stats Plugin</a></small></div>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= "<div class='center'><small>
|
||||||
|
<span style='color:rgba(220,220,220,0.5)'>♦</span> Visitors
|
||||||
|
<span style='color:rgba(151,187,205,1)'>♦</span> Unique Visitors
|
||||||
|
</small></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,7 +71,6 @@ class e_chart
|
|||||||
*/
|
*/
|
||||||
public function setType($type)
|
public function setType($type)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -101,7 +100,7 @@ class e_chart
|
|||||||
|
|
||||||
if($this->data == null)
|
if($this->data == null)
|
||||||
{
|
{
|
||||||
return "No chart data provided";
|
return "<div class='alert alert-info alert-block'>No chart data provided</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user