xref: /plugin/s5/syntax.php (revision f30cb4bf7440beafe7470de74f7433f91d52c6b0)
10f57655dSAndreas Gohr<?php
2*f30cb4bfSAndreas Gohr
3*f30cb4bfSAndreas Gohruse dokuwiki\Extension\SyntaxPlugin;
4*f30cb4bfSAndreas Gohr
50f57655dSAndreas Gohr/**
60f57655dSAndreas Gohr * S5 Plugin: Display a Wiki page as S5 slideshow presentation
70f57655dSAndreas Gohr *
80f57655dSAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
90f57655dSAndreas Gohr * @author     Andreas Gohr <andi@splitbrain.org>
100f57655dSAndreas Gohr */
11*f30cb4bfSAndreas Gohrclass syntax_plugin_s5 extends SyntaxPlugin
12*f30cb4bfSAndreas Gohr{
13*f30cb4bfSAndreas Gohr    /** @inheritdoc */
14*f30cb4bfSAndreas Gohr    public function getType()
15*f30cb4bfSAndreas Gohr    {
160f57655dSAndreas Gohr        return 'substition';
170f57655dSAndreas Gohr    }
180f57655dSAndreas Gohr
19*f30cb4bfSAndreas Gohr    /** @inheritdoc */
20*f30cb4bfSAndreas Gohr    public function getPType()
21*f30cb4bfSAndreas Gohr    {
220f57655dSAndreas Gohr        return 'normal';
230f57655dSAndreas Gohr    }
240f57655dSAndreas Gohr
25*f30cb4bfSAndreas Gohr    /** @inheritdoc */
26*f30cb4bfSAndreas Gohr    public function getSort()
27*f30cb4bfSAndreas Gohr    {
280f57655dSAndreas Gohr        return 800;
290f57655dSAndreas Gohr    }
300f57655dSAndreas Gohr
31*f30cb4bfSAndreas Gohr    /** @inheritdoc */
32*f30cb4bfSAndreas Gohr    public function connectTo($mode)
33*f30cb4bfSAndreas Gohr    {
3425ce19eaSAndreas Gohr        $this->Lexer->addSpecialPattern('~~SLIDESHOW[^~]*~~', $mode, 'plugin_s5');
350f57655dSAndreas Gohr    }
360f57655dSAndreas Gohr
37*f30cb4bfSAndreas Gohr    /** @inheritdoc */
38*f30cb4bfSAndreas Gohr    public function handle($match, $state, $pos, Doku_Handler $handler)
39*f30cb4bfSAndreas Gohr    {
40*f30cb4bfSAndreas Gohr        if ($match != '~~SLIDESHOW~~') return [trim(substr($match, 11, -2))];
41*f30cb4bfSAndreas Gohr        return [];
420f57655dSAndreas Gohr    }
430f57655dSAndreas Gohr
44*f30cb4bfSAndreas Gohr    /** @inheritdoc */
45*f30cb4bfSAndreas Gohr    public function render($format, Doku_Renderer $renderer, $data)
46*f30cb4bfSAndreas Gohr    {
470f57655dSAndreas Gohr        global $ID;
480f57655dSAndreas Gohr        if ($format != 'xhtml') return false;
490f57655dSAndreas Gohr
50*f30cb4bfSAndreas Gohr        $renderer->doc .= '<a href="' . exportlink($ID, 's5', count($data) ? ['s5theme' => $data[0]] : null) . '" title="' . $this->getLang('view') . '">';
510f57655dSAndreas Gohr        $renderer->doc .= '<img src="' . DOKU_BASE . 'lib/plugins/s5/screen.gif" align="right" alt="' . $this->getLang('view') . '" width="48" height="48" />';
520f57655dSAndreas Gohr        $renderer->doc .= '</a>';
530f57655dSAndreas Gohr        return true;
540f57655dSAndreas Gohr    }
550f57655dSAndreas Gohr}
56