1<?php
2/**
3 * DokuWiki Plugin pagehere (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Andreas Gohr <gohr@cosmocode.de>
7 */
8
9class syntax_plugin_pagehere extends DokuWiki_Syntax_Plugin {
10    public function getType() {
11        return 'substition';
12    }
13
14    public function getPType() {
15        return 'normal';
16    }
17
18    public function getSort() {
19        return 133;
20    }
21
22    public function connectTo($mode) {
23        $this->Lexer->addSpecialPattern('{{pagehere}}',$mode,'plugin_pagehere');
24    }
25
26    public function handle($match, $state, $pos, Doku_Handler $handler){
27        return [];
28    }
29
30    public function render($format, Doku_Renderer $renderer, $data) {
31        $renderer->info['cache'] = false;
32        if ($format != 'xhtml') return false;
33
34        global $INFO;
35        global $ID;
36        $check = $INFO['namespace'].':pagehere';
37        if (auth_quickaclcheck($check) < AUTH_EDIT) return;
38
39        $renderer->doc .= '<form class="plugin_pagehere" action="' . script() . '" method="GET">';
40        $renderer->doc .= '<input name="id" type="hidden" value="' . hsc($ID) . '" />';
41        $renderer->doc .= '<input name="pagehere" class="edit" type="text" id="page__here" />';
42        $renderer->doc .= '<input type="submit" value="' . $this->getLang('submit') . '" class="btn" />';
43        $renderer->doc .= '</form>';
44
45        return true;
46    }
47}
48// vim:ts=4:sw=4:et:
49