OSDN Git Service

Simplify. Renive unused global, shrink, rename internal vars...
[pukiwiki/pukiwiki.git] / plugin / menu.inc.php
index 118d9f1..dfc5c38 100644 (file)
@@ -2,46 +2,44 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: menu.inc.php,v 1.2 2003/07/22 06:00:23 arino Exp $
+// $Id: menu.inc.php,v 1.5 2004/08/06 13:11:27 henoheno Exp $
 //
 
 // ¥µ¥Ö¥á¥Ë¥å¡¼¤ò»ÈÍѤ¹¤ë
-define('MENU_ENABLE_SUBMENU',FALSE);
+define('MENU_ENABLE_SUBMENU', FALSE);
+
+// ¥µ¥Ö¥á¥Ë¥å¡¼¤Î̾¾Î
+define('MENU_SUBMENUBAR', 'MenuBar');
 
 function plugin_menu_convert()
 {
-       global $script,$vars,$menubar;
+       global $vars, $menubar;
        static $menu = NULL;
-       
-       if (func_num_args())
-       {
+
+       if (func_num_args()) {
                $args = func_get_args();
-               if (is_page($args[0]))
-               {
-                       $menu = $args[0];
-               }
+               if (is_page($args[0])) $menu = $args[0];
                return '';
        }
-       
+
        $page = ($menu === NULL) ? $menubar : $menu;
-       if (MENU_ENABLE_SUBMENU)
-       {
-               $path = explode('/',strip_bracket($vars['page']));
-               while(count($path))
-               {
-                       $_page = join('/',$path).'/MenuBar';
-                       if (is_page($_page))
-                       {
+
+       if (MENU_ENABLE_SUBMENU) {
+               $path = explode('/', strip_bracket($vars['page']));
+               while(count($path)) {
+                       $_page = join('/', $path) . '/' . MENU_SUBMENUBAR;
+                       if (is_page($_page)) {
                                $page = $_page;
                                break;
                        }
                        array_pop($path);
                }
        }
-       if (!is_page($page))
-       {
+
+       if (! is_page($page)) {
                return '';
+       } else {
+               return preg_replace('/<ul[^>]*>/', '<ul>', convert_html(get_source($page)));
        }
-       return preg_replace('/<ul[^>]*>/','<ul>',convert_html(get_source($page)));
 }
 ?>