1
<?php
2
/**
3
 * ODT Plugin: Exports to ODT
4
 *
5
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6
 * @author     Aurelien Bompard <aurelien@bompard.org>
7
 */
8
// must be run within Dokuwiki
9
if(!defined('DOKU_INC')) die();
10
11
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12
require_once(DOKU_PLUGIN.'action.php');
13
14
/**
15
 * Add the template as a page dependency for the caching system
16
 */
17
class action_plugin_odt extends DokuWiki_Action_Plugin {
18
19
    /**
20
     * return some info
21
     */
22
    function getInfo(){
23
        return confToHash(dirname(__FILE__).'/info.txt');
24
    }
25
26
    function register($controller) {
27
        $controller->register_hook('PARSER_CACHE_USE','BEFORE', $this, 'handle_cache_prepare');
28
    }
29
30
    function handle_cache_prepare(&$event, $param) {
31
        global $conf, $ID;
32
        $cache =& $event->data;
33
        // only the ODT rendering mode needs caching tweaks
34
        if ($cache->mode != "odt") return;
35
        $odt_meta = p_get_metadata($ID, 'relation odt');
36
        $template_name = $odt_meta["template"];
37
        if (!$template_name) {
38
            return;
39
        }
40
        $template_path = $conf['mediadir'].'/'.$this->getConf("tpl_dir")."/".$template_name;
41
        if (file_exists($template_path)) {
42
            $cache->depends['files'][] = $template_path;
43
        }
44
    }
45
46
}
47
48
// vim: set et ts=4 sw=4 fileencoding=utf-8 :