xref: /plugin/nodetailsxhtml/action.php (revision 94ec4299f20b4eee38c01cd83f6dc2803bb04e73)
1b07cf47aSGerry Weißbach<?php
2b07cf47aSGerry Weißbach/**
3b07cf47aSGerry Weißbach * Site Export Plugin
4b07cf47aSGerry Weißbach *
5b07cf47aSGerry Weißbach * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6b07cf47aSGerry Weißbach * @author     i-net software <tools@inetsoftware.de>
7b07cf47aSGerry Weißbach * @author     Gerry Weissbach <gweissbach@inetsoftware.de>
8b07cf47aSGerry Weißbach */
9b07cf47aSGerry Weißbach
10b07cf47aSGerry Weißbach// must be run within Dokuwiki
11b07cf47aSGerry Weißbachif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
12b07cf47aSGerry Weißbachif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13b07cf47aSGerry Weißbachrequire_once(DOKU_PLUGIN.'action.php');
14b07cf47aSGerry Weißbach
15b07cf47aSGerry Weißbachclass action_plugin_nodetailsxhtml extends DokuWiki_Action_Plugin {
16b07cf47aSGerry Weißbach
17b07cf47aSGerry Weißbach    /**
18b07cf47aSGerry Weißbach     * for backward compatability
19b07cf47aSGerry Weißbach     * @see inc/DokuWiki_Plugin#getInfo()
20b07cf47aSGerry Weißbach     */
21b07cf47aSGerry Weißbach    function getInfo(){
22b07cf47aSGerry Weißbach        if ( method_exists(parent, 'getInfo')) {
23b07cf47aSGerry Weißbach            $info = parent::getInfo();
24b07cf47aSGerry Weißbach        }
25b07cf47aSGerry Weißbach        return is_array($info) ? $info : confToHash(dirname(__FILE__).'/../plugin.info.txt');
26b07cf47aSGerry Weißbach    }
27b07cf47aSGerry Weißbach
28b07cf47aSGerry Weißbach        /**
29b07cf47aSGerry Weißbach    * Register Plugin in DW
30b07cf47aSGerry Weißbach    **/
3110f21024SGerry Weißbach    function register(Doku_Event_Handler $controller) {
32b07cf47aSGerry Weißbach        $controller->register_hook('TPL_TOC_RENDER', 'BEFORE', $this, 'check_toc');
33b07cf47aSGerry Weißbach    }
34b07cf47aSGerry Weißbach
35b07cf47aSGerry Weißbach    /**
36b07cf47aSGerry Weißbach    * Check for Template changes
37b07cf47aSGerry Weißbach    **/
389751fde1SGerry Weißbach    function check_toc( Doku_Event $event ) {
39b07cf47aSGerry Weißbach        global $conf, $INFO;
40b07cf47aSGerry Weißbach
41*94ec4299SGerry Weißbach        if ( empty($event->data) && array_key_exists( 'forceTOC', $INFO['meta'] ) && $INFO['meta']['forceTOC'] == true ) {
42b07cf47aSGerry Weißbach            $event->data = $INFO['meta']['description']['tableofcontents'];
43b07cf47aSGerry Weißbach        }
44b07cf47aSGerry Weißbach
45b07cf47aSGerry Weißbach    }
46b07cf47aSGerry Weißbach}
479751fde1SGerry Weißbach
489751fde1SGerry Weißbach//Setup VIM: ex: et ts=4 enc=utf-8 :