<?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 $title
 * @var $page_title
 * @var $data
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title ?? $title,
    ]
);
?>
<?php if ($total) : ?>
    <!-- Listing Sections -->
    <?php foreach ($list() as $booklist): ?>
        <div class="new_post-item without_avatar">
            <a href="?id=<?= $booklist['id'] ?>" class="post-title"><?= $booklist['name'] ?></a>
            <div class="post-body"><?= $booklist['announce'] ?></div>
            <div class="text-muted small d-flex align-items-center flex-wrap">
                <span class="pr-2"><span><?= __('Author:') ?></span>&nbsp;<?= $booklist['who'] ?>,</span>
                <span class="d-flex align-items-center"><span class="pr-1"><?= __('Rating:') ?></span><?= $booklist['ratingView'] ?></span>
            </div>
        </div>
    <?php endforeach; ?>
<?php else : ?>
    <div class="row">
        <div class="col-md-5">
            <div class="alert alert-info shadow border-0"><?= __('The list is empty') ?></div>
        </div>
    </div>
<?php endif; ?>
<div class="phdr"><?= __('Total') ?>: <?= $total ?></div>
<!-- Page switching -->
<?php if ($total > $user->config->kmess) : ?>
    <div><?= $pagination ?></div>
<?php endif ?>

<?php if ($moderMenu) : ?>
    <div class="mt-3">
        <a href="?act=addnew&amp;id=<?= $id ?>" class="btn btn-primary"><?= __('Write Article') ?></a>
        <?php if ($admin) : ?>
            <a href="?act=moder&amp;type=dir&amp;id=<?= $id ?>" class="btn btn-primary"><?= __('Edit') ?></a>
            <a href="?act=del&amp;type=dir&amp;id=<?= $id ?>" class="btn btn-danger"><?= __('Delete') ?></a>
        <?php endif; ?>
    </div>

<?php endif; ?>
