DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:freemind

Freemind Extension for Command Plugin

Compatible with DokuWiki

2005-09-22+

plugin Display Freemind Mindmaps in your wiki.

Last updated on
2006-04-02
Provides
Syntax
Requires
command

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

Tagged with command, extension, flash, freemind, java, mindmap

Overview

This command enables the display of Freemind mind maps in your Wiki. Freemind is handy, easy to use java mind-mapping software. You can find more information about Freemind here (including some screen shots).

This command integrates a java applet into your Wiki, which means that your visitors need to have the Java Plug-in installed in order to browse through your mind maps. This plugin does also provide a flash viewer with some additional features, if you want to avoid the standard java applet. The code for this command comes from another great Wiki software, the Wikka Wikki.

And thanks to the Freemind folks for developing this great mind-mapping application.

Used Libraries

The following libraries are used (and provided) by this plugin:

Changelog

2006-04-02

  • Added support for HTTPS, thanks to Alexander Clouter

2005-11-16

  • Added flash support, thanks to Christophe Ambroise

2005-11-05

  • Fixed a problem with the links.

2005-11-01

  • Initial release…

To-Do

  • Check for valid ID.
  • Update used libraries where possible
  • Clean-up this wiki-page and bring the source of freemind.php in sync with this page

Usage

A basic example using the java applet would look like :

 #freemind?width=300&javalink=false(namespace:mindmap.mm)#

A basic example using the flash browser plugin would look like:

 {{:namespace:mindmap.mm?400x400|alt}}

You can only show mind maps as a block outside paragraphs using #, in-line embedding with % is not intended. Mind maps are media files, use the media file selector to upload your mind maps and to paste the name of the file into your Wiki code.

Detailed Syntax

Command: freemind

Example:
    #freemind?width=200&type=flash(namespace:myMindmap.mm)#

Description:
    Shows a Freemind mindmap.

Content:
    Needs to be a valid ID of the mindmap. An empty string or 'help' shows this help.

Parameters:
    type (=flash|java): Type of display. For now, we allow flash and java (java is the default)
    width (=Number): Width of the displayed mindmap
    height (=Number): Height of the displayed mindmap
    downloadlink (=false|true): Display the download link below the mindmap? (enabled by default)
    freemindlink (=false|true): Display the link to the Freemind Homepage? (enabled by default)
    javalink (=false|true): Display the link to the Java Homepage? (enabled by default)

Installation

You need to have the Command plugin installed. Go here to find more information.

The actual installation consists of two steps:

Add new mime type to allow the upload of Freemind mind maps

Open the file ../conf/mime.conf in the DokuWiki directory and add the following line at the end:

   mm   text/xml

Place files into the command plug in directory

file is offline ? Download the file dokuwiki-freemind-20060402.zip from this location, unzip it and place all the files into the Command plugin's extensions-directory (../lib/plugins/command/ext) in your DokuWiki directory.

The content of the file dokuwiki-freemind-20060402.zip is as follows:

  • Base:
    • freemind.php
  • Java applet:
    • freemindbrowser.jar
  • Flash object:
    • flashobject.js and visorFreemind.swf
  • Download the freemind.php file below
  • Export a map from freemind to SWF. Look in the directory for the other files listed above.

Source

:!: This is the source of the base-part of this plugin (freemind.php). It clearly does not provide the source of the java applet or the flash object.

