<?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 $urls
 * @var $action_url
 * @var $extensions
 * @var $delete_token
 */

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

<?php if (! empty($screens)): ?>
    <div class="h4 font-weight-bold"><?= __('Current screenshots') ?></div>
    <div class="mt-3 mb-4">
        <?php foreach ($screens as $file): ?>
            <div class="media align-items-end mb-3 border-bottom pb-3">
                <a href="<?= $file['url'] ?>" title="<?= $file['file_name'] ?>" data-source="<?= $file['url'] ?>" class="image-preview">
                    <img src="<?= $file['url'] ?>" class="mr-3" style="width: 64px;" alt="<?= $file['file_name'] ?>">
                </a>
                <div class="media-body">
                    <h5 class="font-weight-bold mt-0"><?= $file['file_name'] ?></h5>
                    <form action="?act=edit_screen&amp;id=<?= $id ?>&amp;do=<?= $file['file_name'] ?>" method="post">
                        <input type="hidden" name="delete_token" value="<?= $delete_token ?>">
                        <button type="submit" class="btn btn-danger btn-sm"><?= __('Delete') ?></button>
                    </form>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>

<div class="h4 font-weight-bold"><?= __('Add screenshot') ?></div>
<form name="file_upload_form" action="<?= $action_url ?>" method="post" enctype="multipart/form-data">
    <div class="form-group">
        <div class="custom-file">
            <input type="file" class="custom-file-input" id="fail" name="screen" aria-describedby="file_label">
            <label class="custom-file-label" for="fail"><?= __('Choose file') ?></label>
        </div>
        <div class="text-muted mb-3 small">
            <?= __('Max. Size') ?>: <?= $config['flsz'] ?> kb.
        </div>
    </div>

    <div>
        <button type="submit" name="submit" value="1" class="btn btn-primary"><?= __('Save') ?></button>
        <a href="?act=view&amp;id=<?= $id ?>" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
