OSDN Git Service

Cleanup
[pukiwiki/pukiwiki.git] / plugin / touchgraph.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: touchgraph.inc.php,v 1.6 2005/01/03 12:37:45 henoheno Exp $
4 //
5 // Output an index for 'TouchGraph WikiBrowser'
6 // http://www.touchgraph.com/
7 //
8 // Usage: (Check also TGWikiBrowser's sample)
9 //    java -Dfile.encoding=EUC-JP \
10 //    -cp TGWikiBrowser.jar;BrowserLauncher.jar com.touchgraph.wikibrowser.TGWikiBrowser \
11 //    http://<pukiwiki site>/index.php?plugin=touchgraph \
12 //    http://<pukiwiki site>/index.php? FrontPage 2 true
13 //
14 // Note: -Dfile.encoding=EUC-JP (or UTF-8) may not work with Windows OS
15 //   http://www.simeji.com/wiki/pukiwiki.php?Java%A4%CE%CD%AB%DD%B5 (in Japanese)
16
17 define('PLUGIN_TOUCHGRAPH_REVERSE', 0);
18
19 function plugin_touchgraph_action()
20 {
21         pkwk_headers_sent();
22         header('Content-type: text/plain');
23         if (PLUGIN_TOUCHGRAPH_REVERSE) {
24                 plugin_touchgraph_ref(); // reverse
25         } else {
26                 plugin_touchgraph_rel();
27         }
28         exit;
29 }
30
31 function plugin_touchgraph_rel()
32 {
33         foreach (get_existpages() as $page) {
34                 $file = CACHE_DIR . encode($page) . '.rel';
35                 if (file_exists($file)) {
36                         echo $page;
37                         echo ' ';
38                         $data = file($file);
39                         echo str_replace("\t", ' ', trim($data[0]));
40                         echo "\n";
41                 }
42         }
43 }
44
45 function plugin_touchgraph_ref()
46 {
47         foreach (get_existpages() as $page) {
48                 $file = CACHE_DIR . encode($page) . '.ref';
49                 if (file_exists($file)) {
50                         echo $page;
51                         foreach (file($file) as $line) {
52                                 list($name) = explode("\t", $line);
53                                 echo ' ';
54                                 echo $name;
55                         }
56                         echo "\n";
57                 }
58         }
59 }
60 ?>