1<?php
2
3if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
4if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
5require_once(DOKU_PLUGIN.'syntax.php');
6
7/**
8 * All DokuWiki plugins to extend the parser/rendering mechanism
9 * need to inherit from this class
10 */
11class syntax_plugin_revealjs_notes extends DokuWiki_Syntax_Plugin {
12
13    public function getType() { return 'substition'; }
14    public function getSort() { return 32; }
15    public function getPType() { return 'block'; }
16
17
18    /**
19     * Connect lookup pattern to lexer.
20     *
21     * @param $aMode String The desired rendermode.
22     * @return none
23     * @public
24     * @see render()
25     */
26    public function connectTo($mode) {
27        $this->Lexer->addSpecialPattern('<\/?notes>', $mode, 'plugin_revealjs_notes');
28    }
29
30
31    /**
32     * Handler to prepare matched data for the rendering process.
33     *
34     * @param $aMatch String The text matched by the patterns.
35     * @param $aState Integer The lexer state for the match.
36     * @param $aPos Integer The character position of the matched text.
37     * @param $aHandler Object Reference to the Doku_Handler object.
38     * @return Integer The current lexer state for the match.
39     * @public
40     * @see render()
41     * @static
42     */
43    public function handle($match, $state, $pos, Doku_Handler $handler) {
44        return $match;
45    }
46
47    /**
48     * Handle the actual output creation.
49     *
50     * @param $aFormat String The output format to generate.
51     * @param $aRenderer Object A reference to the renderer object.
52     * @param $aData Array The data created by the <tt>handle()</tt>
53     * method.
54     * @return Boolean <tt>TRUE</tt> if rendered successfully, or
55     * <tt>FALSE</tt> otherwise.
56     * @public
57     * @see handle()
58     */
59    public function render($mode, Doku_Renderer $renderer, $data) {
60        if($mode == 'xhtml') {
61            if (is_a($renderer, 'renderer_plugin_revealjs')) {
62                switch ($data) {
63                    case '<notes>' :
64                        $renderer->doc .= DOKU_LF.'<aside class="notes">';
65                        $renderer->notes_open = true;
66                        break;
67                    case '</notes>' :
68                        $renderer->doc .= '</aside>'.DOKU_LF;
69                        $renderer->notes_open = false;
70                        break;
71                }
72            }
73            else if ($this->getConf('revealjs_active') && $this->getConf('show_slide_details')) {
74                switch ($data) {
75                    case '<notes>' :
76                        $renderer->doc .=
77                            '<div class="slide-notes-hr">Notes'.($slide_details_text).'</div>'.DOKU_LF;
78                        break;
79                }
80            }
81            return true;
82        }
83        return false;
84    }
85}
86