Windows Graphviz Installation Instructions

From Wickle Wiki

Here it is, take it or leave it.

I've decided to help all of us Windows users incorporate graphviz into mediawiki.

Steps

  • Input this into localsettings.php, second to last line of file.


include("extensions/Graphviz.php");
$wgGraphVizSettings->dotCommand = "C:\\Program Files\\ATT\\Graphviz\\bin\\dot.exe";

Full code for localsettings.php:
<?php

# This file was automatically generated by the MediaWiki installer.
# If you make manual changes, please keep track in case you need to
# recreate them later.


$IP = "C:\\Program Files\\Apache2\\htdocs\\wiki";
ini_set( "include_path", ".;$IP;$IP/includes;$IP/languages" );
require_once( "includes/DefaultSettings.php" );

# If PHP's memory limit is very low, some operations may fail.
# ini_set( 'memory_limit', '20M' );

if ( $wgCommandLineMode ) {
	if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
		die( "This script must be run from the command line\n" );
	}
} elseif ( empty( $wgNoOutputBuffer ) ) {
	## Compress output if the browser supports it
	if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
}

$wgSitename         = "Wiki";

$wgScriptPath	    = "/wiki";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";

## If using PHP as a CGI module, use the ugly URLs
$wgArticlePath      = "$wgScript/$1";
# $wgArticlePath      = "$wgScript?title=$1";

$wgStylePath        = "$wgScriptPath/skins";
$wgStyleDirectory   = "$IP/skins";

$wgLogo             = "$wgStylePath/common/images/wiki.png";

$wgUploadPath       = "$wgScriptPath/images";
$wgUploadDirectory  = "$IP\\images";

$wgEnableEmail = true;
$wgEnableUserEmail = true;

$wgEmergencyContact = "email@wiki.com";
$wgPasswordSender	= "email@wiki.com";

## For a detailed description of the following switches see
## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
## There are many more options for fine tuning available see
## /includes/DefaultSettings.php
## UPO means: this is also a user preference option
$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

$wgDBserver         = "localhost";
$wgDBname           = "wikidb";
$wgDBuser           = "wikiuser";
$wgDBpassword       = "wikiuser";
$wgDBprefix         = "";

# If you're on MySQL 3.x, this next line must be FALSE:
$wgDBmysql4 = true;

# Experimental charset support for MySQL 4.1/5.0.
$wgDBmysql5 = false;

## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = array();

## To enable image uploads, make sure the 'images' directory
## is writable, then uncomment this:
$wgEnableUploads		= true;
$wgUseImageResize		= false;
# $wgUseImageMagick = true;
# $wgImageMagickConvertCommand = "/usr/bin/convert";

## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
# $wgHashedUploadDirectory = false;

## If you have the appropriate support software installed
## you can enable inline LaTeX equations:
# $wgUseTeX			= true;
$wgMathPath         = "{$wgUploadPath}/math";
$wgMathDirectory    = "{$wgUploadDirectory}/math";
$wgTmpDirectory     = "{$wgUploadDirectory}/tmp";

$wgLocalInterwiki   = $wgSitename;

$wgLanguageCode = "en";

$wgProxyKey = "41a11db93338978c6794c58841a6bec2265a5bb88c32c3433b34f4ad8b281";

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
# $wgDefaultSkin = 'monobook';

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
# $wgEnableCreativeCommonsRdf = true;
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
# $wgRightsCode = ""; # Not yet used

$wgDiff3 = "";
include("extensions/Graphviz.php");
$wgGraphVizSettings->dotCommand = "C:\\Program Files\\ATT\\Graphviz\\bin\\dot.exe";
?>


  • Now for the fun stuff, I've reset A LOT of settings in this graphviz.php file to work on a windows box. What really makes me mad is that their are like 3 how-to-install documents to view from on a google search. And none of them are worth crap. Especially the one that was on the page before this one. Honestly, I had to do this at my company so nice thing is "I GOT PAID TO DO THIS". But I'm not going to sit down and hold your hand through this (this thing pissed me off enough). Here's my graphviz.php in all it's glory:
<?php

# CoffMan (http://www.wickle.com) code adapted from timeline extension.
# Timeline extension
# To use, include this file from your LocalSettings.php
# To configure, set members of $wgGraphVizSettings after the inclusion

class GraphVizSettings {
	var $dotCommand;
};
$wgGraphVizSettings = new GraphVizSettings;
$wgGraphVizSettings->dotCommand = "C:\\Program Files\\ATT\\Graphviz\\bin\\dot.exe";

