OSDN Git Service

1c28d824b7b5345dda6211b3c6ed3fa2f02bdc24
[pukiwiki/pukiwiki.git] / plugin / include.inc.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: include.inc.php,v 1.12 2004/08/06 16:06:31 henoheno Exp $
6 //
7
8 // ¥Ú¡¼¥¸¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
9 function plugin_include_convert()
10 {
11         global $script, $vars, $get, $post, $menubar, $_msg_include_restrict;
12         static $included = array();
13
14         // Get an argument
15         if (func_num_args() == 0) return;
16         list($page) = func_get_args();
17         $page = strip_bracket($page);
18
19         // Loop yourself
20         $self = isset($vars['page']) ? $vars['page'] : '';
21         $included[$self] = TRUE;
22
23         // I'm stuffed
24         if (isset($included[$page]) || ! is_page($page)) return '';
25
26         // One page, only one time, at a time
27         $included[$page] = TRUE;
28
29         // Include a $page, that probably includes more pages
30         $get['page'] = $post['page'] = $vars['page'] = $page;
31         if (check_readable($page, false, false)) {
32                 $body = convert_html(get_source($page));
33         } else {
34                 $body = str_replace('$1', $page, $_msg_include_restrict);
35         }
36         $get['page'] = $post['page'] = $vars['page'] = $self;
37
38         // Add a title with edit link, before included document
39         $s_page = htmlspecialchars($page);
40         $r_page = rawurlencode($page);
41         $link = "<a href=\"$script?cmd=edit&amp;page=$r_page\">$s_page</a>";
42
43         if ($page == $menubar) {
44                 $body = "<span align=\"center\"><h5 class=\"side_label\">$link</h5></span>" .
45                         "<small>$body</small>";
46         } else {
47                 $body = "<h1>$link</h1>\n" .
48                         "$body\n";
49         }
50
51         return $body;
52 }
53 ?>