1<?php
2/**
3 * DokuWiki Plugin wikistats (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Chris4x4 <4x4.chris@gmail.com>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11
12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13require_once(DOKU_PLUGIN.'action.php');
14
15/**
16 * All DokuWiki plugins to extend the parser/rendering mechanism
17 * need to inherit from this class
18 */
19class action_plugin_wikistats extends DokuWiki_Action_Plugin {
20
21   /**
22    * Get an associative array with plugin info.
23    *
24    * <p>
25    * The returned array holds the following fields:
26    * <dl>
27    * <dt>author</dt><dd>Author of the plugin</dd>
28    * <dt>email</dt><dd>Email address to contact the author</dd>
29    * <dt>date</dt><dd>Last modified date of the plugin in
30    * <tt>YYYY-MM-DD</tt> format</dd>
31    * <dt>name</dt><dd>Name of the plugin</dd>
32    * <dt>desc</dt><dd>Short description of the plugin (Text only)</dd>
33    * <dt>url</dt><dd>Website with more information on the plugin
34    * (eg. syntax description)</dd>
35    * </dl>
36    * @param none
37    * @return Array Information about this plugin class.
38    * @public
39    * @static
40    */
41    function getInfo(){
42        return confToHash(dirname(__FILE__).'/plugin.info.txt');
43    }
44
45    /*
46     * Plugin should use this method to register its handlers with the dokuwiki's event controller
47     */
48    function register(&$controller) {
49        $controller->register_hook('PARSER_CACHE_USE', 'BEFORE',  $this, '_purgecache');
50    }
51
52    /**
53     * Check for pages changes and eventually purge cache.
54     */
55    function _purgecache(&$event, $param) {
56	global $ID;
57	$str = rawWiki($ID);
58	if (strpos($str, '{{wikistats') !== false) {
59	    $event->preventDefault();
60	    $event->stopPropagation();
61	    $event->result = false;
62	}
63    }
64}
65?>
66