OSDN Git Service

Remove media selector, use media query
[pukiwiki/pukiwiki.git] / plugin / topicpath.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: topicpath.inc.php,v 1.9 2011/01/25 15:01:01 henoheno Exp $
4 // Copyright (C)
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)
10 //
11 // 'topicpath' plugin for PukiWiki, available under GPL
12
13 // Show a link to $defaultpage or not
14 define('PLUGIN_TOPICPATH_TOP_DISPLAY', 1);
15
16 // Label for $defaultpage
17 define('PLUGIN_TOPICPATH_TOP_LABEL', 'Top');
18
19 // Separetor / of / topic / path
20 define('PLUGIN_TOPICPATH_TOP_SEPARATOR', ' / ');
21
22 // Show the page itself or not
23 define('PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY', 1);
24
25 // If PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY, add a link to itself
26 define('PLUGIN_TOPICPATH_THIS_PAGE_LINK', 0);
27
28 function plugin_topicpath_convert()
29 {
30         return '<div>' . plugin_topicpath_inline() . '</div>';
31 }
32
33 function plugin_topicpath_inline()
34 {
35         global $script, $vars, $defaultpage;
36
37         $page = isset($vars['page']) ? $vars['page'] : '';
38         if ($page == '' || $page == $defaultpage) return '';
39
40         $parts = explode('/', $page);
41
42         $b_link = TRUE;
43         if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) {
44                 $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK;
45         } else {
46                 array_pop($parts); // Remove the page itself
47         }
48
49         $topic_path = array();
50         while (! empty($parts)) {
51                 $_landing = join('/', $parts);
52                 $landing  = pagename_urlencode($_landing);
53                 $element  = htmlsc(array_pop($parts));
54                 if (! $b_link)  {
55                         // This page ($_landing == $page)
56                         $b_link = TRUE;
57                         $topic_path[] = $element;
58                 } else if (PKWK_READONLY && ! is_page($_landing)) {
59                         // Page not exists
60                         $topic_path[] = $element;
61                 } else {
62                         // Page exists or not exists
63                         $topic_path[] = '<a href="' . $script . '?' . $landing . '">' .
64                                 $element . '</a>';
65                 }
66         }
67
68         if (PLUGIN_TOPICPATH_TOP_DISPLAY)
69                 $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL);
70
71         return join(PLUGIN_TOPICPATH_TOP_SEPARATOR, array_reverse($topic_path));
72 }
73