, Christophe 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 = '
  • Download the file '.$id.'
  • '; $freemindlink = '
  • Use Freemind to edit it
  • '; /* 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 = '
  • Get the latest Java Plug-in here.
  • '; } 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("
    ". $object. // additional links "
    "; return $output; } function getUsage() { $help= '
    ';
    		$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.="
    "; return $help; } function generate_java($path2libs, $mindmap_url) { $output = "\n". "\n". " \n". " \n". " \n". " \n". " \n". " \n". "\n"; return $output; } function generate_flash($path2libs, $mindmap_url) { $output = "". "
    ". " Flash plugin or Javascript are turned off.". " Activate both and reload to view the mindmap". "
    ". ""; return $output; } }