xref: /plugin/vshare/syntax/debug.php (revision 5895dcbaf50020ca1f8fb63a4a2057581cbcca11)
1b82f24afSAndreas Gohr<?php
2*5895dcbaSAndreas Gohr
3*5895dcbaSAndreas Gohruse dokuwiki\Extension\SyntaxPlugin;
4*5895dcbaSAndreas Gohr
5b82f24afSAndreas Gohr/**
6b82f24afSAndreas Gohr * DokuWiki Plugin vshare (Syntax Component)
7b82f24afSAndreas Gohr *
8b82f24afSAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
9b82f24afSAndreas Gohr * @author  Andreas Gohr <andi@splitbrain.org>
10b82f24afSAndreas Gohr */
11*5895dcbaSAndreas Gohrclass syntax_plugin_vshare_debug extends SyntaxPlugin
12b82f24afSAndreas Gohr{
13b82f24afSAndreas Gohr    /** @inheritDoc */
14b82f24afSAndreas Gohr    public function getType()
15b82f24afSAndreas Gohr    {
16b82f24afSAndreas Gohr        return 'substition';
17b82f24afSAndreas Gohr    }
18b82f24afSAndreas Gohr
19b82f24afSAndreas Gohr    /** @inheritDoc */
20b82f24afSAndreas Gohr    public function getPType()
21b82f24afSAndreas Gohr    {
22b82f24afSAndreas Gohr        return 'block';
23b82f24afSAndreas Gohr    }
24b82f24afSAndreas Gohr
25b82f24afSAndreas Gohr    /** @inheritDoc */
26b82f24afSAndreas Gohr    public function getSort()
27b82f24afSAndreas Gohr    {
28b82f24afSAndreas Gohr        return 155;
29b82f24afSAndreas Gohr    }
30b82f24afSAndreas Gohr
31b82f24afSAndreas Gohr    /** @inheritDoc */
32b82f24afSAndreas Gohr    public function connectTo($mode)
33b82f24afSAndreas Gohr    {
34b82f24afSAndreas Gohr        if ($this->getConf('debug')) {
35b82f24afSAndreas Gohr            $this->Lexer->addSpecialPattern('~~vshare-debug~~', $mode, 'plugin_vshare_debug');
36b82f24afSAndreas Gohr        }
37b82f24afSAndreas Gohr    }
38b82f24afSAndreas Gohr
39b82f24afSAndreas Gohr    /** @inheritDoc */
40b82f24afSAndreas Gohr    public function handle($match, $state, $pos, Doku_Handler $handler)
41b82f24afSAndreas Gohr    {
42b82f24afSAndreas Gohr        return [];
43b82f24afSAndreas Gohr    }
44b82f24afSAndreas Gohr
45b82f24afSAndreas Gohr    /** @inheritDoc */
46b82f24afSAndreas Gohr    public function render($mode, Doku_Renderer $renderer, $handlerdata)
47b82f24afSAndreas Gohr    {
48b82f24afSAndreas Gohr        if ($mode !== 'xhtml') {
49b82f24afSAndreas Gohr            return false;
50b82f24afSAndreas Gohr        }
51b82f24afSAndreas Gohr
52b82f24afSAndreas Gohr        $sites = helper_plugin_vshare::loadSites();
53b82f24afSAndreas Gohr        $syntax = new syntax_plugin_vshare_video();
54b82f24afSAndreas Gohr        $handler = new \Doku_Handler();
55b82f24afSAndreas Gohr
56b82f24afSAndreas Gohr
57b82f24afSAndreas Gohr        $renderer->header('vshare sites', 1, 0);
58b82f24afSAndreas Gohr
59b82f24afSAndreas Gohr        foreach ($sites as $site => $info) {
60b82f24afSAndreas Gohr            $renderer->header($site, 2, 0);
61b82f24afSAndreas Gohr
62b82f24afSAndreas Gohr            if (!empty($info['vid'])) {
63b82f24afSAndreas Gohr                $data = $syntax->handle("{{ $site>{$info['vid']} }}", DOKU_LEXER_MATCHED, 0, $handler);
64b82f24afSAndreas Gohr                $syntax->render($mode, $renderer, $data);
65b82f24afSAndreas Gohr            } else {
66b82f24afSAndreas Gohr                $renderer->p_open();
67b82f24afSAndreas Gohr                $renderer->smiley('FIXME');
68b82f24afSAndreas Gohr                $renderer->cdata(' No sample video ID available');
69b82f24afSAndreas Gohr                $renderer->p_close();
70b82f24afSAndreas Gohr            }
71b82f24afSAndreas Gohr
72b82f24afSAndreas Gohr            if (!empty($info['web'])) {
73b82f24afSAndreas Gohr                $renderer->p_open();
74b82f24afSAndreas Gohr                $renderer->externallink($info['web']);
75b82f24afSAndreas Gohr                $renderer->p_close();
76b82f24afSAndreas Gohr            } else {
77b82f24afSAndreas Gohr                $renderer->p_open();
78b82f24afSAndreas Gohr                $renderer->smiley('FIXME');
79b82f24afSAndreas Gohr                $renderer->cdata(' No sample video available');
80b82f24afSAndreas Gohr                $renderer->p_close();
81b82f24afSAndreas Gohr            }
82b82f24afSAndreas Gohr        }
83b82f24afSAndreas Gohr
84b82f24afSAndreas Gohr        return true;
85b82f24afSAndreas Gohr    }
86b82f24afSAndreas Gohr}
87