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