1
0

* Fix a bug in statistics output, when statistics for single-number

months is created. (Andreas Bilke)
This commit is contained in:
Garvin Hicking
2009-10-09 13:02:41 +00:00
parent 18e02a5452
commit 89974bc7ae
3 changed files with 30 additions and 51 deletions

View File

@ -3,6 +3,9 @@
Version 1.5 () Version 1.5 ()
------------------------------------------------------------------------ ------------------------------------------------------------------------
* Fix a bug in statistics output, when statistics for single-number
months is created. (Andreas Bilke)
* Always increase last_modified when an entry is saved to prevent * Always increase last_modified when an entry is saved to prevent
stale entries in RSS feeds. Thanks to Cenic stale entries in RSS feeds. Thanks to Cenic

View File

@ -24,7 +24,7 @@ class serendipity_event_statistics extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_STATISTICS_DESC); $propbag->add('description', PLUGIN_EVENT_STATISTICS_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Arnan de Gans, Garvin Hicking, Fredrik Sandberg, kalkin'); $propbag->add('author', 'Arnan de Gans, Garvin Hicking, Fredrik Sandberg, kalkin');
$propbag->add('version', '1.48'); $propbag->add('version', '1.49');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -659,59 +659,33 @@ class serendipity_event_statistics extends serendipity_event
} //end of function countVisitor } //end of function countVisitor
// Calculate daily stats // Calculate daily stats
function statistics_getdailystats($day, $amount) { function statistics_getdailystats() {
global $serendipity; global $serendipity;
list($year, $month) = explode('-', date("Y-m")); list($year, $month) = explode('-', date("Y-m"));
if ($day > 0 && $day <32) { $sql = "SELECT SUM(visits) AS dailyvisit FROM {$serendipity['dbPrefix']}visitors_count WHERE day";
$sql = "SELECT SUM(visits) AS dailyvisit FROM {$serendipity['dbPrefix']}visitors_count WHERE day"; for ($i=1; $i<32; $i++) {
for ($i=1; $i<32; $i++) { $myDay = ($i < 10) ? "0" . $i : $i;
$sqlfire = $sql . " = '$i' AND year = '$year' AND month = '$month'"; $sqlfire = $sql . " = '$myDay' AND year = '$year' AND month = '$month'";
$res = serendipity_db_query($sqlfire, true); $res = serendipity_db_query($sqlfire, true);
$container[$i] = $res['dailyvisit']; $container[$i] = $res['dailyvisit'];
}
return $container;
} else if (!is_integer($day)) {
echo "Daycount failed - You've gotta specify a correct date(read: integer!)";
return "failure";
} else if ($day < 0 || $day > 32) {
echo "Daycount failed - Days only go from 1 to 31";
return "failure";
} }
return $container;
if (! isset($container)) {
$sql = "SELECT SUM(visits) FROM {$serendipity['dbPrefix']}visitors_count WHERE day = '$day' AND month = '$month' AND year = '$year'";
$res = serendipity_db_query($sql, true);
return $res;
}
} }
// Calculate monthly stats // Calculate monthly stats
function statistics_getmonthlystats($month, $amount) { function statistics_getmonthlystats() {
global $serendipity; global $serendipity;
$year = date("Y"); $year = date("Y");
if ($month > 0 && $month < 13) { $sql = "SELECT SUM(visits) AS monthlyvisit FROM {$serendipity['dbPrefix']}visitors_count WHERE month";
$sql = "SELECT SUM(visits) AS monthlyvisit FROM {$serendipity['dbPrefix']}visitors_count WHERE month"; for ($i=1; $i<13; $i++) {
for ($i=1; $i<13; $i++) { $myMonth = ($i < 10) ? "0" . $i : $i;
$sqlfire = $sql . " = '$i' AND year = '$year'"; $sqlfire = $sql . " = '$myMonth' AND year = '$year'";
$res = serendipity_db_query($sqlfire, true); $res = serendipity_db_query($sqlfire, true);
$container[$i] = $res['monthlyvisit']; $container[$i] = $res['monthlyvisit'];
}
return $container;
} else if (!is_integer($month)) {
echo "Monthcount failed - You've gotta specify a correct month(read: integer!)";
return "failure";
} else if ($month < 0 || $month > 13) {
echo "Monthcount failed - Months only go from 1 to 12";
return "failure";
}
if (!isset($container)) {
$sql = "SELECT SUM(visits) FROM {$serendipity['dbPrefix']}visitors_count WHERE month = '$month' AND year = '$year'";
$res = serendipity_db_query($sql, true);
return $res;
} }
return $container;
} }
function extendedVisitorStatistics($max_items){ function extendedVisitorStatistics($max_items){
@ -780,6 +754,10 @@ class serendipity_event_statistics extends serendipity_event
<table width="100%" cellpadding="0" cellspacing="0"><tr> <table width="100%" cellpadding="0" cellspacing="0"><tr>
<?php <?php
$color = "col2"; $color = "col2";
$num = $this->statistics_getmonthlystats();
$rep = $num;
rsort($rep);
$maxVisHeigh = 100/$rep[0]*2;
for ($i=1; $i < 13; $i++) { for ($i=1; $i < 13; $i++) {
if ($color == "col1") { if ($color == "col1") {
$color ="col2"; $color ="col2";
@ -787,10 +765,6 @@ class serendipity_event_statistics extends serendipity_event
$color ="col1"; $color ="col1";
} }
$num = $this->statistics_getmonthlystats($i, $visitors_count[0]);
$rep = $num;
rsort($rep);
$maxVisHeigh = 100/$rep[0]*2;
echo '<td class="'.$color.'" width="8%" align="center" valign="bottom"><small>' . $num[$i]; echo '<td class="'.$color.'" width="8%" align="center" valign="bottom"><small>' . $num[$i];
echo '<br /><img src="plugins/serendipity_event_statistics/'; echo '<br /><img src="plugins/serendipity_event_statistics/';
if ($num[$i]*$maxVisHeigh/2 <= 33) { if ($num[$i]*$maxVisHeigh/2 <= 33) {
@ -825,16 +799,16 @@ class serendipity_event_statistics extends serendipity_event
<table width="100%" cellpadding="0" cellspacing="0"><tr> <table width="100%" cellpadding="0" cellspacing="0"><tr>
<?php <?php
$color = "col2"; $color = "col2";
for ($i=1; $i < 32; $i++) { $num = $this->statistics_getdailystats();
$rep = $num;
rsort($rep);
for ($i=1; $i < 32; $i++) {
if ($color == "col1") { if ($color == "col1") {
$color ="col2"; $color ="col2";
} else { } else {
$color ="col1"; $color ="col1";
} }
$num = $this->statistics_getdailystats($i, $visitors_count[0]);
$rep = $num;
rsort($rep);
$maxVisHeigh = 100/$rep[0]*2; $maxVisHeigh = 100/$rep[0]*2;
echo '<td class="'.$color.'" width="3%" align="center" valign="bottom"><small>' . $num[$i]; echo '<td class="'.$color.'" width="3%" align="center" valign="bottom"><small>' . $num[$i];
echo '<br /><img src="plugins/serendipity_event_statistics/'; echo '<br /><img src="plugins/serendipity_event_statistics/';

View File

@ -165,7 +165,9 @@ class serendipity_plugin_comments extends serendipity_plugin
$cond['and'] = ' AND e.isdraft = \'false\' '; $cond['and'] = ' AND e.isdraft = \'false\' ';
if ($this->get_config('authorid') == 'login') { if ($this->get_config('authorid') == 'login') {
serendipity_ACL_SQL($cond, true); serendipity_ACL_SQL($cond, true);
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries'));
} }
$q = 'SELECT co.body AS comment, $q = 'SELECT co.body AS comment,
co.timestamp AS stamp, co.timestamp AS stamp,