<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<div class="right_col" role="main">
    <div class="">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>Blog-Post bearbeiten</h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form class="form-horizontal form-label-left input_mask" method="post">
                            <!-- Title input -->
                            <div class="col-md-6 col-sm-12 col-xs-12">
                                <div class="form-group">
                                    <label for="title">Titel</label>
                                    <input type="text" name="title" id="title-input" required placeholder="Titel"
                                           class="form-control" <?php if($edit): ?>value="<?= $content['postTitle'] ?>"<?php endif; ?>/>
                                </div>
                            </div>
                            <!-- URL input -->
                            <div class="col-md-6 col-sm-12 col-xs-12">
                                <div class="form-group">
                                    <label for="url">URL</label>
                                    <div class="input-group">
                                        <span class="input-group-addon" id="url-prefix">https://www.kingofdog.de/blog/post/</span>
                                        <input type="text" name="url" id="url-input" required placeholder="URL"
                                               class="form-control" aria-describedby="url-prefix" <?php if($edit): ?>value="<?= $content['postUrl'] ?>"<?php endif; ?> <?= $edit ? 'disabled' : '' ?>>
                                    </div>
                                </div>
                            </div>
                            <!-- Description input -->
                            <div class="form-group col-md-12 col-sm-12 col-xs-12">
                                <label for="description">Kurzbeschreibung</label>
                                <textarea name="description" rows="3" cols="40" class="form-control resizable_textarea"
                                          placeholder="Kurzbeschreibung"><?php if($edit) echo $content['postDesc'] ?></textarea>
                            </div>
                            <!-- Text editor -->
                            <div class="form-group col-md-12 col-sm-12 col-xs-12">
                                <label for="content">Inhalt</label>
                                <textarea class="tinymce-textarea form-control" name="content"><?= $edit ? $content['postCont'] : '' ?></textarea>
                            </div>
                            <!-- Publish date/time picker -->
                            <div class="form-group col-md-2 col-sm-12 col-xs-12">
                                <label for="publishDate">Veröffentlichungs-Datum</label>
                                <input type='text' class="form-control" name="publishDate" id="datetimepicker" <?= $edit ? 'disabled' : '' ?> <?php if($edit): ?>value="<?= $content['postPublishDate'] ?>"<?php endif; ?>/>
                            </div>
                            <div class="form-group col-md-10 col-sm-12 col-xs-12">
                                <div class="col-md-4 col-sm-12 col-xs-12">
                                    <label for="category">Kategorie</label>
                                    <select class="form-control" name="category" required>
                                        <option value="new-category">-- Neue Kategorie --</option>
                                        <?php foreach($categories as $category) { ?>
                                            <option value="<?= $category['ID'] ?>" <?= $edit && $category['ID'] == $content['postCategoryID'] ? 'selected' : '' ?>><?= $category['display_name'] ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-md-8 col-sm-12 col-xs-12" id="new-category" <?php if($edit): ?>style="display:none"<?php endif; ?>>
                                    <div class="form-group col-md-4 col-sm-12 col-xs-12">
                                        <label for="new-category-display-name">Neue Kategorie (Display-Name)</label>
                                        <input class="form-control" type="text" name="new-category-display-name" placeholder="Display-Name der neuen Kategorie">
                                    </div>
                                    <div class="form-group col-md-4 col-sm-12 col-xs-12">
                                        <label for="new-category-name">Neue Kategorie (Interner Name)</label>
                                        <input class="form-control" type="text" name="new-category-name" placeholder="Interner Name der neuen Kategorie">
                                    </div>
                                    <button class="btn btn-green col-md-4 col-sm-12 col-xs-12" id="new-category-submit">Erstellen</button>
                                </div>
                            </div>
                            <div class="form-group col-md-12">
                                <label for="tags">Tags</label>
                                <input type="text" class="form-control" name="tags" data-role="tagsinput" <?php if($edit): ?>value="<?php foreach($tags as $tag) echo $tag['display_name'] . ',' ?>"<?php endif; ?>>
                            </div>
                            <?php if($edit): ?>
                                <div class="col-md-12 form-group">
                                    <label for="version-message">Was wurde geändert?</label>
                                    <input type="text" class="form-control" name="version-message" placeholder="Was wurde an Änderungen getätigt?" required>
                                </div>
                            <?php endif; ?>
                            <input type="submit" class="btn btn-green col-md-12 col-sm-12 col-xs-12" value="Absenden">
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>