<?php

/**
 * @var int         $total
 * @var array[]     $list
 * @var string      $tag
 * @var string      $pagination
 * @var \Johncms\Users\User $user
 */

$this->layout('system::layout/default');
?>

<?php foreach ($list as $article) : ?>
    <div class="new_post-item without_avatar">
        <a href="<?= $article['url'] ?>" class="card-title h3"><?= $this->e($article['name']) ?></a>
        <div class="post-body"><?= $article['text'] ?></div>
        <?php if ($article['tags']) : ?>
            <div class="mb-1"><?= $article['tags'] ?></div>
        <?php endif; ?>
        <div class="text-muted small d-flex align-items-center flex-wrap">
            <div class="me-2">
                <span><?= __('Author:') ?></span><?= $article['who'] ?>
            </div>
            <div class="me-2">
                <span><?= __('Number of readings:') ?></span><?= $article['count_views'] ?>
            </div>
            <div>
                <?php if ($article['comments']) : ?>
                    <a href="/library/article/<?= $article['id'] ?>/comments"><?= __('Comments:') ?></a>
                    (<?= $article['comm_count'] ?>)
                <?php endif; ?>
            </div>
        </div>
    </div>
<?php endforeach; ?>

<div class="mt-3"><?= __('Total') ?>: <?= $total ?></div>
<?php if ($total > $user->config->kmess) : ?>
    <div><?= $pagination ?></div>
<?php endif; ?>
<p><a href="/library/"><?= __('To Library') ?></a></p>
