57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
|
<?php
|
||
|
|
||
|
class syntax_plugin_bootstyle extends DokuWiki_Syntax_Plugin {
|
||
|
function getType(){
|
||
|
|
||
|
return 'substition';
|
||
|
}
|
||
|
function getPType(){
|
||
|
|
||
|
|
||
|
return 'block';
|
||
|
}
|
||
|
function getSort(){
|
||
|
|
||
|
return 300;
|
||
|
}
|
||
|
|
||
|
function connectTo($mode) {
|
||
|
$this->Lexer->addSpecialPattern('{{[^{}]*\.[pjg][npi][gf][^{}]*}}', $mode, 'plugin_bootstyle');
|
||
|
}
|
||
|
|
||
|
function handle($match, $state, $pos, Doku_Handler $handler){
|
||
|
echo "handle";
|
||
|
exit();
|
||
|
if ($state != DOKU_LEXER_SPECIAL) return array();
|
||
|
// $match will equal our full matching pattern, need to pull the image and size out
|
||
|
if (preg_match('/{{(.*\.[pjg][npi][gf])\??([0-9]*)x?([0-9]*)\|?(.*)}}/', html_entity_decode($match), $parts)) {
|
||
|
|
||
|
if (! $parts[2]) {
|
||
|
$parts[2] = 150;
|
||
|
$parts[3] = 150;
|
||
|
}
|
||
|
return $parts;
|
||
|
}
|
||
|
|
||
|
return array();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Create output
|
||
|
*/
|
||
|
function render($mode, Doku_Renderer $renderer, $data) {
|
||
|
echo "render";
|
||
|
exit();
|
||
|
if ($mode == 'xhtml' or $mode == 'htmldoc') {
|
||
|
list($all, $src, $width, $height, $title) = $data;
|
||
|
|
||
|
if (! preg_match('/^https?:/', $src)) {
|
||
|
$src = DOKU_BASE . "lib/exe/fetch.php?media=$src";
|
||
|
}
|
||
|
$renderer->doc .= "<a href=\"$src\" data-toggle=\"lightbox\"><img src=\"$src\" class=\"media\" width=\"$width\" height=\"$height\" alt=\"$title\" title=\"$title\" /></a>";
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
}
|