<?php
$adminMenu = \DynCom\mysyde\common\classes\Adminmenu::get();

$subsites = array();
if ($_GET["level_1"] != "") {
    $subsites = $adminMenu[$_GET["level_1"]]['subsites'];
}
$subsites_2 = array();
if ($_GET["level_2"] != "") {
    $subsites_2 = $adminMenu[$_GET["level_2"]]['subsites'];
}

?>

<?php if (count($subsites)): ?>
    <ul>
        <?php foreach ($subsites as $code => $subsite): ?>
            <li>
                <?php
                $active = '';
                if ($_GET["level_2"] != "" && $_GET["level_2"] == $code) {
                    $active = 'class="active"';
                }
                ?>
                <a <?php echo $active; ?>  href="<?php echo get_menu_link($_GET["level_1"] . "/" . $code, $site, $language); ?>"><?php echo $subsite['name']; ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

<?php if (count($subsites_2)): ?>
    <ul>
        <?php foreach ($subsites_2 as $code => $subsite): ?>
            <li>
                <?php
                $active = '';
                if ($_GET["level_3"] != "" && $_GET["level_3"] == $code) {
                    $active = 'class="active"';
                }
                ?>
                <a <?php echo $active; ?> href="<?php echo get_menu_link($_GET["level_1"] . "/" . $_GET["level_2"] . "/" . $code, $site, $language); ?>"><?php echo $subsite['name']; ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>