freemind.php
<?php
/**
* freemind Command: Displays a freemind mindmap
*
* The code used for this plugin comes from the Wikka Wikki: http://wikka.jsnx.com/FreeMind
* For a full description of this Command Plugin command, see: http://www.splitbrain.org/plugin:tagged
*
* @license    GPL2 and later (http://www.gnu.org/licenses/gpl.html)
* @author     Patrick Maué <http://www.q14.net>, Christophe Ambroise <http://www.hds.utc.fr/~ambroise>
*
* Changes: 
*  11/15/05 Added Flash support
*/
 
 
class CommandPluginExtension_freemind extends CommandPluginExtension
{
 
 
	function getCachedData($embedding, $params, $paramHash, $content,
	&$errorMessage) // STATIC
	{
 
 
		/* remove { or } brackets */
		$content = preg_replace('/{|}/','', $content);
 
		/* display usage if no mindmap is given as content */
		if((strcmp($content, "help") == 0) || (strcmp($content, "") == 0)) {
			return CommandPluginExtension_freemind::getUsage();
		}
 
		/* TODO: How to check if id is valid?
		if(! check url? ) {
		$errorMessage = "INVALID_FILE_ID: ".$content;
		return null;
		}
		*/
 
		/* get url to freemind map */
		$id = cleanId($content);
 
		$protocol = ( $_SERVER['HTTPS'] ) ? 'https' : 'http';
	  $mindmap_url = $protocol .'://'. $_SERVER['HTTP_HOST'] .ml($id,'',true); // should work now
 
		/* path to the libraries for the display, file path does not work */
		$path2libs = DOKU_BASE.'lib/plugins/command/ext/';
 
		/* the links are enabled by default (but can be disabled by parameter) */
		$downloadlink = '<li class="level1"><div class="li"> Download the file <a class="wikilink1" title="'.$id.'" href="'.$mindmap_url.'"> '.$id.'</a></div></li>';
		$freemindlink = '<li class="level1"><div class="li">Use <a href="http://freemind.sourceforge.net/">Freemind</a> to edit it</div></li>';
 
		/* java is the default view */
		$object = CommandPluginExtension_freemind::generate_java($path2libs, $mindmap_url);
 
		/* switch though through parameter */
		if(@count($params) > 0) {
			foreach($params as $var) {
 
				switch($var[0]) {
					case 'type': 
						if(strcmp($var[1],"java") == 0) {  // might add other display possibilites here (eg. SVG)
							$object = CommandPluginExtension_freemind::generate_java($path2libs, $mindmap_url);		
							$javalink = '<li class="level1"><div class="li">Get the latest Java Plug-in <a href="http://java.com/"> here.</a></div></li>';					 
						} else if(strcmp($var[1],"flash") == 0) { 
							$object = CommandPluginExtension_freemind::generate_flash($path2libs, $mindmap_url);		
						} else {
							$object = CommandPluginExtension_freemind::generate_java($path2libs, $mindmap_url);						 // java in every other case
						}
 
					break;
					case 'height':
					$style.='height:'.$var[1].'px;';
					$flashstyle .= 'height:'.$var[1].'px;';
					break;
					case 'width':
					$style.='width:'.$var[1].'px;';
					$flashstyle .= 'height:'.$var[1].'px;';
					break;
					case 'downloadlink':
					if(strcmp($var[1],"false") == 0) unset($downloadlink);
					break;
					case 'javalink':
					if(strcmp($var[1],"false") == 0) unset($javalink);
					break;
					case 'freemindlink':
					if(strcmp($var[1],"false") == 0) unset($freemindlink);
					break;
 
					/* add other parameter here */
					default:
					break;
				}
			}
		}
 
		// if (height or weight) and flash is requested, we add height to #flashid (has de be done here, because order of parametes is not defined)
		if(isset($flashstyle)) {
			$object = str_replace("<div ","<div style=\"".$flashstyle."\" " ,$object);
		}
 
		// set other style attributes for surrounding layer
		$style.="clear:both;";
 
 
 
		/* output for java applet */
		$output = "<div class=\"freemind\" id=\"flashcontent\" style=\"".$style."\">".
						$object.
						// additional links
						"<ul>";
		if(isset($javalink)) $output .= $javalink."\n";
		if(isset($downloadlink)) $output .= $downloadlink."\n";
		if(isset($freemindlink)) $output .= $freemindlink ."\n";
		$output .= "</ul></div>";
 
 
		return $output;
 
	}
 
	function getUsage() {
 
 
		$help= '<pre class="code">';
		$help.="Command: freemind \n \n";
 
		$help.="Example: \n    #freemind?width=200&type=flash(namespace:myMindmap.mm)# \n \n";
 
		$help.="Description: \n    Shows a Freemind mindmap. \n \n";
 
		$help.="Content: \n    Needs to be a valid ID of the mindmap. An empty string or 'help' shows this help. \n \n";
 
		$help.="Parameter: \n";
		$help.="    type (=flash|java): Type of display. For now, we allow flash and java (default)\n";
		$help.="    width (=Number): Width of the displayed mindmap\n";
		$help.="    height (=Number): Height of the displayed mindmap\n";
		$help.="    downloadlink (=false|true): Display the download link below the mindmap? (enabled by default)\n";
		$help.="    freemindlink (=false|true): Display the link to the Freemind Homepage? (enabled by default)\n";
		$help.="    javalink (=false|true): Display the link to the Java Homepage? (enabled by default)\n";
		$help.="</pre>";
		return $help;
 
 
	}
 
