<?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 Mobicms\Render\Template\Template $this
 * @var $title
 * @var $page_title
 * @var $data
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title,
    ]
);
?>


<?php if (empty($data['items'])): ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-info',
            'alert'      => __('The list is empty'),
        ]
    ) ?>
<?php else: ?>
    <div class="d-flex flex-wrap">
        <?php foreach ($data['items'] as $item): ?>
            <div class="flex-grow-0">
                <div style="width: 100px;" class="mb-2 mr-2">
                    <?php if (! empty($item['set_url'])): ?>
                        <a href="<?= $item['set_url'] ?>">
                            <img src="<?= $item['picture'] ?>" alt="." class="img-thumbnail">
                        </a>
                    <?php else: ?>
                        <img src="<?= $item['picture'] ?>" alt="." class="img-thumbnail">
                    <?php endif; ?>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>

<div class="mt-4">
    <?php if ($data['total'] > $data['per_page']): ?>
        <div>
            <?= $data['pagination'] ?>
        </div>
    <?php endif; ?>
    <?php if ($data['total'] > 0): ?>
        <div><?= __('Total:') ?> <?= $data['total'] ?></div>
    <?php endif; ?>
</div>
<div>
    <a href="<?= $data['back_url'] ?>"><?= __('Back') ?></a>
</div>
