2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: topicpath.inc.php,v 1.6 2005/01/29 14:31:04 henoheno Exp $
5 // 'topicpath' plugin for PukiWiki, available under GPL
7 // Show a link to $defaultpage or not
8 define('PLUGIN_TOPICPATH_TOP_DISPLAY', 1);
10 // Label for $defaultpage
11 define('PLUGIN_TOPICPATH_TOP_LABEL', 'Top');
13 // Separetor / of / topic / path
14 define('PLUGIN_TOPICPATH_TOP_SEPARATOR', ' / ');
16 // Show the page itself or not
17 define('PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY', 1);
19 // If PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY, add a link to itself
20 define('PLUGIN_TOPICPATH_THIS_PAGE_LINK', 0);
22 function plugin_topicpath_convert()
24 return '<div>' . plugin_topicpath_inline() . '</div>';
27 function plugin_topicpath_inline()
29 global $script, $vars, $defaultpage;
31 $page = isset($vars['page']) ? $vars['page'] : '';
32 if ($page == '' || $page == $defaultpage) return '';
34 $parts = explode('/', $page);
37 if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) {
38 $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK;
40 array_pop($parts); // Remove the page itself
43 $topic_path = array();
44 while (! empty($parts)) {
45 $_landing = join('/', $parts);
46 $landing = rawurlencode($_landing);
47 $element = htmlspecialchars(array_pop($parts));
49 // This page ($_landing == $page)
51 $topic_path[] = $element;
52 } else if (PKWK_READONLY && ! is_page($_landing)) {
54 $topic_path[] = $element;
56 // Page exists or not exists
57 $topic_path[] = '<a href="' . $script . '?' . $landing . '">' .
62 if (PLUGIN_TOPICPATH_TOP_DISPLAY)
63 $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL);
65 return join(PLUGIN_TOPICPATH_TOP_SEPARATOR, array_reverse($topic_path));