OSDN Git Service

Cleanup. Show read-link of the pages
[pukiwiki/pukiwiki.git] / plugin / include.inc.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: include.inc.php,v 1.15 2004/08/10 11:38:21 henoheno Exp $
6 //
7
8 define('INCLUDE_MAX', 4); // °ìÅ٤˥¤¥ó¥¯¥ë¡¼¥É¤Ç¤­¤ë¥Ú¡¼¥¸¤ÎºÇÂç¿ô
9
10 // ¥Ú¡¼¥¸¤ò(²Äǽ¤Ê¤é¤ÐºÆµ¢Åª¤Ë)¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
11 function plugin_include_convert()
12 {
13         global $script, $vars, $get, $post, $menubar, $_msg_include_restrict;
14         static $included = array();
15         static $count = 1;
16
17         if (func_num_args() == 0) return '#include(): No argument<br />';
18
19         // Get an argument
20         list($page) = func_get_args();
21         $page = strip_bracket($page);
22         $s_page = htmlspecialchars($page);
23         $r_page = rawurlencode($page);
24         $link = "<a href=\"$script?$r_page\">$s_page</a>"; // Read link
25
26         // Loop yourself
27         $root = isset($vars['page']) ? $vars['page'] : '';
28         $included[$root] = TRUE;
29
30         // I'm stuffed
31         if (isset($included[$page])) {
32                 return "#include(): Included already: $link<br />";
33         } if (! is_page($page)) {
34                 return "#include(): No such page: $s_page<br />";
35         } if ($count > INCLUDE_MAX) {
36                 return "#include(): Limit exceeded: $link<br />";
37         } else {
38                 ++$count;
39         }
40
41         // One page, only one time, at a time
42         $included[$page] = TRUE;
43
44         // Include A page, that probably includes another pages
45         $get['page'] = $post['page'] = $vars['page'] = $page;
46         if (check_readable($page, false, false)) {
47                 $body = convert_html(get_source($page));
48         } else {
49                 $body = str_replace('$1', $page, $_msg_include_restrict);
50         }
51         $get['page'] = $post['page'] = $vars['page'] = $root;
52
53         // Add a title with edit link, before included document
54         $link = "<a href=\"$script?cmd=edit&amp;page=$r_page\">$s_page</a>";
55
56         if ($page == $menubar) {
57                 $body = "<span align=\"center\"><h5 class=\"side_label\">$link</h5></span>" .
58                         "<small>$body</small>";
59         } else {
60                 $body = "<h1>$link</h1>\n" .
61                         "$body\n";
62         }
63
64         return $body;
65 }
66 ?>