xref: /plugin/include/syntax/editbtn.php (revision 69877801a94217e2716e9a4f2f69f88208bf14bf)
1<?php
2/**
3 * Include plugin (editbtn header component)
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author  Michael Klier <chi@chimeric.de>
7 */
8
9if (!defined('DOKU_INC'))
10    define('DOKU_INC', realpath(dirname(__FILE__) . '/../../') . '/');
11if (!defined('DOKU_PLUGIN'))
12    define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
13require_once (DOKU_PLUGIN . 'syntax.php');
14
15class syntax_plugin_include_editbtn extends DokuWiki_Syntax_Plugin {
16
17    function getType() {
18        return 'formatting';
19    }
20
21    function getSort() {
22        return 50;
23    }
24
25    function handle($match, $state, $pos, Doku_Handler $handler) {
26        // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
27    }
28
29    /**
30     * Renders an include edit button
31     *
32     * @author Michael Klier <chi@chimeric.de>
33     */
34    function render($mode, Doku_Renderer $renderer, $data) {
35        list($title) = $data;
36        if ($mode == 'xhtml') {
37            if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
38                $renderer->startSectionEdit(0, array('target' => 'plugin_include_editbtn', 'name' => $title));
39            } else {
40                $renderer->startSectionEdit(0, 'plugin_include_editbtn', $title);
41            }
42
43            $renderer->finishSectionEdit();
44            return true;
45        }
46        return false;
47    }
48}
49// vim:ts=4:sw=4:et:
50