<?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 ?? $title,
    ]
);
?>
<?php if ($created) : ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-success',
            'alert'      => __('Section created'),
        ]
    ) ?>
    <div class="mt-3">
        <a href="?do=dir&amp;id=<?= $id ?>"><?= __('To Section') ?></a>
    </div>
<?php else : ?>

    <?php if ($error) : ?>
        <?= $this->fetch(
            'system::app/alert',
            [
                'alert_type' => 'alert-danger',
                'alert'      => $error,
            ]
        ) ?>
    <?php endif; ?>

    <form action="?act=mkdir&amp;id=<?= $id ?>" method="post">
        <div class="form-group">
            <label for="name"><?= __('Title') ?></label>
            <input type="text" name="name" class="form-control" id="name" placeholder="<?= __('Title') ?>" required>
        </div>

        <div class="form-group">
            <label for="description"><?= __('Section description') ?></label>
            <textarea class="form-control" rows="<?= $user->config->fieldHeight ?>" name="description" id="description"></textarea>
        </div>

        <h3 class="mt-3"><?= __('Section type') ?></h3>
        <div class="custom-control custom-radio">
            <input type="radio" id="section_type1" name="type" value="0" class="custom-control-input" checked="checked">
            <label class="custom-control-label" for="section_type1"><?= __('Articles') ?></label>
        </div>
        <div class="custom-control custom-radio">
            <input type="radio" id="section_type2" name="type" value="1" class="custom-control-input">
            <label class="custom-control-label" for="section_type2"><?= __('Sections') ?></label>
        </div>

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

<?php endif; ?>
