OSDN Git Service

Cleanup. Japanese => English.
[pukiwiki/pukiwiki.git] / plugin / include.inc.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: include.inc.php,v 1.19 2004/10/21 12:27:40 henoheno Exp $
6 //
7
8 define('PLUGIN_INCLUDE_MAX', 4); // °ìÅ٤˥¤¥ó¥¯¥ë¡¼¥É¤Ç¤­¤ë¥Ú¡¼¥¸¤ÎºÇÂç¿ô
9
10 define('PLUGIN_INCLUDE_WITH_TITLE', TRUE);      // Default: TRUE
11
12
13 // ¥Ú¡¼¥¸¤ò(²Äǽ¤Ê¤é¤ÐºÆµ¢Åª¤Ë)¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
14 function plugin_include_convert()
15 {
16         global $script, $vars, $get, $post, $menubar, $_msg_include_restrict;
17         static $included = array();
18         static $count = 1;
19
20         $usage = "#include(): Usage: (a-page-name-you-want-to-include[,title|,notitle])<br />\n";
21         if (func_num_args() == 0) return $usage;
22
23         // Get arguments
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;
31                 }
32         }
33
34         $s_page = htmlspecialchars($page);
35         $r_page = rawurlencode($page);
36         $link = "<a href=\"$script?$r_page\">$s_page</a>"; // Read link
37
38         // Loop yourself
39         $root = isset($vars['page']) ? $vars['page'] : '';
40         $included[$root] = TRUE;
41
42         // I'm stuffed
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";
49         } else {
50                 ++$count;
51         }
52
53         // One page, only one time, at a time
54         $included[$page] = TRUE;
55
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));
60         } else {
61                 $body = str_replace('$1', $page, $_msg_include_restrict);
62         }
63         $get['page'] = $post['page'] = $vars['page'] = $root;
64
65         // Add a title with edit link, before included document
66         if ($with_title) {
67                 $link = "<a href=\"$script?cmd=edit&amp;page=$r_page\">$s_page</a>";
68
69                 if ($page == $menubar) {
70                         $body = '<span align="center"><h5 class="side_label">' .
71                         $link . '</h5></span>' .  "<small>$body</small>";
72                 } else {
73                         $body = "<h1>$link</h1>\n" . "$body\n";
74                 }
75         }
76
77         return $body;
78 }
79 ?>