OSDN Git Service

InterWikiName: Correct Google.jp => Google, Yahoo.jp => Yahoo
[pukiwiki/pukiwiki.git] / plugin / topicpath.inc.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: topicpath.inc.php,v 1.4 2004/08/12 13:02:26 henoheno Exp $
6 // topicpath plugin for PukiWiki
7 //   available under the GPL
8
9 // $defaultpage¤Ø¤Î¥ê¥ó¥¯¤âɽ¼¨¤¹¤ë¤«¤É¤¦¤«
10 // TRUE:ɽ¼¨¤¹¤ë FALSE:ɽ¼¨¤·¤Ê¤¤.
11 define('PLUGIN_TOPICPATH_TOP_DISPLAY', TRUE);
12 // $defaultpage¤ËÂФ¹¤ë¥é¥Ù¥ë
13 define('PLUGIN_TOPICPATH_TOP_LABEL', 'Top');
14
15 // ³¬Áؤò¶èÀڤ륻¥Ñ¥ì¡¼¥¿
16 define('PLUGIN_TOPICPATH_TOP_SEPARATOR', ' / ');
17
18 // ¤½¤Î¥Ú¡¼¥¸¼«¿È¤òɽ¼¨¤¹¤ë¤«
19 define('PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY', TRUE);
20 // É½¼¨¤¹¤ë¾ì¹ç¡¢¼«Ê¬¼«¿È¤ò»Ø¤¹¥ê¥ó¥¯¤òɽ¼¨¤¹¤ë¤«
21 define('PLUGIN_TOPICPATH_THIS_PAGE_LINK', FALSE);
22
23 function plugin_topicpath_convert()
24 {
25         return '<div>' . plugin_topicpath_inline() . '</div>';
26 }
27
28 function plugin_topicpath_inline()
29 {
30         global $script, $vars, $defaultpage;
31
32         // $args = func_get_args();
33
34         $page = isset($vars['page']) ? $vars['page'] : '';
35         if ($page == '' || $page == $defaultpage) return '';
36
37         $parts = explode('/', $page);
38
39         if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) {
40                 $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK;
41         } else {
42                 array_pop($parts); // Remove itself
43                 $b_link = TRUE;    // Link to the parent
44         }
45
46         $topic_path = array();
47         while (! empty($parts)) {
48                 $landing = rawurlencode(join('/', $parts));
49                 $element = htmlspecialchars(array_pop($parts));
50                 if ($b_link)  {
51                         $topic_path[] = "<a href=\"$script?$landing\">$element</a>";
52                 } else {
53                         $topic_path[] = $element;
54                         $b_link = TRUE; // Maybe reacheable once at a time
55                 }
56         }
57
58         if (PLUGIN_TOPICPATH_TOP_DISPLAY) {
59                 $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL);
60         }
61
62         return join(PLUGIN_TOPICPATH_TOP_SEPARATOR, array_reverse($topic_path));
63 }
64 ?>