<?php
    $blnHasActive = false;
    $intLevel = (int) substr($this->level, 6);

    if ($intLevel < 1) {
        $intLevel = 1;
    }

    if ($intLevel == 1):
        $arrLanguages = \System::getLanguages();
        foreach ($this->items as $item) {
            if ($item['isActive'] || strpos($item['subitems'], 'class="active') !== false) {
                $blnHasActive = true;
                break;
            }
        }
?>
<select class="<?php echo $this->level; ?>" onchange="window.location.href=this.value">
<?php endif; ?>
<?php if ($intLevel == 1 && !$blnHasActive): ?><option value="">-</option><?php endif; ?>
<?php foreach ($this->items as $item): ?>
<?php if ($item['isActive']): ?>
<option class="active <?php echo $item['class']; ?>" selected><?php echo str_repeat('&nbsp;&nbsp;&nbsp;', $intLevel-1); ?><?php echo $arrLanguages[strtolower($item['link'])] ?: $item['link']; ?><?php echo $item['subitems']; ?></option>
<?php else: ?>
<option <?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?> value="<?php echo $item['href']; ?>"><?php echo str_repeat('&nbsp;&nbsp;&nbsp;', $intLevel-1); ?><?php echo $arrLanguages[strtolower($item['link'])] ?: $item['link']; ?><?php echo $item['subitems']; ?></option>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($intLevel == 1): ?>
</select>
<?php endif; ?>
