2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: topicpath.inc.php,v 1.9 2011/01/25 15:01:01 henoheno Exp $
5 // 2004-2005 PukiWiki Developers Team
6 // 2003 reimy (Some bug fix)
7 // 2003 t.m (Migrate to 1.3)
8 // 2003 Nibun-no-ni (Originally written for PukiWiki 1.4.x)
9 // License: GPL (any version)
11 // 'topicpath' plugin for PukiWiki, available under GPL
13 // Show a link to $defaultpage or not
14 define('PLUGIN_TOPICPATH_TOP_DISPLAY', 1);
16 // Label for $defaultpage
17 define('PLUGIN_TOPICPATH_TOP_LABEL', 'Top');
19 // Separetor / of / topic / path
20 define('PLUGIN_TOPICPATH_TOP_SEPARATOR', ' / ');
22 // Show the page itself or not
23 define('PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY', 1);
25 // If PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY, add a link to itself
26 define('PLUGIN_TOPICPATH_THIS_PAGE_LINK', 0);
28 function plugin_topicpath_convert()
30 return '<div>' . plugin_topicpath_inline() . '</div>';
33 function plugin_topicpath_inline()
35 global $script, $vars, $defaultpage;
37 $page = isset($vars['page']) ? $vars['page'] : '';
38 if ($page == '' || $page == $defaultpage) return '';
40 $parts = explode('/', $page);
43 if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) {
44 $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK;
46 array_pop($parts); // Remove the page itself
49 $topic_path = array();
50 while (! empty($parts)) {
51 $_landing = join('/', $parts);
52 $landing = pagename_urlencode($_landing);
53 $element = htmlsc(array_pop($parts));
55 // This page ($_landing == $page)
57 $topic_path[] = $element;
58 } else if (PKWK_READONLY && ! is_page($_landing)) {
60 $topic_path[] = $element;
62 // Page exists or not exists
63 $topic_path[] = '<a href="' . $script . '?' . $landing . '">' .
68 if (PLUGIN_TOPICPATH_TOP_DISPLAY)
69 $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL);
71 return join(PLUGIN_TOPICPATH_TOP_SEPARATOR, array_reverse($topic_path));