7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2008 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: menu.inc.php 1114 2008-10-24 06:23:15Z fishbone $
14 * @link http://www.magic3.org
17 define('MENU_ENABLE_SUBMENU', FALSE);
20 define('MENU_SUBMENUBAR', 'MenuBar');
22 function plugin_menu_convert()
24 //global $vars, $menubar;
27 $num = func_num_args();
29 // Try to change default 'MenuBar' page name (only)
30 if ($num > 1) return '#menu(): Zero or One argument needed';
31 if ($menu !== NULL) return '#menu(): Already set: ' . htmlspecialchars($menu);
32 $args = func_get_args();
33 if (! is_page($args[0])) {
34 return '#menu(): No such page: ' . htmlspecialchars($args[0]);
36 $menu = $args[0]; // Set
40 // Output menubar page data
41 //$page = ($menu === NULL) ? $menubar : $menu;
42 $page = ($menu === NULL) ? WikiConfig::getMenuBarPage() : $menu;
44 if (MENU_ENABLE_SUBMENU) {
45 //$path = explode('/', strip_bracket($vars['page']));
46 $path = explode('/', strip_bracket(WikiParam::getPage()));
47 while(! empty($path)) {
48 $_page = join('/', $path) . '/' . MENU_SUBMENUBAR;
49 if (is_page($_page)) {
57 if (! is_page($page)) {
59 //} else if ($vars['page'] == $page) {
60 } else if (WikiParam::getPage() == $page){
61 return '<!-- #menu(): You already view ' . htmlspecialchars($page) . ' -->';
64 $menutext = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m', '$1$2', get_source($page));
66 return preg_replace('/<ul[^>]*>/', '<ul>', convert_html($menutext));