2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: related.inc.php,v 1.6 2005/04/10 18:41:02 teanan Exp $
5 // Related plugin: Show Backlinks for the page
7 function plugin_related_convert()
11 return make_related($vars['page'], 'p');
14 // Show Backlinks: via related caches for the page
15 function plugin_related_action()
17 global $vars, $script, $non_list, $defaultpage, $whatsnew;
19 $_page = isset($vars['page']) ? $vars['page'] : '';
20 if ($_page == '') $_page = $defaultpage;
22 // Get related from cache
23 $data = links_get_related_db($_page);
25 // Hide by array keys (not values)
26 $non_list_pattern = '/' . $non_list . '/';
27 foreach(array_keys($data) as $page)
28 if ($page == $whatsnew ||
29 preg_match($non_list_pattern, $page))
34 $r_word = rawurlencode($_page);
35 $s_word = htmlspecialchars($_page);
36 $msg = 'Backlinks for: ' . $s_word;
37 $retval = '<a href="' . $script . '?' . $r_word . '">' .
38 'Return to ' . $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);