<?php
/**
 * @var SportController $this;
 */
?>
<ul class="sidebar-nav">
    <?php
    $rootNode = $this->getNode();
    $sectionNode = null;
    $pageNode = null;
    if (isset($rootNode->node_id)) {
        $sectionNode = $rootNode;
        $rootNode = $sectionNode->node;
        if (isset($rootNode->node_id)) {
            $pageNode = $sectionNode;
            $sectionNode = $pageNode->node;
            $rootNode = $sectionNode->node;
        }
    }

    foreach ($rootNode->nodes as $node1)
        if (!$node1->hidden) {
            switch ($node1->data_type) {
                case('sportSection'):
                    if (isset($sectionNode) && $node1->id == $sectionNode->id) {
                        echo '<li class="active">', CHtml::link($node1->i18n->label, array('sportSection/index', 'node_id' => $node1->id));
                        if (count($node1->nodes)) {
                            echo '<ul>';
                            foreach ($node1->nodes as $node2)
                                if (!$node2->hidden) {
                                    if (isset($pageNode) && $node2->id == $pageNode->id) {
                                        echo '<li class="active">', CHtml::link($node2->i18n->label, array('sportPage/index', 'node_id' => $node2->id));
                                        echo '</li>';
                                    } else {
                                        echo '<li>', CHtml::link($node2->i18n->label, array('sportPage/index', 'node_id' => $node2->id)), '</li>';
                                    }
                                }
                            echo '</ul>';
                        }
                        echo '</li>';
                    } else {
                        echo '<li>', CHtml::link($node1->i18n->label, array('sportSection/index', 'node_id' => $node1->id)), '</li>';
                    }
                    break;
                case('albumsSection'):
                    if (isset($sectionNode) && $node1->id == $sectionNode->id) echo '<li class="active">';
                    else echo '<li>';
                    echo CHtml::link($node1->i18n->label, array('albumsSection/albums', 'node_id' => $node1->id)), '</li>';
                    break;
                case('calendarSection'):
                    if (isset($sectionNode) && $node1->id == $sectionNode->id) echo '<li class="active">';
                    else echo '<li>';
                    echo CHtml::link($node1->i18n->label, array('calendarSection/calendar', 'node_id' => $node1->id)), '</li>';
                    break;
            }
        }
    ?>
</ul>