2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: include.inc.php,v 1.19 2004/10/21 12:27:40 henoheno Exp $
8 define('PLUGIN_INCLUDE_MAX', 4); // °ìÅ٤˥¤¥ó¥¯¥ë¡¼¥É¤Ç¤¤ë¥Ú¡¼¥¸¤ÎºÇÂç¿ô
10 define('PLUGIN_INCLUDE_WITH_TITLE', TRUE); // Default: TRUE
13 // ¥Ú¡¼¥¸¤ò(²Äǽ¤Ê¤é¤ÐºÆµ¢Åª¤Ë)¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
14 function plugin_include_convert()
16 global $script, $vars, $get, $post, $menubar, $_msg_include_restrict;
17 static $included = array();
20 $usage = "#include(): Usage: (a-page-name-you-want-to-include[,title|,notitle])<br />\n";
21 if (func_num_args() == 0) return $usage;
24 $args = func_get_args();
25 $page = isset($args[0]) ? strip_bracket(array_shift($args)) : '';
26 $with_title = PLUGIN_INCLUDE_WITH_TITLE;
27 if (isset($args[0])) {
28 switch(strtolower(array_shift($args))) {
29 case 'title' : $with_title = TRUE; break;
30 case 'notitle': $with_title = FALSE; break;
34 $s_page = htmlspecialchars($page);
35 $r_page = rawurlencode($page);
36 $link = "<a href=\"$script?$r_page\">$s_page</a>"; // Read link
39 $root = isset($vars['page']) ? $vars['page'] : '';
40 $included[$root] = TRUE;
43 if (isset($included[$page])) {
44 return "#include(): Included already: $link<br />\n";
45 } if (! is_page($page)) {
46 return "#include(): No such page: $s_page<br />\n";
47 } if ($count > PLUGIN_INCLUDE_MAX) {
48 return "#include(): Limit exceeded: $link<br />\n";
53 // One page, only one time, at a time
54 $included[$page] = TRUE;
56 // Include A page, that probably includes another pages
57 $get['page'] = $post['page'] = $vars['page'] = $page;
58 if (check_readable($page, false, false)) {
59 $body = convert_html(get_source($page));
61 $body = str_replace('$1', $page, $_msg_include_restrict);
63 $get['page'] = $post['page'] = $vars['page'] = $root;
65 // Add a title with edit link, before included document
67 $link = "<a href=\"$script?cmd=edit&page=$r_page\">$s_page</a>";
69 if ($page == $menubar) {
70 $body = '<span align="center"><h5 class="side_label">' .
71 $link . '</h5></span>' . "<small>$body</small>";
73 $body = "<h1>$link</h1>\n" . "$body\n";