<?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,
    ]
);
$this->sectionReplace('sidebar-menu', $this->fetch('admin::sidebar-admin-menu', ['module_menu' => ['forum' => true]]));
?>

<?php if (empty($data['items'])): ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-info',
            'alert'      => __('The list is empty'),
        ]
    ) ?>
<?php endif; ?>
<?php foreach ($data['items'] as $item): ?>
    <div class="new_post-item without_avatar">
        <div class="d-flex justify-content-between align-items-center">
            <div class="d-flex align-items-center">
                <span class="text-muted mr-1">[<?= $item['sort'] ?>]</span>
                <a href="<?= $item['list_url'] ?>"><?= $item['name'] ?></a>
                <?php if (! empty($item['counter'])): ?>
                    <span class="badge badge-pill badge-light border ml-2"><?= $item['counter'] ?></span>
                <?php endif; ?>
            </div>
            <div>
                <a href="<?= $item['public_url'] ?>" class="btn btn-secondary btn-sm"><?= __('View') ?></a>
            </div>
        </div>
        <?php if (! empty($item['description'])): ?>
            <div class="small text-muted"><?= $item['description'] ?></div>
        <?php endif; ?>
        <div class="mt-2">
            <a href="<?= $item['edit_url'] ?>" class=""><?= __('Edit') ?></a>
            <a href="<?= $item['delete_url'] ?>" class="text-danger ml-2"><?= __('Delete') ?></a>
        </div>
    </div>
<?php endforeach; ?>
<?php if (! empty($data['add_form_url'])): ?>
    <div class="mt-3">
        <a href="<?= $data['add_form_url'] ?>" class="btn btn-primary"><?= __('Add') ?></a>
    </div>
<?php endif; ?>
<div class="mt-2">
    <a href="<?= $data['back_url'] ?>"><?= __('Back') ?></a>
</div>
