<?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 $show_post_preview
 * @var $preview_message
 * @var $back_url
 * @var $msg
 * @var $form_action
 * @var $is_new_message
 * @var $is_quote
 * @var $message
 * @var $add_file
 * @var \Johncms\Modules\Forum\Domain\Models\ForumTopic $topic
 */

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

<form name="message_form" action="<?= $form_action ?>" method="post">
    <input type="hidden" name="token" value="<?= $token ?>">
    <div class="h4"><?= __('Topic') ?>: <?= $this->e($topic->name) ?></div>

    <?= $this->fetch(
        'system::app/ckeditor',
        [
            'label'        => __('Message'),
            'errors'       => implode(', ', $errors['message'] ?? []),
            'value'        => $msg,
            'name'         => 'msg',
            'allow_upload' => true,
            'upload_url'   => '/forum/upload_file/',
        ]
    ) ?>
    <div class="custom-control custom-checkbox mb-3">
        <input type="checkbox" class="custom-control-input" name="addfiles" value="1" id="addfiles" <?= $add_file ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="addfiles"><?= __('Add File') ?></label>
    </div>
    <div>
        <button type="submit" name="submit" value="1" class="btn btn-primary"><?= __('Write') ?></button>
    </div>
    <div class="mt-3">
        <a href="/help/?act=smileys" class="pe-2"><?= __('Smilies') ?></a> <a href="<?= $back_url ?>"><?= __('Back') ?></a>
    </div>
</form>
