2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: menu.inc.php,v 1.10 2011/01/25 15:01:01 henoheno Exp $
9 define('MENU_ENABLE_SUBMENU', FALSE);
12 define('MENU_SUBMENUBAR', 'MenuBar');
14 function plugin_menu_convert()
16 global $vars, $menubar;
19 $num = func_num_args();
21 // Try to change default 'MenuBar' page name (only)
22 if ($num > 1) return '#menu(): Zero or One argument needed';
23 if ($menu !== NULL) return '#menu(): Already set: ' . htmlsc($menu);
24 $args = func_get_args();
25 if (! is_page($args[0])) {
26 return '#menu(): No such page: ' . htmlsc($args[0]);
28 $menu = $args[0]; // Set
33 // Output menubar page data
34 $page = ($menu === NULL) ? $menubar : $menu;
36 if (MENU_ENABLE_SUBMENU) {
37 $path = explode('/', strip_bracket($vars['page']));
38 while(! empty($path)) {
39 $_page = join('/', $path) . '/' . MENU_SUBMENUBAR;
40 if (is_page($_page)) {
48 if (! is_page($page)) {
50 } else if ($vars['page'] === $page) {
51 return '<!-- #menu(): You already view ' . htmlsc($page) . ' -->';
54 $menutext = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m', '$1$2', get_source($page));
56 return preg_replace('/<ul[^>]*>/', '<ul>', convert_html($menutext));