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