visio plugin by Marc Hauswirth
Use the Microsoft ActiveX Visio Viewer to display embedded visio diagrams
Last updated on 2007-12-05. Provides Syntax.
No compatibility info given!
Similar to video.
I have been working on making a documentation page for some network. We needed some inline Visio diagram display so that regular end user could be able to see the diagram without generating (non up to date image export).
Download the file visio.zip(4Kb) and unpack it into lib/plugins folder or use the plugin manager.
Download the (Free) Microsoft Visio Viewer 2003 and copy the .exe file to your server, then configure the plugin to have the correct path to offer the Visio viewer download to the end users.
Visio 2003 Viewer can be found under downloaded at Microsoft.
I borrowed some code from the video plugin.
{{my_visio_file.vsd[,width,height]|Alternate text}}
The plugin will generate the needed embedded object to view the visio file with Internet Explorer and Microsoft Visio Viewer 2003. (Ok, could be better, but quick and dirty solution).
<?php /** * Plugin Visio: Insert a ActiveX object to view Visio diagrams. * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Marc Hauswirth <marc@practeo.ch> */ // 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' => 'http://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 .= '<OBJECT classid="'.$this->getConf('classid').'" '; $renderer->doc .= 'codebase="'.$this->getConf('codebase').'" id="viewer1" width="'.$width.'" height="'.$height.'">'."\n"; $renderer->doc .= ' <param name="BackColor" value="16777200">'."\n"; $renderer->doc .= ' <param name="AlertsEnabled" value="1">'."\n"; $renderer->doc .= ' <param name="ContextMenuEnabled" value="1">'."\n"; $renderer->doc .= ' <param name="GridVisible" value="0">'."\n"; $renderer->doc .= ' <param name="HighQualityRender" value="0">'."\n"; $renderer->doc .= ' <param name="PageColor" value="16777215">'."\n"; $renderer->doc .= ' <param name="PageVisible" value="1">'."\n"; $renderer->doc .= ' <param name="PropertyDialogEnabled" value="1">'."\n"; $renderer->doc .= ' <param name="ScrollbarsVisible" value="1">'."\n"; $renderer->doc .= ' <param name="SizeGripVisible" value="1">'."\n"; $renderer->doc .= ' <param name="ToolbarVisible" value="1">'."\n"; $renderer->doc .= ' <param name="SRC" value="'; $renderer->doc .= DOKU_URL."lib/exe/fetch.php?id=".$data['file']."&cache=cache&media=".$data['file']; $renderer->doc .= '">'."\n"; $renderer->doc .= ' <param name="CurrentPageIndex" value="0">'."\n"; $renderer->doc .= ' <param name="Zoom" value="-1">'."\n"; $renderer->doc .= '</object>'."\n"; $renderer->doc .= '<a href="'.DOKU_URL.'lib/exe/fetch.php?id='.$data['file'].'&cache=cache&media='.$data['file'].'" class="media mediafile mf_vsd" title="'.$data['file'].'">'.$data['file'].'</a><br/>'; return true; } return false; } } ?>
There are some new configuration settings to set the default url for downloading the Microsoft Visio Viewer 2003 and default height and width.
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported