1<?php
2/**
3 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Andreas Gohr <gohr@cosmocode.de>
5 */
6
7/**
8 * All DokuWiki plugins to extend the parser/rendering mechanism
9 * need to inherit from this class
10 */
11class action_plugin_navi extends DokuWiki_Action_Plugin
12{
13
14    /**
15     * plugin should use this method to register its handlers with the dokuwiki's event controller
16     */
17    function register(Doku_Event_Handler $controller)
18    {
19        $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handle_cache_prepare');
20    }
21
22    /**
23     * prepare the cache object for default _useCache action
24     */
25    function handle_cache_prepare(&$event, $param)
26    {
27        $cache =& $event->data;
28
29        // we're only interested in wiki pages
30        if (!isset($cache->page)) return;
31        if ($cache->mode != 'i') return;
32
33        // get meta data
34        $depends = p_get_metadata($cache->page, 'relation naviplugin');
35        if (!is_array($depends) || !count($depends)) return; // nothing to do
36        $cache->depends['files'] = !empty($cache->depends['files']) ? array_merge($cache->depends['files'],
37            $depends) : $depends;
38    }
39}
40