	function generate_java($path2libs, $mindmap_url) {
 
		$output =
		"<script type=\"text/javascript\">\n".
		"<!--\n".
		"    if(!navigator.javaEnabled()) {\n".
		"        document.write('<div class=\"freeminderror\"> Please install a <a href=\"http://www.java.com\">Java Runtime Environment<\/a> on your computer.</div>');\n".
		"    }\n".
		"//-->\n".
		"</script>\n".
		"<applet code=\"freemind.main.FreeMindApplet.class\" archive=\"".$path2libs."freemindbrowser.jar\" width=\"100%\" height=\"100%\">\n".
		"  <param name=\"type\" value=\"application/x-java-applet;version=1.4\" />\n".
		"  <param name=\"scriptable\" value=\"false\" />\n".
		"  <param name=\"modes\" value=\"freemind.modes.browsemode.BrowseMode\" />\n".
		"  <param name=\"browsemode_initial_map\" value=\"".$mindmap_url."\" />\n".
		"  <param name=\"initial_mode\" value=\"Browse\" />\n".
		"  <param name=\"selection_method\" value=\"selection_method_direct\" />\n".
		"</applet>\n</div>";
 
		return $output;
 
	}
 
	function generate_flash($path2libs, $mindmap_url) {
 
		$output =
		"<script type=\"text/javascript\" src=\"".$path2libs."flashobject.js\"></script>".
    "<div id=\"flashcontent\">".
		" Flash plugin or Javascript are turned off.".
		" Activate both and reload to view the mindmap".
	  "</div>".
  	"<script type=\"text/javascript\">".
		" var fo = new FlashObject(\"".$path2libs."visorFreemind.swf\", \"".$path2libs."visorFreeMind\", \"100%\", \"100%\", 6, \"#9999ff\");".
		" fo.addParam(\"quality\", \"high\");".
		" fo.addParam(\"bgcolor\", \"#ffffff\");".
		" fo.addVariable(\"openUrl\", \"_blank\");".
		" fo.addVariable(\"initLoadFile\", \"".$mindmap_url."\");".
		" fo.addVariable(\"startCollapsedToLevel\",\"5\");".
		" fo.addVariable(\"mainNodeShape\",\"rectangle\");".
		" fo.write(\"flashcontent\");".
    "</script>";
 
    return $output;
	}
}

Examples

Alternatives

I use the flash plugin along with Freemind flash browser to display my freemind maps in dokuwiki, for it seemed easier to install. Works out great so far. —berteh, Dec 2009

Discussion

Flash-only fork

I tried the last version of this plugins some times ago and … on my wiki, it doesn't work.
I checked the code, it used a old version of plugins implementation.

So I wrote a new version of freemind plugins with 3 differences:

  • new implementation
  • it only works in flash (with the bug-fix for flash 10)
  • it uses the same syntax as an image.

you can find the plugins and a how-to here

thanks for your feedback.
Aurelien ANTOINE 20081228

Heyas, thanks for contributing in keeping this thing alive… I've very quickly taken a look at your version and it seems quite neat… It didn't work here (always notice that Flash/JavaScript isn't enabled while surely enabled in my browser(s)) but I'm almost certain that that is due to my limit tries… I'll surely look at this later (as planned and announced here) but for now I'm too busy… Greetings,
Mischa The Evil 2008/12/29 22:30
At a first look this really seems to work great (tested FF3 and IE; old plugin did not work with IE and had problems in FF3). Thanks. 2009/1/10
Thanks for the renewed plugin! Just a hint!: I changed SAVEDIR in my local Dokuwiki installatin to a path at my home directory (to /home/user/dokuwiki/data). I have to changed in /plugins/freemind/syntax.php the entry $mm_file='data/media/'.str_replace(':','/',$data['filename']); to $mm_file='/home/user/dokuwiki/data/media/'.str_replace(':','/',$data['filename']); to do not get the error messages:
Error in {{:wiki:freemindflashbrowser.mm?600x400|alt text}}
data/media/wiki/freemindflashbrowser.mm not found
for a FreeMind Flash widget,
use the following syntax:
{{:namespace:filename.mm|alt}}

After this small change I could see the mindmap in Dokuwiki. But unfortunately the displaying of the included image does not work :?:. — krause (I am just a user. ;-)) 2009/09/25

