1<?php
2/**
3 * Plugin imagereference
4 *
5 * Syntax: <tabref linkname> - creates a table link to a table
6 *         <tabcaption linkname <orientation> | Table caption> Table</tabcaption>
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Gerrit Uitslag <klapinklapin@gmail.com>
10 * @author     Philipp Imhof <dev@imhof.cc>
11 */
12
13if(!defined('DOKU_INC')) die();
14
15/**
16 * All DokuWiki plugins to extend the parser/rendering mechanism
17 * need to inherit from this class
18 */
19class syntax_plugin_imagereference_ggbcaption extends syntax_plugin_imagereference_imgcaption {
20
21    /**
22     * @return string Syntax type
23     */
24    public function getType() {
25        return 'formatting';
26    }
27    /**
28     * @return string Paragraph type
29     */
30    public function getPType() {
31        return 'block';
32    }
33    /**
34     * @return int Sort order
35     */
36    public function getSort() {
37        return 196;
38    }
39
40    /**
41     * Specify modes allowed in the ggbcaption tag
42     * Using getAllowedTypes() includes too much modes.
43     *
44     * @param string $mode Parser mode
45     * @return bool true if $mode is accepted
46     */
47    public function accepts($mode) {
48        $allowedsinglemodes = array(
49            'media', //allowed content
50            'plugin_geogebrembed_ggb'    //plugins
51        );
52        if(in_array($mode, $allowedsinglemodes)) return true;
53
54        return parent::accepts($mode);
55    }
56
57    /**
58     * Connect lookup pattern to lexer.
59     *
60     * @param string $mode Parser mode
61     */
62    public function connectTo($mode) {
63        $this->Lexer->addEntryPattern('<ggbcaption.*?>(?=.*?</ggbcaption>)', $mode, 'plugin_imagereference_ggbcaption');
64    }
65
66    public function postConnect() {
67        $this->Lexer->addExitPattern('</ggbcaption>', 'plugin_imagereference_ggbcaption');
68    }
69
70    /**
71     * @var string $captionStart opening tag of caption
72     * @var string $captionEnd closing tag of caption
73     */
74    protected $captionStart = '<div id="%s" class="ggbcaption%s">';
75    protected $captionEnd   = '</div>';
76
77}
78
79