From f699a20c363fa6eea44287bec0f0584e7e6f9ade Mon Sep 17 00:00:00 2001 From: mcramer Date: Fri, 28 Sep 2012 08:52:13 +0000 Subject: [PATCH] Implemented: Extend menus by putting *.menu.php inside the module/lib/menu.d/ folder --- .../admin/lib/interface.d/tpl_default.menu.php | 15 +++++++++++---- interface/web/admin/lib/module.conf.php | 14 -------------- interface/web/capp.php | 16 +++++++++++++++- interface/web/login/index.php | 12 ++++++++++++ .../web/themes/default/templates/sidenav.tpl.htm | 4 ++++ interface/web/tools/lib/module.conf.php | 14 +------------- 6 files changed, 43 insertions(+), 32 deletions(-) diff --git a/interface/web/admin/lib/interface.d/tpl_default.menu.php b/interface/web/admin/lib/interface.d/tpl_default.menu.php index 5c30072e34..e2e7745679 100644 --- a/interface/web/admin/lib/interface.d/tpl_default.menu.php +++ b/interface/web/admin/lib/interface.d/tpl_default.menu.php @@ -1,7 +1,14 @@ 'Default Theme', - 'target' => 'content', - 'link' => 'admin/tpl_default.php', - 'html_id' => 'tpl_default'); +for($m = 0; $m < count($module['nav']); $m++) { + if($module['nav'][$m]['title'] == 'Interface') { + + $module['nav'][$m]['items'][] = array( 'title' => 'Default Theme', + 'target' => 'content', + 'link' => 'admin/tpl_default.php', + 'html_id' => 'tpl_default'); + break; + } +} + ?> diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 489daacf2d..92e1979b16 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/interface/web/admin/lib/module.conf.php @@ -83,20 +83,6 @@ $items[] = array( 'title' => 'Interface Config', 'link' => 'admin/system_config_edit.php?id=1', 'html_id' => 'interface_config'); -//**** Load the settings pages of all installed themes -$menu_dir = ISPC_WEB_PATH.'/admin/lib/interface.d'; - -if (is_dir($menu_dir)) { - if ($dh = opendir($menu_dir)) { - //** Go through all files in the menu dir - while (($file = readdir($dh)) !== false) { - if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php') { - include_once($menu_dir . '/' . $file); - } - } - } -} - $module['nav'][] = array( 'title' => 'Interface', 'open' => "1", 'items' => $items); diff --git a/interface/web/capp.php b/interface/web/capp.php index 4512391988..7917aa0bbb 100644 --- a/interface/web/capp.php +++ b/interface/web/capp.php @@ -52,7 +52,21 @@ if(!in_array($mod,$user_modules)) $app->error($app->lng(301)); //* Load module configuration into the session. if(is_file($mod."/lib/module.conf.php")) { include_once($mod."/lib/module.conf.php"); - $_SESSION["s"]["module"] = $module; + + $menu_dir = ISPC_WEB_PATH.'/' . $mod . '/lib/menu.d'; + + if (is_dir($menu_dir)) { + if ($dh = opendir($menu_dir)) { + //** Go through all files in the menu dir + while (($file = readdir($dh)) !== false) { + if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php' && $file != 'dns_resync.menu.php') { + include_once($menu_dir . '/' . $file); + } + } + } + } + + $_SESSION["s"]["module"] = $module; session_write_close(); if($redirect == ''){ echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"]; diff --git a/interface/web/login/index.php b/interface/web/login/index.php index a99a77546e..a158422f89 100644 --- a/interface/web/login/index.php +++ b/interface/web/login/index.php @@ -195,6 +195,18 @@ class login_index { if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) { include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php'); + $menu_dir = ISPC_WEB_PATH.'/' . $_SESSION['s']['user']['startmodule'] . '/lib/menu.d'; + + if (is_dir($menu_dir)) { + if ($dh = opendir($menu_dir)) { + //** Go through all files in the menu dir + while (($file = readdir($dh)) !== false) { + if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php' && $file != 'dns_resync.menu.php') { + include_once($menu_dir . '/' . $file); + } + } + } + } $_SESSION['s']['module'] = $module; } diff --git a/interface/web/themes/default/templates/sidenav.tpl.htm b/interface/web/themes/default/templates/sidenav.tpl.htm index 8ec46aa867..b42ea6667a 100644 --- a/interface/web/themes/default/templates/sidenav.tpl.htm +++ b/interface/web/themes/default/templates/sidenav.tpl.htm @@ -12,7 +12,11 @@
  • id='' > + + + + diff --git a/interface/web/tools/lib/module.conf.php b/interface/web/tools/lib/module.conf.php index 10855fe70b..c6b6aaeb87 100644 --- a/interface/web/tools/lib/module.conf.php +++ b/interface/web/tools/lib/module.conf.php @@ -40,18 +40,6 @@ $module['nav'][] = array( 'title' => 'Interface', unset($items); -//**** Load additional menu items -$menu_dir = ISPC_WEB_PATH.'/tools/lib/menu.d'; - -if (is_dir($menu_dir)) { - if ($dh = opendir($menu_dir)) { - //** Go through all files in the menu dir - while (($file = readdir($dh)) !== false) { - if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php' && $file != 'dns_resync.menu.php') { - include_once($menu_dir . '/' . $file); - } - } - } -} + ?> \ No newline at end of file -- GitLab