I also changed the savedir in my installation so needed to change the plugin.

        function render($mode, &$renderer, $data){
                global $conf;  // SAVEDIR EDIT

                if($mode != 'xhtml') return false;

                if (empty($data['error'])) { //check MM filename
                        $mm_file= $conf['savedir'] . '/media/'.str_replace(':','/',$data['filename']);  // SAVEDIR EDIT

— Ian Rogers at contactclean com 2011/04/15

Better Navigation #1

Tested it with DokuWiki-2006-03-09b and “better navigation template” 2006-03-11. While the flash-Include works fine, in my installation it somehow breaks the layout below the plugin code, if the java-Version is included: Elements below the code are shown as with switched off CSS (at least with Firefox and opera).
Hella Breitkopf 2006-06-21–20:30

I am using Firefox 2.0.0.7, Modify freemind.php line 115, remove code </div> to solve the problem.

	function getCachedData($embedding, $params, $paramHash, $content,
	&$errorMessage) // STATIC
	{
:
:
:
		if(isset($freemindlink)) $output .= $freemindlink ."\n";
		$output .= "</ul>"; ///>>>>>>Original Code "</ul></div>";
 
 
		return $output;
 
	}
> 


Jonathan Tsai 2007-10-12 05:56

Better Navigation #2

I have the same problem and am using the same better navigation plugin. Additional I experienced that my wikitext below the mind map overlaps with the link to the mind map and the stuff which is by default generated by the plugin. Additionally, the browser does not realize that there is any contend below the flash part if there is only the data generated by the plugin itself ( link to freemind and stuff like mentioned before). So if you have one big freemind map on a page and made it for example 800*800 big you can not scroll to the aer ea of the page where the additional information from the plugin is placed, because the browser does not recognize this content. I am using Firefox 1.5.0.6
Unknown User

For above the solution would be to modify the function generate_java to change the last line before outpup to
"</applet>\n";


	function generate_java($path2libs, $mindmap_url) {
 
		$output =
		"<script type=\"text/javascript\">\n".
		"<!--\n".
		"    if(!navigator.javaEnabled()) {\n".
		"        document.write('<div class=\"freeminderror\"> Please install a <a href=\"http://www.java.com\">Java Runtime Environment<\/a> on your computer.</div>');\n".
		"    }\n".
		"//-->\n".
		"</script>\n".
		"<applet code=\"freemind.main.FreeMindApplet.class\" archive=\"".$path2libs."freemindbrowser.jar\" width=\"100%\" height=\"100%\">\n".
		"  <param name=\"type\" value=\"application/x-java-applet;version=1.4\" />\n".
		"  <param name=\"scriptable\" value=\"false\" />\n".
		"  <param name=\"modes\" value=\"freemind.modes.browsemode.BrowseMode\" />\n".
		"  <param name=\"browsemode_initial_map\" value=\"".$mindmap_url."\" />\n".
		"  <param name=\"initial_mode\" value=\"Browse\" />\n".
		"  <param name=\"selection_method\" value=\"selection_method_direct\" />\n".
		"</applet>\n</div>"; ///>>>>>>CHANGE TO "</applet>\n";
 
		return $output;
 
	}


Unknown User

Real Plugin

Would it possible to create the PHP files into a 'real' plugin that can be managed through the Plugin Manager ?
Thanks in advance
charlieMOGUL 2006/12/06 10:00

Hey, charlieMOGUL
I am not actively maintaining this plugin anymore (not even using DokuWiki anymore, sorry ;) ). I did choose the command plugin when I started this plugin due to its simplicity, and I didn't really bother to learn more about the 'real' plugin engine behind DokuWiki . And when it was implemented there was no such thing like a Plugin Manager. Anyway, of course it would be great if someone more skilled in DokuWiki plugins can copy my code (which is nothing special) and creates a plugin which can be handled by the Plugin Mangager.
Patrick Maué, who doesn't even know is login anymore

HTTPS support

Hi, HTTPS support does not work on my W2K IIS with PHP 4.4.1 installed. After changing Line 43 in freemind.php from

$protocol = ( $_SERVER['HTTPS'] ) ? 'https' : 'http';

to

$protocol = ( $_SERVER['HTTPS'] == "on" ) ? 'https' : 'http';

it works for me. I dont know if this works on an Apache webserver and Linux as well. Maybe someone can test it.
andi 01.02.2006 17:30 MEZ

not working for me on Linux/Apache, do I need fopen to be enabled?
— happy DokuWiki user

Freemind XML -> DokuWiki Translator

Hi guys, thanks for this great piece of work. I am using this plugin to display meeting notes catched using Freemind. But the problem is that this plugin needs a huge place in the page to be really a usable viewer. And if you give it a huge place, it is destroying the page layout.

So I wrote a very simple and quick translator from Freemind XML (native format in the mm file) to basic DokuWiki syntax, using headers and bullet lists. You can give it a try at this location: http://prog.13.free.fr/freemind2dokuwiki/ Source code is published under GPL, right click to see and download it and change anything you want.

Hope this will help :) Frederic Monjo

