1<?php
2/**
3 * Include plugin (locallink component)
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author  Michael Hamann <michael@content-space.de>
7 */
8
9class syntax_plugin_include_locallink extends DokuWiki_Syntax_Plugin {
10
11    function getType() {
12        return 'formatting';
13    }
14
15    function getSort() {
16        return 50;
17    }
18
19    function handle($match, $state, $pos, Doku_Handler $handler) {
20        // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
21    }
22
23    /**
24     * Displays a local link to an included page
25     *
26     * @author Michael Hamann <michael@content-space.de>
27     */
28    function render($mode, Doku_Renderer $renderer, $data) {
29        global $ID;
30        if ($mode == 'xhtml') {
31            /** @var Doku_Renderer_xhtml $renderer */
32            list($hash, $name, $id) = $data;
33            // construct title in the same way it would be done for internal links
34            $default = $renderer->_simpleTitle($id);
35            $name    = $renderer->_getLinkTitle($name, $default, $isImage, $id);
36            $title   = $ID.' ↵';
37            $renderer->doc .= '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
38            $renderer->doc .= $name;
39            $renderer->doc .= '</a>';
40            return true;
41        }
42        return false;
43    }
44}
45// vim:ts=4:sw=4:et:
46