1<?php
2/**
3 * @license    GPL 3 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Szymon Olewniczak <(my first name) [at] imz [dot] re>
5 * @author     Cejka Rudolf <cejkar@fit.vutbr.cz>
6 */
7
8// must be run within DokuWiki
9if(!defined('DOKU_INC')) die();
10
11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12require_once DOKU_PLUGIN.'syntax.php';
13
14/**
15 * All DokuWiki plugins to extend the parser/rendering mechanism
16 * need to inherit from this class
17 */
18class action_plugin_filterrss extends DokuWiki_Action_Plugin {
19    function register(Doku_Event_Handler $controller) {
20	$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, '_preventCache', array ());
21    }
22    /**
23     * Prevents page caching
24     * @param mixed $param the parameters passed to register_hook when this handler was registered
25     * @param object $event event object by reference
26     */
27    function _preventCache(&$event, $param)
28    {
29	$cache = $event->data;
30	if ($cache->mode != 'xhtml') return;
31	if (!isset($cache->page)) return;
32	$meta = p_get_metadata($cache->page, 'plugin_filterrss');
33	if (is_array($meta) && $meta['purge']) {
34	    $event->preventDefault();
35	    $event->stopPropagation();
36	    $event->result = false;
37	}
38    }
39}
40