<?php
-/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
+// $Id: touchgraph.inc.php,v 1.10 2005/12/18 15:28:55 henoheno Exp $
//
-// $Id: touchgraph.inc.php,v 1.2 2003/05/16 05:59:32 arino Exp $
+// Output an index for 'TouchGraph WikiBrowser'
+// http://www.touchgraph.com/
//
-// TouchGraph http://www.touchgraph.com/index.html
+// Usage: (Check also TGWikiBrowser's sample)
+// java -Dfile.encoding=EUC-JP \
+// -cp TGWikiBrowser.jar;BrowserLauncher.jar com.touchgraph.wikibrowser.TGWikiBrowser \
+// http://<pukiwiki site>/index.php?plugin=touchgraph \
+// http://<pukiwiki site>/index.php? FrontPage 2 true
+//
+// Note: -Dfile.encoding=EUC-JP (or UTF-8) may not work with Windows OS
+// http://www.simeji.com/wiki/pukiwiki.php?Java%A4%CE%CD%AB%DD%B5 (in Japanese)
function plugin_touchgraph_action()
{
+ global $vars;
+
+ pkwk_headers_sent();
header('Content-type: text/plain');
- plugin_touchgraph_ref();
-// plugin_touchgraph_rel();
-
- die;
+ if (isset($vars['reverse'])) {
+ plugin_touchgraph_ref();
+ } else {
+ plugin_touchgraph_rel();
+ }
+ exit;
}
+
+// Normal
function plugin_touchgraph_rel()
{
- foreach (get_existpages() as $page)
- {
- if (file_exists(CACHE_DIR.encode($page).'.rel'))
- {
- $data = file(CACHE_DIR.encode($page).'.rel');
- echo mb_convert_encoding($page.' '.str_replace("\t",' ',trim($data[0]))."\n",'SJIS',SOURCE_ENCODING);
+ foreach (get_existpages() as $page) {
+ if (check_non_list($page)) continue;
+
+ $file = CACHE_DIR . encode($page) . '.rel';
+ if (file_exists($file)) {
+ echo $page;
+ $data = file($file);
+ foreach(explode("\t", trim($data[0])) as $name) {
+ if (check_non_list($name)) continue;
+ echo ' ', $name;
+ }
+ echo "\n";
}
}
}
+
+// Reverse
function plugin_touchgraph_ref()
{
- foreach (get_existpages() as $page)
- {
- if (file_exists(CACHE_DIR.encode($page).'.ref'))
- {
- $data = file(CACHE_DIR.encode($page).'.ref');
- $node = $page;
- foreach ($data as $line)
- {
- list($name) = explode("\t",$line);
- $node .= " $name";
+ foreach (get_existpages() as $page) {
+ if (check_non_list($page)) continue;
+
+ $file = CACHE_DIR . encode($page) . '.ref';
+ if (file_exists($file)) {
+ echo $page;
+ foreach (file($file) as $line) {
+ list($name) = explode("\t", $line);
+ if (check_non_list($name)) continue;
+ echo ' ', $name;
}
- echo mb_convert_encoding("$node\n",'SJIS',SOURCE_ENCODING);
+ echo "\n";
}
}
}