Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Nov 28, 2012
1 parent b8b0743 commit c170381
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
8 changes: 8 additions & 0 deletions action.php
Expand Up @@ -2,13 +2,21 @@
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

/**
* statdisplay plugin action component
*
* @author Andreas Gohr <gohr@cosmocode.de>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
class action_plugin_statdisplay extends DokuWiki_Action_Plugin {

function register($controller) {
$controller->register_hook('INDEXER_TASKS_RUN','AFTER', $this, 'handle_run');
}

/**
* Analyze the next chunk of data
*
* @param Doku_Event $event
* @param $param
*/
Expand Down
7 changes: 7 additions & 0 deletions graph.php
@@ -1,4 +1,11 @@
<?php
/**
* statdisplay plugin graph dispatcher
*
* @author Andreas Gohr <gohr@cosmocode.de>
* @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);
Expand Down
14 changes: 12 additions & 2 deletions helper/graph.php
@@ -1,5 +1,13 @@
<?php

// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

/**
* statdisplay plugin graph helper component
*
* @author Andreas Gohr <gohr@cosmocode.de>
* @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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions helper/log.php
@@ -1,5 +1,13 @@
<?php

// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

/**
* statdisplay plugin log helper component
*
* @author Andreas Gohr <gohr@cosmocode.de>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
class helper_plugin_statdisplay_log extends DokuWiki_Plugin {
public $logdata = array();
private $logcache = '';
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 9 additions & 1 deletion helper/table.php
@@ -1,5 +1,13 @@
<?php

// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

/**
* statdisplay plugin table helper component
*
* @author Andreas Gohr <gohr@cosmocode.de>
* @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;
Expand Down
15 changes: 5 additions & 10 deletions syntax.php
@@ -1,18 +1,13 @@
<?php
/**
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author J.-F. Lalande <jean-francois.lalande@ensi-bourges.fr>
* @author Maxime Fonda <maxime.fonda@ensi-bourges.fr>
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
* @author Andreas Gohr <gohr@cosmocode.de>
*/
// 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 <gohr@cosmocode.de>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
class syntax_plugin_statdisplay extends DokuWiki_Syntax_Plugin {

Expand Down

0 comments on commit c170381

Please sign in to comment.