xref: /plugin/include/syntax/editbtn.php (revision 2524d4070dd2d3a04a927b4ad11e6ee8599a434b)
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, &$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, &$renderer, $data) {
35        global $lang;
36        list($page, $sect, $sect_title, $redirect_id) = $data;
37        if ($mode == 'xhtml') {
38            $title = ($sect) ? $sect_title : $page;
39            $params = array('do' => 'edit',
40                             'redirect_id' => $redirect_id,
41                             'id' => $page);
42            $xhtml .= '<div class="secedit">' . DOKU_LF;
43            $xhtml .= '<form class="button btn_incledit" method="post" action="' . DOKU_SCRIPT . '"><div class="no">' . DOKU_LF;
44            foreach($params as $key => $val) {
45                $xhtml .= '<input type="hidden" name="'.$key.'" ';
46                $xhtml .= 'value="'.htmlspecialchars($val).'" />';
47            }
48            $xhtml .= '<input type="submit" value="'.htmlspecialchars($lang['btn_secedit']).' (' . $page . ')" class="button" title="'.$title.'"/>' . DOKU_LF;
49            $xhtml .= '</div></form>' . DOKU_LF;
50            $xhtml .= '</div>' . DOKU_LF;
51            $renderer->doc .= $xhtml;
52            return true;
53        }
54        return false;
55    }
56}
57// vim:ts=4:sw=4:et:
58