xref: /plugin/include/syntax/editbtn.php (revision 6a1594b706c10b444f0c6b7749352b530c6f94c7)
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 getInfo() {
18        return array (
19            'author' => 'Gina Häußge, Michael Klier',
20            'email' => 'dokuwiki@chimeric.de',
21            'date' => @file_get_contents(DOKU_PLUGIN . 'blog/VERSION'),
22            'name' => 'Include Plugin (permalink header component)',
23            'desc' => 'Provides a header instruction which renders a permalink to the included page',
24            'url' => 'http://wiki.splitbrain.org/plugin:include',
25        );
26    }
27
28    function getType() {
29        return 'formatting';
30    }
31
32    function getSort() {
33        return 50;
34    }
35
36    function handle($match, $state, $pos, &$handler) {
37        // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
38    }
39
40    /**
41     * Renders an include edit button
42     *
43     * @author Michael Klier <chi@chimeric.de>
44     */
45    function render($mode, &$renderer, $data) {
46        list($page, $sect, $sect_title, $redirect_id) = $data;
47        if ($mode == 'xhtml') {
48            $tooltip = ($sect) ? $sect_title : $page;
49            $xhtml .= '<div class="secedit">';
50            $xhtml .= html_btn('secedit', $page, '', array('do' => 'edit',
51                                                       'redirect_id' => $redirect_id,
52                                                       'id' => $page),
53                                                       'post', $tooltip);
54            $xhtml .= '</div>';
55            $renderer->doc .= $xhtml;
56            return true;
57        }
58        return false;
59    }
60}
61// vim:ts=4:sw=4:et:enc=utf-8:
62