DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:visio

Visio Plugin

Compatible with DokuWiki

weatherwax

plugin Use the Microsoft ActiveX Visio Viewer to display embedded Visio diagrams

Last updated on
2007-12-05
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to video

Tagged with diagrams, embed

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 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.

Acknowledgment

I borrowed some code from 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

<?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;
    }
}
?>

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 Wiki. But if I have an vsd file - where I have to put it? (in german:Ich habe das PlugIn installiert in meinem 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

Fox to allow the extension just add it to the conf/mime.conf file. -Matt

Does it work with Chrome?

plugin/visio.txt · Last modified: 2015-12-24 16:46 by 93.81.204.244