OSDN Git Service

Fix: '#vote'(No argument) confuse others listed below
[pukiwiki/pukiwiki.git] / plugin / touchgraph.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: touchgraph.inc.php,v 1.7 2005/01/03 12:59:01 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
18 function plugin_touchgraph_action()
19 {
20         global $vars;
21
22         pkwk_headers_sent();
23         header('Content-type: text/plain');
24         if (isset($vars['reverse'])) {
25                 plugin_touchgraph_ref();
26         } else {
27                 plugin_touchgraph_rel();
28         }
29         exit;
30 }
31
32 // Normal
33 function plugin_touchgraph_rel()
34 {
35         global $non_list;
36
37         $non_list_pattern = '#' . $non_list . '#';
38         foreach (get_existpages() as $page) {
39                 if (preg_match($non_list_pattern, $page)) continue;
40
41                 $file = CACHE_DIR . encode($page) . '.rel';
42                 if (file_exists($file)) {
43                         echo $page;
44                         $data = file($file);
45                         foreach(explode("\t", trim($data[0])) as $name) {
46                                 if (preg_match($non_list_pattern, $name)) continue;
47                                 echo ' ', $link;
48                         }
49                         echo "\n";
50                 }
51         }
52 }
53
54 // Reverse
55 function plugin_touchgraph_ref()
56 {
57         global $non_list;
58  
59         $non_list_pattern = '#' . $non_list . '#';
60         foreach (get_existpages() as $page) {
61                 if (preg_match($non_list_pattern, $page)) continue;
62
63                 $file = CACHE_DIR . encode($page) . '.ref';
64                 if (file_exists($file)) {
65                         echo $page;
66                         foreach (file($file) as $line) {
67                                 list($name) = explode("\t", $line);
68                                 if (preg_match($non_list_pattern, $name)) continue;
69                                 echo ' ', $name;
70                         }
71                         echo "\n";
72                 }
73         }
74 }
75 ?>