====== visio plugin ====== ---- plugin ---- description: Use the Microsoft ActiveX Visio Viewer to display embedded Visio diagrams author : Marc Hauswirth email : marc@practeo.ch type : syntax lastupdate : 2007-12-05 compatible : depends : conflicts : similar : video tags : embed, diagrams downloadurl: http://open.practeo.ch/dokuwiki-plugin/visio.zip ---- =====Background====== 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). ====== How to install ====== Download the file [[http://open.practeo.ch/dokuwiki-plugin/visio.zip|visio.zip]](4Kb) and unpack it into ''lib/plugins'' folder or use the [[plugin: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 [[http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=3fb3bd5c-fed1-46cf-bd53-da23635ab2df&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2f5%2f2%2f452f8090-413f-408f-83c0-edd66db786ee%2fvviewer.exe|Microsoft]]. ====Acknowledgment==== I borrowed some code from [[plugin:video|the video plugin]]. ====Syntax==== {{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). ====Code==== */ // 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 .= 'doc .= 'codebase="'.$this->getConf('codebase').'" id="viewer1" width="'.$width.'" height="'.$height.'">'."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' doc .= '">'."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ' '."\n"; $renderer->doc .= ''."\n"; $renderer->doc .= ''.$data['file'].'
'; return true; } return false; } } ?>
===== Configuration ===== There are some new configuration settings to set the default url for downloading the Microsoft Visio Viewer 2003 and default height and width. ====== Discussion ====== I've installed the PlugIn on my [[http://test.jurtenrunde.de/wiki/|Wiki]]. But if I have an vsd file - where I have to put it? (//in german://Ich habe das PlugIn installiert in meinem [[http://test.jurtenrunde.de/wiki/|Wiki]]. Doch muss mich ich die *.vsd Datei speichern, damit sie an gezeigt wird?) >It doesn't seem to work on Firefox... Hello, I've tried it with one Visio 2007 (*.VSD) and I got the message, that i have not the proper version of VisoViewer installed (but I have visioviewer.exe from MS-downloads). It looks like that because of the putting the extension to lower-case it assumes/expects now a Visio-File only up to Version 2003. Maybe the conversion of Upper to lowercase has to be overwritten for this file-type. And yes it doesn't work with Firefox (I assume also not with Safari) I just downloaded Visio 2007 viewer and this plugin. I think we should replace CLSID:279D6C9A-652E-4833-BEFC-312CA8887857 with new CLASID ? But in this moment my main problem is how to upload visio file (extension vsd is not allowed ?!?!). - Fox