User Tools

Site Tools


unix:osx:firestats_doku_plugin

Firestats Plugin for Dokuwiki

It is noted in the code, but I'll repeat it here:

This code is almost entirely copied from the Google Analytics plugin by Terence J. Grant. See his plugin page for details. Credit for the work should ostensibly be his- I merely deleted a few lines and changed a configuration name.

Concerning this rendering of the code:

See firestats.cc for information on what Firestats is and how to use it.

Plugin installation consists of:

  • Unarchiving the plugin .tgz file to your dokuwiki lib/plugins directory
  • Visiting the site Admin ⇒ Configuration page to set the URL for your firestats installation.

An example URL looks like: http://yoursite.com/yourfirestats/js/fs.js.php?site_id=2

Download

The plugin archive file is here.

Details

File/Directory structure:

dokufirestats/
dokufirestats/action.php
dokufirestats/lang/
dokufirestats/lang/en/
dokufirestats/lang/en/settings.php
dokufirestats/conf/
dokufirestats/conf/metadata.php

Action.php

<?php 
/*
*
* This code is almost entirely copied from the Google Analytics plugin by:
*
*	Terence J. Grant
*	See: http://www.dokuwiki.org/plugin:googleanalytics
*	
* My changes to the code were made on 05/05/2010.
*
*/

if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');

class action_plugin_dokufirestats extends DokuWiki_Action_Plugin {

	function getInfo(){

		return array(
			'author' => 'Benjamin Hall (base code from Terence J. Grant\'s Google Analytics Plugin)',
			'email'  => 'ben@benhall.com',
			'date'   => '2010-05-05',
			'name'   => 'Firestats Plugin',
			'desc'   => 'Plugin to call firestats on pageload',
			'url'    => 'http://benhall.com/doku/doku.php?id=firestats',
		);
	}
	
	function register(&$controller) {
	    $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE',  $this, '_addHeaders');
	}

	function _addHeaders (&$event, $param) {
		global $INFO;
		if(!$this->getConf('FIRESTATSURL')) return;
		if($this->getConf('dont_count_admin') && $INFO['isadmin']) return;
		if($this->getConf('dont_count_users') && $_SERVER['REMOTE_USER']) return;
		$event->data["script"][] = array (
		  "type" => "text/javascript",
		  "src" => $this->getConf('FIRESTATSURL'),
		);

	}
}
?>

Metadata.php

<?php
$meta['FIRESTATSURL'] = array('string');
$meta['dont_count_admin'] = array('onoff');
$meta['dont_count_users'] = array('onoff');
?>

Settings.php

<?php
$lang['FIRESTATSURL'] = 'Your Firestats Site URL:';
$lang['dont_count_admin'] = 'Don\'t count admin/superuser';
$lang['dont_count_users'] = 'Don\'t count logged in users';
?>
unix/osx/firestats_doku_plugin.txt · Last modified: 2013/03/19 05:34 by ben