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