$wgExtensionFunctions[] = "wfGraphVizExtension";

function wfGraphVizExtension() {
	global $wgParser;
	$wgParser->setHook( "graphviz", "renderGraphviz" );
	#renderGraphviz (5);
}

function renderGraphviz( $timelinesrc )
{
	global $wgUploadDirectory, $wgUploadPath, $IP, $wgGraphVizSettings, $wgArticlePath, $wgTmpDirectory;
	$hash = md5( $timelinesrc );
	$dest = $wgUploadDirectory."\\graphviz\\";
	if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }
	if ( ! is_dir( $wgTmpDirectory ) ) { mkdir( $wgTmpDirectory, 0777 ); }

	$fname = $dest . $hash;
//	echo $fname;
	if ( ! ( file_exists( $fname.".png" ) || file_exists( $fname.".err" ) ) )
	{
		$handle = fopen($fname, "w");
		fwrite($handle, $timelinesrc);
		fclose($handle);

		$cmdline = wfEscapeShellArg( $wgGraphVizSettings->dotCommand) .
		  " -Tpng -o " . wfEscapeShellArg( $fname. ".png") . " " .
		  wfEscapeShellArg( $fname ) ;

		$cmdlinemap = wfEscapeShellArg( $wgGraphVizSettings->dotCommand) .
		  " -Tcmapx -o " . wfEscapeShellArg( $fname. ".map") . " " .
		  wfEscapeShellArg( $fname ) ;
//		echo $cmdline;
//		exit;
//		break;
//		echo "ADIOS";
		$ret = `"{$cmdline}"`;
		$ret = `"{$cmdlinemap}"`;

		unlink($fname);

/*
if ( $ret == "" ) {
			// Message not localized, only relevant during install
			return "<div id=\"toc\"><tt>Timeline error: Executable not found. Command line was: {$cmdline}</tt></div>";
		}
*/
	}

	@$err=file_get_contents( $fname.".err" );

	if ( $err != "" ) {
		$txt = "<div id=\"toc\"><tt>$err</tt></div>";
	} else {
		//echo $fname.".map";
		@$map = file_get_contents( $fname.".map" );
		//echo "mapa-antes:".$map;
		$map=preg_replace("#<ma(.*)>#"," ",$map);
		$map=str_replace("</map>","",$map);

		//echo "mapa:".$map;
		if (substr(php_uname(), 0, 7) == "Fucker") {
			$ext = "gif";
		} else {
			$ext = "png";
		}

		$txt  = "<map name=\"$hash\">{$map}</map>".
		        "<img usemap=\"#{$hash}\" src=\"{$wgUploadPath}/graphviz/{$hash}.{$ext}\">";
	}
	return $txt;
}

?>


  • THIS MAY LOOK A LOT LIKE THE GRAPHVIZ.PHP YOU'VE ALREADY DOWNLOADED - BUT IT'S NOT (THERE ARE SUBTLE DIFFERENCES).

Only about 4 lines changed and it was mainly syntax changes like adding a " or changing / to \, mainly what I found was when doing this was that I really hadn't configured wiki properly (especially the upload part of wiki).

  • So here's the deal. If you installed the graphviz windows installer program in it's default location then go to C:\program files\att and copy the directory graphviz to within your media wiki directory under the extensions folder EX: c:\program files\apache group\apache2\htdocs\wiki\extensions.


So your path to dot.exe will be "c:\program files\apache group\apache2\htdocs\wiki\extensions\graphviz\bin\dot.exe"

  • Your path to graphviz.php will be "c:\program files\apache group\apache2\htdocs\wiki\extensions\graphviz.php"
  • The images graphviz makes go to "c:\program files\apache group\apache2\htdocs\wiki\images\graphviz\*.png"
  • If you have problems take the */ and /* out of graphviz.php and re-cycle the wiki page. It will tell you the paths it's using for the most part.
  • Well if you didn't like this page tough - You got more from this then I got from the other pages (all 3 of them) I found.
  • If you did like this, and it helped then maybe the Good-Karma will come back around to me.

MOSTLY LOOK AT THE PATHS THAT ARE SET IN YOUR LOCALSETTINGS.PHP AND GRAPHVIZ.PHP AND MAKE SURE YOU UPDATE THE SYNTAX IN THE GRAPHVIZ.PHP PAGE TO REFLECT WHAT I CHANGED

Personal tools
This site is powered by Queres Tecnologias