<?php $this->layout(
    'system::layout/default',
    [
        'title'      => __('News'),
        'page_title' => __('News'),
    ]
) ?>
<?php if ($user->rights >= 6): ?>
    <p>
        <a href="/news/add/" class="btn btn-primary mr-2"><?= __('Add') ?></a>
        <a href="/news/clean/" class="btn btn-danger"><?= __('Clear') ?></a>
    </p>
<?php endif ?>
<!-- Listing News -->
<?php foreach ($list() as $news): ?>
    <div class="new_post-item without_avatar">
        <h3 class="font-weight-bold"><?= $this->e($news['name']) ?></h3>
        <p class="post-body"><?= $news['text'] ?></p>
        <div class="text-muted small"><?= __('Author') ?>: <?= $news['avt'] ?> (<?= $tools->displayDate($news['time']) ?>)</div>
        <?php if (! empty($news['kom']) || $user->rights >= 6): ?>
            <div class="pt-1 d-flex justify-content-between">
                <div>
                    <?php if (! empty($news['kom'])): ?>
                        <!-- Forum discussion -->
                        <a href="/forum/?type=topic&id=<?= $news['kom'] ?>">
                            <?= __('Discuss in Forum') ?> (<?= $news['kom_count'] ?>)
                        </a>
                    <?php endif ?>
                </div>
                <?php if ($user->rights >= 6): ?>
                    <!-- Buttons for deleting and changing news -->
                    <div>
                        <a href="/news/edit/<?= $news['id'] ?>" class="mr-2"><?= __('Edit') ?></a>
                        <a href="/news/del/<?= $news['id'] ?>"><?= __('Delete') ?></a>
                    </div>
                <?php endif ?>
            </div>
        <?php endif ?>
    </div>
<?php endforeach ?>
<div class="pt-2 pb-2"><?= __('Total') ?>:&#160;<?= $total ?></div>
<!-- Page switching -->
<?php if ($total > $user->config->kmess): ?>
    <div><?= $pagination ?></div>
<?php endif ?>

