2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: related.inc.php,v 1.3 2005/01/15 14:25:58 henoheno Exp $
5 // Related plugin: Show Backlinks for the page
7 // TODO: move '#related' here
8 //function plugin_related_convert()
10 // global $related_link;
15 // Show Backlinks: via related caches for the page
16 function plugin_related_action()
18 global $vars, $script, $non_list, $defaultpage, $whatsnew;
20 $_page = isset($vars['page']) ? $vars['page'] : '';
21 if ($_page == '') $_page = $defaultpage;
23 // Get related from cache
24 $data = links_get_related_db($_page);
26 // Hide by array keys (not values)
27 $non_list_pattern = '/' . $non_list . '/';
28 foreach(array_keys($data) as $page)
29 if ($page == $whatsnew ||
30 preg_match($non_list_pattern, $page))
35 $s_word = htmlspecialchars($_page);
36 $msg = 'Backlinks for: ' . $s_word;
37 $retval = '<a href="' . $script . '?' . $s_word . '">' .
38 'Return ' . $s_word .'</a><br/>'. "\n";
41 $retval .= '<ul><li>No related pages found.</li></ul>' . "\n";
45 $retval .= '<ul>' . "\n";
46 foreach ($data as $page=>$time) {
47 $r_page = rawurlencode($page);
48 $s_page = htmlspecialchars($page);
49 $passage = get_passage($time);
50 $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page .
51 '</a> ' . $passage . '</li>' . "\n";
53 $retval .= '</ul>' . "\n";
55 return array('msg'=>$msg, 'body'=>$retval);