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