<?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' => $title,
    ]
);

?>

<?php if (! empty($data['success_message'])): ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-success',
            'alert'      => $data['success_message'],
        ]
    ) ?>
<?php endif; ?>

<?php if (! empty($data['errors'])): ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-danger',
            'alert'      => $data['errors'],
        ]
    ) ?>
<?php endif; ?>
<form action="<?= $data['form_action'] ?>" method="post" enctype="multipart/form-data">
    <h3><?= $page_title ?></h3>
    <div class="form-group">
        <div class="custom-file">
            <input type="file" class="custom-file-input" id="file" name="imagefile" aria-describedby="file_label" required>
            <label class="custom-file-label" for="file"><?= __('Choose file') ?></label>
        </div>
        <div class="text-muted mb-3 small">
            <?= sprintf(__('Allowed image formats: JPG, PNG, GIF. File size should not exceed %d kb.<br>The new image will replace old (if was).'), $config['flsz']) ?>
        </div>
    </div>

    <div class="mt-3">
        <input type="submit" name="submit" value="<?= __('Save') ?>" class="btn btn-primary"/>
        <a href="<?= $data['back_url'] ?>" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
