<?php
/**
 * @var Johncms\Counters $counters
 * @var int $rights
 * @var $data
 */

$this->layout('system::layout/default', ['title' => __('Welcome')]);
?>
<div class="myWrap">
<?php if (! empty($data['news'])): ?>
    <div class="news-item myWrap-item">
        <div class="forums_title"><?= __('News') ?></div>
        <div class="row body">
            <?php foreach ($data['news'] as $item): ?>
                <div class="col-12">
                    <a class="h4 font-weight-bold" href="/news/"><?= $item['title'] ?></a>
                    <?php if (! empty($item['text'])): ?>
                        <div class="small"><?= $item['text'] ?></div>
                    <?php endif; ?>
                    <?php if (! empty($item['comments_url'])): ?>
                        <div class="small"><a href="<?= $item['comments_url'] ?>"><?= __('Discuss') ?></a> (<?= $item['comments'] ?>)</div>
                    <?php endif; ?>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
<?php endif; ?>
<div class="d-block d-md-none mobile_tiles mt-n4">
    <div class="row">
        <div class="col-6 col-sm-4 mt-3 tile">
            <a href="/news/" class="card border-0 shadow text-center">
                <div class="card-body">
                    <div class="icon_with_badge d-inline-block">
                        <svg class="icon-40">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#book"/>
                        </svg>
                        <?php if ($data['counters']['news']['new'] > 0): ?>
                            <span class="badge badge-pill badge-danger ml-3 mt-1"><?= $tools->formatNumber($data['counters']['news']['new']) ?></span>
                        <?php endif ?>
                    </div>
                    <div class="mt-2 tile_name"><?= __('News') ?></div>
                </div>
            </a>
        </div>
        <div class="col-6 col-sm-4 mt-3 tile">
            <a href="/forum/" class="card border-0 shadow text-center">
                <div class="card-body">
                    <div class="icon_with_badge d-inline-block">
                        <svg class="icon-40">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#forum"/>
                        </svg>
                        <?php if ($data['counters']['forum']['new_messages'] > 0): ?>
                            <span class="badge badge-pill badge-danger ml-3 mt-1"><?= $tools->formatNumber($data['counters']['forum']['new_messages']) ?></span>
                        <?php endif ?>
                    </div>
                    <div class="mt-2 tile_name"><?= d__('system', 'Forum') ?></div>
                </div>
            </a>
        </div>
        <div class="col-6 col-sm-4 mt-3 tile">
            <a href="/guestbook/ga" class="card border-0 shadow text-center">
                <div class="card-body">
                    <div class="icon_with_badge d-inline-block">
                        <svg class="icon-40">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#chat"/>
                        </svg>
                        <?php if ($data['counters']['guestbook']['guestbook'] > 0): ?>
                            <span class="badge badge-pill badge-danger ml-3 mt-1"><?= $tools->formatNumber($data['counters']['guestbook']['guestbook']) ?></span>
                        <?php endif ?>
                    </div>
                    <div class="mt-2 tile_name"><?= d__('system', 'Guestbook') ?></div>
                </div>
            </a>
        </div>
        <div class="col-6 col-sm-4 mt-3 tile">
            <a href="/downloads/" class="card border-0 shadow text-center">
                <div class="card-body">
                    <div class="icon_with_badge d-inline-block">
                        <svg class="icon-40">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#download"/>
                        </svg>
                        <?php if ($data['counters']['downloads']['new'] > 0): ?>
                            <span class="badge badge-pill badge-danger ml-3 mt-1"><?= $tools->formatNumber($data['counters']['downloads']['new']) ?></span>
                        <?php endif ?>
                    </div>
                    <div class="mt-2 tile_name"><?= d__('system', 'Downloads') ?></div>
                </div>
            </a>
        </div>
        <div class="col-6 col-sm-4 mt-3 tile">
            <a href="/library/" class="card border-0 shadow text-center">
                <div class="card-body">
                    <div class="icon_with_badge d-inline-block">
                        <svg class="icon-40">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#text"/>
                        </svg>
                        <?php if ($data['counters']['library']['new'] > 0): ?>
                            <span class="badge badge-pill badge-danger ml-3 mt-1"><?= $tools->formatNumber($data['counters']['library']['new']) ?></span>
                        <?php endif ?>
                    </div>
                    <div class="mt-2 tile_name"><?= d__('system', 'Library') ?></div>
                </div>
            </a>
        </div>
        <div class="col-6 col-sm-4 mt-3 tile">
            <a href="/community/" class="card border-0 shadow text-center">
                <div class="card-body">
                    <div class="icon_with_badge d-inline-block">
                        <svg class="icon-40">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#users"/>
                        </svg>
                        <?php if ($data['counters']['users']['new'] > 0): ?>
                            <span class="badge badge-pill badge-danger ml-3 mt-1"><?= $tools->formatNumber($data['counters']['users']['new']) ?></span>
                        <?php endif ?>
                    </div>
                    <div class="mt-2 tile_name"><?= d__('system', 'Users') ?></div>
                </div>
            </a>
        </div>
    </div>
</div>
<div class="row">
<?php if ($data['last_posts'] !== 'none'): ?>
<div class="col-md-6 col-sm-12 mt-3 tile">
    <div class="forums">
        <div class="row">
        <div class="forums_title">Последние обсуждения</div>
            <?php foreach($data['last_posts'] as $item): ?>
                <a href="/forum/?type=topic&id=<?= $item['id'] ?>">
                    <i class="fal fa-comment-alt"></i> <?= $item['title'] ?> 
                    <span class="myBadge float-right"><?= $item['posts'] ?></span>
                </a>
            <?php endforeach; ?>
        </div>
    </div>
</div>
<?php endif; ?>

<?php if ($data['last_down'] !== 'none'): ?>
<div class="col-md-6 col-sm-12 mt-3 tile">
    <div class="forums">
        <div class="row">
        <div class="forums_title">Новые файлы</div>
            <?php foreach($data['last_down'] as $fitem): ?>
                <a href="/downloads/?act=view&id=<?= $fitem['uid'] ?>">
                    <i class="fal fa-file-archive"></i> <?= $fitem['rus_name'] ?>
                </a>
            <?php endforeach; ?>
        </div>
    </div>
</div>
<?php endif; ?>

<?php if ($data['last_lib'] !== 'none'): ?>
<div class="col-md-12 col-sm-12 mt-3 tile">
    <div class="forums">
        <div class="row">
        <div class="forums_title">Свежие статьи</div>
            <?php foreach($data['last_lib'] as $item): ?>
                <a href="/library/?id=<?= $item['id'] ?>">
                    <i class="fal fa-book"></i> <?= $item['name'] ?>
                </a>
            <?php endforeach; ?>
        </div>
    </div>
</div>
<?php endif; ?>
</div>
</div>
<?php $this->push('styles') ?>
<link rel="stylesheet" href="<?= $this->asset('indexpage/css/main.css', true) ?>">
<link rel="stylesheet" href="<?= $this->asset('indexpage/css/all.min.css', true) ?>">
<?php $this->stop(); ?>