Future of this plugin

Since I think this is a great plugin which deserves to stay alive I've added a new source to the original plugin package. I also did some more major cleanup to this page. .
I'll soon update the plugin with some slight modifications/updates (probably flash-only).
Mischa The Evil 2008/12/04 01:39

Problems with Java

Hi! I integrated the Plug-In as described, but when I take a look at the output, I get the following message: “Flash plugin or JavaScript are turned off. Activate both and reload to view the mindmap.” I tested it with three browsers (Firefox, Safari, Internet Explorer) but the results were the same (Java and Flash are switched on in all of them). What is wrong?

Thanks, Chris

Hmmm, that seems odd. I've tested both the Java-applet and the Flash-object and both seems to work fine with DokuWiki 2008-05-05…

Are you absolutely certain that:
* the command plugin is installed successfully?
* you've added the new mime type (for *.mm) to allow the upload of Freemind mind maps?
* you've placed the files from the downloaded archive into the command plug in directory (../lib/plugins/command/ext)?
* you are using the correct syntax (e.g: #freemind?width=950&height=500(:mindmapfile.mm)#)?

Also important: What does your logs say and what platform are we talking about?

Mischa The Evil 2008/12/12 21:59
Hi Mischa,

Thanks for responding quickly! I re-checked everything you wrote, but it helped nothing. But perhaps this part of the Java Console Log gives answers (the freemind.main.FreeMindApplet.class was not found):

java.lang.ClassNotFoundException: freemind.main.FreeMindApplet.class
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://www.diekolumne1.de/dokuwiki-2008-05-05/freemind/main/FreeMindApplet/class.class
	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 7 more



This url: http://www.diekolumne1.de/dokuwiki-2008-05-05/freemind/main/FreeMindApplet/class.class does not exist on my server. I don´t know, where the programe gets it. My Machine ist WinXP. Perhaps I should test it on an Apple?

Greetz
chris

Hey Chris,
Sorry for the delay in my response, but I'm currently pretty busy. Regarding your problem with the Java-part of the plugin: Since I'm not a user of the Java-part (I'm using my personally modified Flash only version which I wanted to prepare for public release earlier) and having too less time I'm not able to test the Java-implementation (extensive). Thereby I personally don't like the implementation using the Java-applet so I'm not very willing to invest limited spare-time on it. Though YMMV
Maybe others around here are better able to help you than I am…??

Greetings,

Mischa The Evil 2008/12/29 22:39

Hi. I am also having problems using this addin… will the revised be ready soon. I am using the last release candidate

Will there be an update?

Thanks Misha for this great plugin. This still works on the main wiki but does not work on the dokuanimal. any suggestions?

plugin/freemind.txt · Last modified: 2015-06-24 21:23 by Klap-in