<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var string $unread_count
 * @var string $files_url
 * @var string $files_name
 * @var string $files_count
 */

?>
<?php if (! $config['mod_forum']): ?>
    <div class="alert alert-danger"><?= __('Forum is closed') ?></div>
<?php elseif ($config['mod_forum'] == 3): ?>
    <div class="alert alert-danger"><?= __('Read only') ?></div>
<?php endif; ?>

<div class="border-top full-mobile-width border-bottom d-flex mb-3 pt-2 pb-2 align-items-center">
    <div class="mr-auto d-flex pt-2 pb-2 flex-shrink-0">
        <?php if ($user->isValid()): ?>
            <?php if (! empty($unread_count)): ?>
                <div class="d-flex align-items-center pr-2">
                    <a href="?act=new" class="pr-2 d-flex">
                        <span class="d-none d-sm-inline"><?= __('Unread') ?></span>
                        <div class="icon_with_badge">
                            <svg class="icon d-sm-none">
                                <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#forum"/>
                            </svg>
                            <span class="badge badge-pill badge-danger d-sm-none"><?= $unread_count ?></span>
                            <span class="d-none d-sm-inline text-danger font-weight-bold pl-1">+<?= $unread_count ?></span>
                        </div>
                    </a>
                </div>
            <?php endif; ?>
            <div class="pr-3">
                <a href="?act=new&amp;do=period">
                    <span class="d-none d-sm-inline"><?= __('Show for Period') ?></span>
                    <svg class="icon d-sm-none">
                        <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#calendar"/>
                    </svg>
                </a>
            </div>
        <?php else: ?>
            <div class="pr-3">
                <a href="?act=new">
                    <span class="d-none d-sm-inline"><?= __('Last activity') ?></span>
                    <svg class="icon d-sm-none">
                        <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#calendar"/>
                    </svg>
                </a>
            </div>
        <?php endif; ?>
        <div class="d-flex align-items-center">
            <a href="<?= $files_url ?>" class="pr-2">
                <span class="d-none d-sm-inline"><?= $files_name ?></span>
                <span class="icon_with_badge mr-sm-3">
                    <svg class="icon d-sm-none"><use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#download"/></svg>
                    <?php if ($files_count > 0): ?>
                        <span class="badge badge-pill badge-success"><?= $files_count ?></span>
                    <?php endif ?>
                </span>
            </a>
        </div>
    </div>
    <form class="form-inline search-in-nav mb-0" action="?act=search" method="post">
        <div class="input-with-inner-btn">
            <input class="form-control pr-5 border-radius-12" name="search" type="search" minlength="4" placeholder="<?= __('Search') ?>">
            <button class="btn icon-button" type="submit" name="submit" value="1">
                <svg class="icon">
                    <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#search"/>
                </svg>
            </button>
        </div>
    </form>
</div>
