<?php $work_in_progress = true; ?>


<nav class="navbar navbar-inverse navbar-fixed-top" id="navigation">
    <div class="container-fluid">
        <div class="row">
            <div id="navbar" class="navbar-collapse collapse">
                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                    <form class="navbar-form navbar-left search_form">
                        <fieldset disabled>
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
                                <input type="text" class="form-control" placeholder="<?php echo T('Поиск...'); ?>">
                                <input type="submit" hidden>
                            </div>
                        </fieldset>
                    </form>
                </div>

                <?php
                if (!$work_in_progress) {
                    /* Формирование ссылок на страницы сайта */
                    $external_pages = glob(THEME_ROOT . "/pages/*.php");
                    $user_pages = glob(THEME_ROOT . "/pages/user/*.php");
                    $dir1 = strlen(THEME_ROOT . '/pages/');
                    $dir2 = strlen(THEME_ROOT . '/pages/user/');
                    /* Внешние страницы */
                    foreach ($external_pages as $key => $value) {
                        $external_pages[$key] = str_replace('.php', '', substr($value, $dir1));
                        if ($external_pages[$key] == 'index') {
                            $buf = $external_pages[0];
                            $external_pages[0] = $external_pages[$key];
                            $external_pages[$key] = $buf;
                        }
                    }
                    /* Внутренние страницы */
                    foreach ($user_pages as $key => $value) {
                        $user_pages[$key] = str_replace('.php', '', substr($value, $dir2));
                        if ($user_pages[$key] == 'index') {
                            $buf = $user_pages[0];
                            $user_pages[0] = $user_pages[$key];
                            $user_pages[$key] = $buf;
                        }
                    }
                }
                ?>

                <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="/adg.php?page=translator"><?php echo T('Таблица'); ?></a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                <?php echo T('Внешние страницы'); ?>
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                <?php if (!$work_in_progress) { ?>
                                    <?php foreach ($external_pages as $key => $value) {
                                        switch ($value) {
                                            case 'index':
                                                $value = '';
                                                $page_name = T('Главная');
                                                break;
                                            case 'about':
                                                $page_name = T('О компании');
                                                break;
                                            case 'faq':
                                                $page_name = T('FAQ');
                                                break;
                                            case 'forgot':
                                                $page_name = T('Восстановление пароля');
                                                break;
                                            case 'login':
                                                $page_name = T('Авторизация');
                                                break;
                                            case 'news':
                                                $page_name = T('Новости');
                                                break;
                                            case 'partners':
                                                $page_name = T('Партнёрам');
                                                break;
                                            case 'reviews':
                                                $page_name = T('Отзывы');
                                                break;
                                            case 'rules':
                                                $page_name = T('Правила');
                                                break;
                                            case 'signup':
                                                $page_name = T('Регистрация');
                                                break;
                                            case 'support':
                                                $page_name = T('Контакты');
                                                break;
                                            default:
                                                $page_name = $value;
                                                break;
                                        }
                                        if (!in_array($value, ['exit'])) { ?>
                                            <li><a href="/translated/pages/<?php echo $value; ?>"><?php echo escape($page_name); ?></a></li>
                                        <?php } ?>

                                    <?php } ?>
                                <?php } else { ?>
                                    <li><a href="/adg.php?page=translator">Work in progress</a></li>
                                <?php } ?>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                Страницы кабинета <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                <?php if (!$work_in_progress) { ?>
                                    <?php foreach ($user_pages as $key => $value) {
                                        switch ($value) {
                                            case 'index':
                                                $value = '';
                                                $page_name = T('Кабинет');
                                                break;
                                            case 'banners':
                                                $page_name = T('Баннеры');
                                                break;
                                            case 'depozit':
                                            case 'depozits':
                                            case 'deposit':
                                            case 'deposits':
                                                $page_name = T('Депозиты');
                                                break;
                                            case 'invest':
                                            case 'invests':
                                                $page_name = T('Пополнения');
                                                break;
                                            case 'payment':
                                            case 'payments':
                                                $page_name = T('Выплаты');
                                                break;
                                            case 'operations':
                                            case 'history':
                                                $page_name = T('Операции');
                                                break;
                                            case 'ref':
                                                $page_name = T('Рефералы');
                                                break;
                                            case 'reviews':
                                                $page_name = T('Отзывы');
                                                break;
                                            case 'settings':
                                                $page_name = T('Настройки');
                                                break;
                                            case 'changepass':
                                                $page_name = T('Изменение пароля');
                                                break;
                                            case 'wallets':
                                                $page_name = T('Реквизиты');
                                                break;
                                            case 'tickets':
                                                $page_name = T('Тикеты');
                                                break;
                                            case 'newticket':
                                            case 'new_ticket':
                                                $page_name = T('Новый тикет');
                                                break;
                                            default:
                                                $page_name = $value;
                                                break;
                                        }
                                        if (!in_array($value, ['exit', 'ticket_id', 'ticketid'])) { ?>
                                            <li><a href="/translated/pages/user/<?php echo $value; ?>"><?php echo escape($page_name); ?></a></li>
                                        <?php } ?>
                                    <?php } ?>
                                <?php } else { ?>
                                    <li><a href="/adg.php?page=translator">Work in progress</a></li>
                                <?php } ?>
                            </ul>
                        </li>
                        <li><a href="#"><?php echo T('FAQ'); ?></a></li>
                        <?php if (!(isset($_GET['page']) && $_GET['page'] === 'translator')) { ?>
                            <li><?php echo get_language_flags('flag', 'position: relative; margin: 8px;'); ?></li>
                        <?php } ?>

                        <li><a href="/adg.php"><?php echo T('Назад'); ?></a></li>
                    </ul>

                    <a class="navbar-brand" href="#">translator v0.3</a>
                </div>
            </div>
        </div>
    </div>
</nav>