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

<form name="file_edit_form" action="<?= $data['action_url'] ?>" method="post" enctype="multipart/form-data">
    <?php if (! empty($data['error_message'])): ?>
        <?= $this->fetch(
            'system::app/alert',
            [
                'alert_type' => 'alert-danger border-0',
                'alert'      => $data['error_message'],
            ]
        ) ?>
    <?php endif; ?>
    <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 format image JPG, JPEG, PNG, GIF<br>File size should not exceed %d kb.'), $config['flsz']) ?>
        </div>
    </div>
    <div class="form-group">
        <label for="description"><?= __('Description') ?></label>
        <textarea id="description" name="description" class="form-control" rows="<?= $user->config->fieldHeight ?>"></textarea>
    </div>
    <div class="mt-3">
        <button type="submit" name="submit" value="1" class="btn btn-primary"><?= __('Save') ?></button>
        <a href="<?= $data['back_url'] ?>" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
