Exemple #1
0
function makeAndShowModules($page, $isMods = false)
{
    global $mos;
    global $nav_modules;
    global $nav_installed;
    $isAll = false;
    if (isset($_GET['show'])) {
        $isAll = $_GET['show'] == 'all';
    }
    $packs = array();
    $packs = parse_ini_file($mos . '/etc/pm/packages', true);
    $roles = array();
    foreach ($nav_modules as $mod => $item) {
        $role = $item['role'];
        if (!$isMods and $role == 'core') {
            continue;
        }
        $irev = $item['revision'];
        $sts = $item['_status'];
        $acts = $item['_actions'];
        if ($role == 'core') {
            $acts = array();
        }
        $arev = '';
        if (isset($packs[$mod])) {
            $arev = $packs[$mod]['revision'];
            if ($arev != $irev) {
                $acts[] = 'update';
            }
        }
        $menu = array();
        $menu[$mod] = array('type' => 'node', 'title' => $item['title'], 'items' => array());
        foreach ($acts as $act) {
            $menu[$mod]['items'][$act] = array('type' => 'item', 'title' => getMsg('coreCm_' . $act), 'url' => "?page={$page}&mod={$mod}&act={$act}");
        }
        if (isset($item['config_edit']) || isset($item['config_link'])) {
            $cls = 'top_delim';
            if (count($menu[$mod]['items']) == 0) {
                $cls = '';
            }
            if (isset($item['config_edit'])) {
                $menu[$mod]['items']['edit'] = array('type' => 'item', 'class' => $cls, 'title' => getMsg('coreSettings'), 'url' => "?page=edit&mod={$mod}");
            } elseif (isset($item['config_link'])) {
                $menu[$mod]['items']['link'] = array('type' => 'item', 'class' => $cls, 'title' => getMsg('coreSettings'), 'url' => $item['config_link']);
            }
        }
        // about
        if (($url = showAbout($mod)) !== false) {
            $menu[$mod]['items']['about_' . $mod] = array('type' => 'about', 'class' => 'top_delim', 'title' => getMsg('coreCm_about'), 'url' => $url);
        }
        $roles[$role][$mod] = array('status' => $sts, 'arev' => $arev, 'irev' => $irev, 'size' => $item['size'] * 1024, 'menu' => $menu);
    }
    // adding installed packages
    foreach ($nav_installed as $mod => $item) {
        if (!array_key_exists($mod, $nav_modules)) {
            $menu = array();
            if ($item['revision'] == 'emb') {
                if (!$isAll) {
                    continue;
                }
                $menu[$mod] = array('type' => 'node', 'title' => $packs[$mod]['title'], 'items' => array());
                $roles[$packs[$mod]['role']][$mod] = array('status' => 'embeded', 'arev' => '', 'irev' => '', 'menu' => $menu);
            } else {
                if ($isAll or isset($packs[$mod]) and $item['revision'] != $packs[$mod]['revision']) {
                    $menu[$mod] = array('type' => 'node', 'title' => $item['title'], 'items' => array());
                    if (isset($packs[$mod]) and $item['revision'] != $packs[$mod]['revision']) {
                        $menu[$mod]['items']['update'] = array('type' => 'item', 'title' => getMsg('coreCm_update'), 'url' => "?page={$page}&mod={$mod}&act=update");
                    }
                    $roles[$item['role']][$mod] = array('status' => 'install', 'arev' => $packs[$mod]['revision'], 'irev' => $item['revision'], 'size' => $item['size'] * 1024, 'menu' => $menu);
                }
            }
        }
    }
    if ($isMods) {
        // adding non installed modules
        foreach ($packs as $mod => $item) {
            if (!array_key_exists($mod, $nav_modules)) {
                if (!array_key_exists($mod, $nav_installed)) {
                    $menu = array();
                    $st = isInstalable($mod, $item);
                    if ($st == 0 and $item['role'] != 'package' or $isAll) {
                        $menu[$mod] = array('type' => 'node', 'title' => $item['title'], 'items' => array());
                        if ($st == 0 and $item['role'] != 'package') {
                            $sts = 'noinstall';
                            $menu[$mod]['items']['install'] = array('type' => 'item', 'title' => getMsg('coreCm_install'), 'url' => "?page={$page}&mod={$mod}&act=install");
                            // about
                            if (($url = showAbout($mod)) !== false) {
                                $menu[$mod]['items']['about_' . $mod] = array('type' => 'about', 'class' => 'top_delim', 'title' => getMsg('coreCm_about'), 'url' => $url);
                            }
                        } elseif ($st == 0) {
                            $sts = 'noinstall';
                        } elseif ($st == 2) {
                            $sts = 'embeded';
                        } else {
                            $sts = 'inaccess';
                        }
                        $roles[$item['role']][$mod] = array('status' => $sts, 'arev' => $item['revision'], 'irev' => '', 'size' => $item['size'] * 1024, 'menu' => $menu);
                    }
                }
            }
        }
    }
    showModulesList($page, $roles);
}
<script type="text/javascript" src="javascript/functions.js"></script>


<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-<?php 
echo $v_leaflet;
?>
/leaflet.css" />

<link rel="stylesheet" type="text/css" href="style/style.css">
<link rel="alternate" type="application/rss+xml" href="changelog.php" title="Changelog">

<?php 
//route id is defined -> get route
if (isset($_GET["id"]) || isset($_POST["id"])) {
    $route = new Route();
    // get data
    $route->getData();
    $route->train = new Train();
    $route->loadXml();
    $route->loadRelationWays();
    $route->calculateSpeed();
    $route->output();
    showAbout();
} else {
    start();
    Search::showSearchResult();
    showAbout();
}
?>
</body>
</html>