mcramer
2012-09-28 f699a20c363fa6eea44287bec0f0584e7e6f9ade
Implemented: Extend menus by putting *.menu.php inside the module/lib/menu.d/ folder

6 files modified
73 ■■■■■ changed files
interface/web/admin/lib/interface.d/tpl_default.menu.php 15 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/module.conf.php 14 ●●●●● patch | view | raw | blame | history
interface/web/capp.php 16 ●●●●● patch | view | raw | blame | history
interface/web/login/index.php 12 ●●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/sidenav.tpl.htm 4 ●●●● patch | view | raw | blame | history
interface/web/tools/lib/module.conf.php 12 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/interface.d/tpl_default.menu.php
@@ -1,7 +1,14 @@
<?php
$items[] = array(   'title'     => '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;
    }
}
?>
interface/web/admin/lib/module.conf.php
@@ -83,20 +83,6 @@
                    '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);
interface/web/capp.php
@@ -52,7 +52,21 @@
//* 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"];
interface/web/login/index.php
@@ -195,6 +195,18 @@
                                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;
                                }
                                
interface/web/themes/default/templates/sidenav.tpl.htm
@@ -12,7 +12,11 @@
            <tmpl_loop name="items">
                <li <tmpl_if name="html_id"> id='<tmpl_var name="html_id">' </tmpl_if>>
                    <tmpl_if name="link">
                        <tmpl_if name="target" op="==" value="_blank">
                        <a href="<tmpl_var name='link'>" target="_blank">
                        <tmpl_else>
                        <a href="#" onclick="loadContent('<tmpl_var name='link'>')">
                        </tmpl_if>
                    </tmpl_if>
                    <tmpl_var name="title">
                    <tmpl_if name="link">
interface/web/tools/lib/module.conf.php
@@ -40,18 +40,6 @@
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);
            }
        }
    }
}
?>