getConf('mode') & Diagrams::MODE_MEDIA)) return; $this->Lexer->addSpecialPattern('\{\{[^\}]+(?:\.svg)[^\}]*?\}\}',$mode,'plugin_diagrams_mediafile'); } /** * Parse SVG syntax into media data * * @param string $match * @param int $state * @param int $pos * @param Doku_Handler $handler * @return array|bool */ public function handle($match, $state, $pos, Doku_Handler $handler) { return Doku_Handler_Parse_Media($match); } /** * Render the diagram SVG as instead of to allow links, * except when rendering to a PDF * * @param string $format * @param Doku_Renderer $renderer * @param array $data * @return bool */ public function render($format, Doku_Renderer $renderer, $data) { if ($format !== 'xhtml') return false; $imageAttributes = array( 'class' => 'media', 'width' => $data['width'] ?: '', 'height' => $data['height'] ?: '', 'title' => $data['title'], ); if(is_a($renderer, 'renderer_plugin_dw2pdf')) { $imageAttributes['align'] = $data['align']; $imageAttributes['src'] = ml($data['src'], ['cache' => 'nocache'], true, '&'); $renderer->doc .= ''; } else { $imageAttributes['class'] .= ' diagrams-svg'; $imageAttributes['class'] .= ' media' . $data['align']; $imageAttributes['data'] = ml($data['src'], ['cache' => 'nocache'], true, '&'); $imageAttributes['data-id'] = cleanID($data['src']); $tag = ''; $renderer->doc .= sprintf($tag, buildAttributes($imageAttributes, true)); } return true; } }