Jump to content

User:Mlong212

From mediawiki.org

All extensions have been installed on:

  • Product || Version
  • MediaWiki || 1.12.0
  • PHP || 5.2.5 (cgi-fcgi)
  • MySQL || 5.0.24-community-nt
  • OS || Windoes Server 2003

Extensions

[edit]

Graphviz

[edit]

Main page: Extension:GraphViz

Required: Graphviz webpage or direct file link

  • version 2.18

Some Windows operating systems may require run-time components of Visual C++ libraries to properly run Graphviz executables. click this link and install Microsoft Visual C++ 2005 Redistributable Package (x86).


Install directions

[edit]

1.) install graphviz software I installed it to w:\graphviz2.18

  • this path is referenced in the graphviz.php and needs to be changed to your install path

2.) add user rights

  • use file browser and find cmd.exe and give internet users read/execute access
  • give internet users read/execute access to the directory graphviz was installed to

3.) create Graphviz.php[1]

  • save into your mediawiki/extensions folder
  • edit about line 12 ( $wgGraphVizSettings->dotCommand = "w:\\graphviz2.18\\bin\\dot.exe"; ) to reflect your graphviz software installation
    • note the two "\\" between directories
<?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 = "w:\\graphviz2.18\\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;
}

?>

4.) edit mediawiki localsettings.php

  • add the following 2 lines:
include("extensions/Graphviz.php");
$wgGraphVizSettings->dotCommand = "W:\\Graphviz2.18\\bin\\DOT.exe";
    • change the dotcommand path to reflect your graphviz software installation
    • note the two "\\" between directory names


[edit]

use

node [URL="http://10.0.0.3//index.php?title=\N"];

where " title=\ " = " title=namespace\ "

where " \N" " will become the page title and is derived from the chart values


File:Graphviz with links


<graphviz>
digraph G {
node [style=filled, color=black, fillcolor=ghostwhite];
bgcolor="transparent";
node [URL="http://www.mediawiki.org/w/index.php?title=User:Mlong212/\N"];
size ="8,8";
Top[shape=box, style=filled, fillcolor=lightblue];
Bottom [style=filled, fillcolor=lightblue];
Top -> Branch1;
Top -> Branch2;
Top -> Branch3];
Branch1 -> sub1;
Branch2 -> Bottom;
sub3 -> "almost there";
Branch3 -> sub3;
sub1 -> Bottom;
"almost there" -> Bottom;
}
|}

Inkscape

[edit]

i gave up and installed imagemagick