1<?php
2/**
3 * DokuWiki Plugin booking (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Andreas Gohr <dokuwiki@cosmocode.de>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) {
11    die();
12}
13
14class syntax_plugin_booking extends DokuWiki_Syntax_Plugin
15{
16    /**
17     * @return string Syntax mode type
18     */
19    public function getType()
20    {
21        return 'substition';
22    }
23
24    /**
25     * @return int Sort order - Low numbers go before high numbers
26     */
27    public function getSort()
28    {
29        return 155;
30    }
31
32    /**
33     * Connect lookup pattern to lexer.
34     *
35     * @param string $mode Parser mode
36     */
37    public function connectTo($mode)
38    {
39        $this->Lexer->addSpecialPattern('{{booking}}', $mode, 'plugin_booking');
40    }
41
42
43    /**
44     * Handle matches of the booking syntax
45     *
46     * @param string       $match   The match of the syntax
47     * @param int          $state   The state of the handler
48     * @param int          $pos     The position in the document
49     * @param Doku_Handler $handler The handler
50     *
51     * @return array Data for the renderer
52     */
53    public function handle($match, $state, $pos, Doku_Handler $handler)
54    {
55        $data = array();
56        return $data;
57    }
58
59    /**
60     * Render xhtml output or metadata
61     *
62     * @param string        $mode     Renderer mode (supported modes: xhtml)
63     * @param Doku_Renderer $renderer The renderer
64     * @param array         $data     The data from the handler() function
65     *
66     * @return bool If rendering was successful.
67     */
68    public function render($mode, Doku_Renderer $renderer, $data)
69    {
70        if ($mode !== 'xhtml') {
71            return false;
72        }
73
74        $renderer->doc .= '<div class="plugin_booking">loading...</div>';
75
76        return true;
77    }
78}
79
80