xref: /plugin/nodetailsxhtml/syntax/forcetoc.php (revision 06b275ec441e0b05c99a464795ad0b3ee16d61c8)
1b07cf47aSGerry Weißbach<?php
2b07cf47aSGerry Weißbach/**
3b07cf47aSGerry Weißbach * iReflect 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ßbachif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
11b07cf47aSGerry Weißbachif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12b07cf47aSGerry Weißbach
13b07cf47aSGerry Weißbach/**
14b07cf47aSGerry Weißbach * All DokuWiki plugins to extend the parser/rendering mechanism
15b07cf47aSGerry Weißbach * need to inherit from this class
16b07cf47aSGerry Weißbach */
17b07cf47aSGerry Weißbachclass syntax_plugin_nodetailsxhtml_forcetoc extends DokuWiki_Syntax_Plugin {
18b07cf47aSGerry Weißbach
19b07cf47aSGerry Weißbach    function getInfo() {
20b07cf47aSGerry Weißbach        if ( method_exists(parent, 'getInfo')) {
21b07cf47aSGerry Weißbach            $info = parent::getInfo();
22b07cf47aSGerry Weißbach        }
23b07cf47aSGerry Weißbach        return array_merge(is_array($info) ? $info : confToHash(dirname(__FILE__).'/../plugin.info.txt'), array(
24b07cf47aSGerry Weißbach                        'desc' => 'Force the TOC to be inserted',
25b07cf47aSGerry Weißbach        ));
26b07cf47aSGerry Weißbach    }
27b07cf47aSGerry Weißbach
28b07cf47aSGerry Weißbach    function getType(){ return 'substition';}
29b07cf47aSGerry Weißbach
30b07cf47aSGerry Weißbach    function getSort(){ return 230; }
31b07cf47aSGerry Weißbach
32b07cf47aSGerry Weißbach    function connectTo($mode) {
33b07cf47aSGerry Weißbach        $this->Lexer->addSpecialPattern('~~forceTOC~~', $mode, 'plugin_nodetailsxhtml_forcetoc');
34b07cf47aSGerry Weißbach    }
35b07cf47aSGerry Weißbach
36*9751fde1SGerry Weißbach    function handle($match, $state, $pos, Doku_Handler $handler) {
37b07cf47aSGerry Weißbach        return $match;
38b07cf47aSGerry Weißbach    }
39b07cf47aSGerry Weißbach
40*9751fde1SGerry Weißbach    function render($mode, Doku_Renderer $renderer, $data) {
410313ced8SGerry Weißbach        global $ID, $INFO;
42b07cf47aSGerry Weißbach
43b07cf47aSGerry Weißbach        $renderer->info['forceTOC'] = true;
44b07cf47aSGerry Weißbach        $renderer->info['toc'] = true;
450313ced8SGerry Weißbach        $renderer->meta['internal']['forceTOC'] = true;
46b07cf47aSGerry Weißbach        return true;
47b07cf47aSGerry Weißbach    }
48b07cf47aSGerry Weißbach}
49b07cf47aSGerry Weißbach
50b07cf47aSGerry Weißbach//Setup VIM: ex: et ts=4 enc=utf-8 :