<?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'),
        ]
    ) ?>
    <a href="/help/smilies/" class="btn btn-primary mt-3"><?= __('Add Smilies') ?></a>
<?php else: ?>
    <?php if ($user->isValid()): ?>
        <form action="<?= $data['form_action'] ?>" method="post">
    <?php endif; ?>
    <div class="row">
        <div class="col-md-6">
            <div class="list-group">
                <?php foreach ($data['items'] as $item): ?>
                    <div class="list-group-item d-flex align-items-center">
                        <div class="custom-control custom-checkbox align-items-center me-2">
                            <input type="checkbox" class="custom-control-input" name="delete_sm[]"
                                   value="<?= $item['lat_smile'] ?>" id="check_<?= $item['lat_smile'] ?>" <?= ! $item['can_del'] ? 'disabled' : '' ?>>
                            <label class="custom-control-label" for="check_<?= $item['lat_smile'] ?>"></label>
                        </div>
                        <div class="me-3">
                            <?= $item['picture'] ?>
                        </div>
                        <div>
                            :<?= $item['lat_smile'] ?>: <?= __('or') ?> <?= $item['smile'] ?>
                        </div>
                    </div>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
    <?php if ($user->isValid()): ?>
        <div class="mt-3">
            <input type="submit" name="delete" value="<?= __('Delete') ?>" class="btn btn-primary">
        </div>
        </form>
    <?php endif; ?>
<?php endif; ?>

<div class="mt-4">
    <?php if ($data['total'] > $user->config->kmess): ?>
        <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>
