1<?php
2
3use dokuwiki\Extension\SyntaxPlugin;
4
5/**
6 * S5 Plugin: Display a Wiki page as S5 slideshow presentation
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Andreas Gohr <andi@splitbrain.org>
10 */
11class syntax_plugin_s5 extends SyntaxPlugin
12{
13    /** @inheritdoc */
14    public function getType()
15    {
16        return 'substition';
17    }
18
19    /** @inheritdoc */
20    public function getPType()
21    {
22        return 'normal';
23    }
24
25    /** @inheritdoc */
26    public function getSort()
27    {
28        return 800;
29    }
30
31    /** @inheritdoc */
32    public function connectTo($mode)
33    {
34        $this->Lexer->addSpecialPattern('~~SLIDESHOW[^~]*~~', $mode, 'plugin_s5');
35    }
36
37    /** @inheritdoc */
38    public function handle($match, $state, $pos, Doku_Handler $handler)
39    {
40        if ($match != '~~SLIDESHOW~~') return [trim(substr($match, 11, -2))];
41        return [];
42    }
43
44    /** @inheritdoc */
45    public function render($format, Doku_Renderer $renderer, $data)
46    {
47        global $ID;
48        if ($format != 'xhtml') return false;
49
50        $renderer->doc .= '<a href="' . exportlink($ID, 's5', count($data) ? ['s5theme' => $data[0]] : null) . '" title="' . $this->getLang('view') . '">';
51        $renderer->doc .= '<img src="' . DOKU_BASE . 'lib/plugins/s5/screen.gif" align="right" alt="' . $this->getLang('view') . '" width="48" height="48" />';
52        $renderer->doc .= '</a>';
53        return true;
54    }
55}
56