*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_visio extends DokuWiki_Syntax_Plugin {
function getInfo(){
return array(
'author' => 'Marc Hauswirth',
'email' => 'marc@practeo.ch',
'date' => '2007-12-05',
'name' => 'visio',
'desc' => 'Use the Microsoft ActiveX Visio Viewer to display visio diagrams \n simply put the file as
{{my_visio_file.vsd[,width,height]|Alternate text}}',
'url' => 'https://www.dokuwiki.org/plugin:visio',
);
}
function getType() { return 'substition'; }
function getSort() { return 10; }
function connectTo($mode) {
$this->Lexer->addSpecialPattern('{{[^}|]*\.vsd[^}]*}}',$mode,'plugin_visio');
}
function handle($match, $state, $pos, &$handler){
$data['full_data'] = $match;
$match = substr($match,2,-2);
list($filename,$alternate_text) = explode('|',$match);
$data['alternate_text'] = $alternate_text;
if (preg_match_all('/(.*),(.*),(.*)/',$filename,$matches))
{
$data['file'] = $matches[1][0];
$data['width'] = $matches[2][0];
$data['height'] = $matches[3][0];
}
else
{
$data['file'] = $filename;
}
return array($data, $state, $pos);
}
function render($mode, &$renderer, $data) {
if($mode == 'xhtml'){
$data = $data[0];
if (isset($data['width'])) { $width = $data['width']; } else { $width = $this->getConf('width');}
if (isset($data['height'])) { $height = $data['height']; } else { $height = $this->getConf('height');}
$renderer->doc .= ''."\n";
$renderer->doc .= ''.$data['file'].'
';
return true;
}
return false;
}
}