xref: /plugin/include/syntax/locallink.php (revision 2ce032a785758436b78479066d4ecd9aa14cc355)
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
9if (!defined('DOKU_INC')) die('must be used inside DokuWiki');
10
11class syntax_plugin_include_locallink extends DokuWiki_Syntax_Plugin {
12
13    function getType() {
14        return 'formatting';
15    }
16
17    function getSort() {
18        return 50;
19    }
20
21    function handle($match, $state, $pos, &$handler) {
22        // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
23    }
24
25    /**
26     * Displays a local link to an included page
27     *
28     * @author Michael Hamann <michael@content-space.de>
29     */
30    function render($mode, &$renderer, $data) {
31        global $ID;
32        if ($mode == 'xhtml') {
33            /** @var Doku_Renderer_xhtml $renderer */
34            list($hash, $name, $id) = $data;
35            // construct title in the same way it would be done for internal links
36            $default = $renderer->_simpleTitle($id);
37            $name    = $renderer->_getLinkTitle($name, $default, $isImage, $id);
38            $title   = $ID.' ↵';
39            $renderer->doc .= '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
40            $renderer->doc .= $name;
41            $renderer->doc .= '</a>';
42            return true;
43        }
44        return false;
45    }
46}
47// vim:ts=4:sw=4:et:
48