From c17038183045b7488d1cffbac0742bf03a6c4792 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 28 Nov 2012 17:06:14 +0100 Subject: [PATCH] some cleanup --- action.php | 8 ++++++++ graph.php | 7 +++++++ helper/graph.php | 14 ++++++++++++-- helper/log.php | 17 ++++++++++------- helper/table.php | 10 +++++++++- syntax.php | 15 +++++---------- 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/action.php b/action.php index 42de5961d..d1f7fbca6 100644 --- a/action.php +++ b/action.php @@ -2,6 +2,12 @@ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); +/** + * statdisplay plugin action component + * + * @author Andreas Gohr + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + */ class action_plugin_statdisplay extends DokuWiki_Action_Plugin { function register($controller) { @@ -9,6 +15,8 @@ function register($controller) { } /** + * Analyze the next chunk of data + * * @param Doku_Event $event * @param $param */ diff --git a/graph.php b/graph.php index 4cdd7ace3..17391f69b 100644 --- a/graph.php +++ b/graph.php @@ -1,4 +1,11 @@ + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + */ + if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../'); define('DOKU_DISABLE_GZIP_OUTPUT', 1); diff --git a/helper/graph.php b/helper/graph.php index 499f1ea4a..38590ae76 100644 --- a/helper/graph.php +++ b/helper/graph.php @@ -1,5 +1,13 @@ + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + */ class helper_plugin_statdisplay_graph extends DokuWiki_Plugin { /** @var helper_plugin_statdisplay_log */ private $log = null; @@ -179,7 +187,7 @@ private function prevmonth($date){ } /** - * @param $date month to display + * @param string $date month to display */ private function userdownloads($date) { if(!$date) $date = date('Y-m'); @@ -207,6 +215,8 @@ private function userdownloads($date) { if(count($usertraffic)){ $avg = $alltraffic/count($usertraffic); $avg = $avg / 5; //work day average + }else{ + $avg = 0; } // prepare the graph datasets diff --git a/helper/log.php b/helper/log.php index 47558d6af..b64972a30 100644 --- a/helper/log.php +++ b/helper/log.php @@ -1,5 +1,13 @@ + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + */ class helper_plugin_statdisplay_log extends DokuWiki_Plugin { public $logdata = array(); private $logcache = ''; @@ -78,11 +86,6 @@ public function parseLogData() { $size = $parts[9]; $user = trim($parts[2],'"-'); - // FIXME fake user for debug - $fixme = array('', '', 'joey', 'jane', 'lara', 'john-schmoe'); - $user = $fixme[array_rand($fixme)]; - - if($status == 200) { $thistype = (substr($url, 0, 8) == '/_media/') ? 'media' : 'page'; if($thistype == 'page') { @@ -160,7 +163,7 @@ public function parseLogData() { $this->logdata['_logpos'] = $pos; // clean up the last month, freeing memory - if($this->logdata['_lastmonth'] != $month) { + if(isset($month) && $this->logdata['_lastmonth'] != $month) { $this->clean_month($this->logdata['_lastmonth']); $this->logdata['_lastmonth'] = $month; } diff --git a/helper/table.php b/helper/table.php index 54b1ae5cf..a2ff17b1a 100644 --- a/helper/table.php +++ b/helper/table.php @@ -1,5 +1,13 @@ + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + */ class helper_plugin_statdisplay_table extends DokuWiki_Plugin { /** @var helper_plugin_statdisplay_log */ private $log = null; diff --git a/syntax.php b/syntax.php index f790cea5d..404c3477d 100644 --- a/syntax.php +++ b/syntax.php @@ -1,18 +1,13 @@ - * @author Maxime Fonda - * @author Thibault Coullet - * @author Andreas Gohr - */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); + /** - * All DokuWiki plugins to extend the parser/rendering mechanism - * need to inherit from this class + * statdisplay plugin syntax component + * + * @author Andreas Gohr + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) */ class syntax_plugin_statdisplay extends DokuWiki_Syntax_Plugin {