<?php

/**
 * @var Mobicms\Render\Template\Template $this
 * @var string $form_action
 * @var int|null $id
 * @var array<string, mixed> $fields
 * @var list<string> $errors
 * @var int $field_height
 * @var string $csrf_token
 */

$this->layout('system::layout/default');
?>

<?php if (! empty($errors)): ?>
    <div class="alert alert-danger shadow border-0">
        <?php foreach ($errors as $error): ?>
            <div><?= $this->e($error) ?></div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>
<form action="<?= $this->e($form_action) ?>" method="post">
    <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>">
    <?php if (! empty($id)): ?>
        <input type="hidden" name="id" value="<?= $id ?>">
    <?php endif; ?>
    <div class="form-group">
        <label for="link"><?= __('Link') ?></label>
        <input type="text" name="link" class="form-control" id="link" placeholder="<?= __('Link') ?>" value="<?= $this->e($fields['link']) ?>">
    </div>
    <div class="form-check">
        <input type="checkbox" class="form-check-input" name="show" value="1" id="show" <?= ! empty($fields['show']) ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="show"><?= __('Direct Link') ?></label>
        <div class="text-muted small"><?= __('Click statistics won\'t be counted, If the direct link is turned on') ?></div>
    </div>
    <div class="form-group mt-2">
        <label for="name"><?= __('Title') ?></label>
        <input type="text" name="name" class="form-control" id="name" placeholder="<?= __('Title') ?>" value="<?= $this->e($fields['name']) ?>">
        <div class="text-muted small"><?= __('To change the name when updating pages, you must wtite names trought the symbol |') ?></div>
    </div>
    <div class="form-group">
        <label for="color"><?= __('Color') ?></label>
        <input type="text" name="color" class="form-control" id="color" placeholder="<?= __('Color') ?>" value="<?= $this->e($fields['color']) ?>">
        <div class="text-muted small"><?= __('In the format FFFFFF, if you do not want to use link color, simply do not fill this field') ?></div>
    </div>
    <div class="form-group">
        <label for="count"><?= __('Hits') ?></label>
        <input type="text" name="count" class="form-control" id="count" placeholder="<?= __('Hits') ?>" value="<?= (int) $fields['count_link'] ?>">
        <div class="text-muted small"><?= __('Number of hits for link existence which will be automatically removed from the page<br>0 - Unlimited') ?></div>
    </div>
    <div class="form-group">
        <label for="day"><?= __('Days') ?></label>
        <input type="text" name="day" class="form-control" id="day" placeholder="<?= __('Days') ?>" value="<?= (int) $fields['day'] ?>">
        <div class="text-muted small"><?= __('Number of days for link existence which will be automatically removed from the page<br>0 - Unlimited') ?></div>
    </div>
    <h3><?= __('Show') ?></h3>
    <div class="form-check">
        <input type="radio" id="view1" name="view" value="0" class="form-check-input" <?= (int) $fields['view'] === 0 ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="view1"><?= __('Everyone') ?></label>
    </div>
    <div class="form-check">
        <input type="radio" id="view2" name="view" value="1" class="form-check-input" <?= (int) $fields['view'] === 1 ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="view2"><?= __('Guests') ?></label>
    </div>
    <div class="form-check">
        <input type="radio" id="view3" name="view" value="2" class="form-check-input" <?= (int) $fields['view'] === 2 ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="view3"><?= __('Users') ?></label>
    </div>
    <h3 class="mt-3"><?= __('Place') ?></h3>
    <?php foreach ([0 => __('Before the menu'), 1 => __('After the menu'), 2 => __('At the top of the page'), 3 => __('At the bottom of the page')] as $value => $label): ?>
        <div class="form-check">
            <input type="radio" id="type<?= $value ?>" name="type" value="<?= $value ?>" class="form-check-input" <?= (int) $fields['type'] === $value ? 'checked="checked"' : '' ?>>
            <label class="form-check-label" for="type<?= $value ?>"><?= $label ?></label>
        </div>
    <?php endforeach; ?>
    <h3 class="mt-3"><?= __('Layout') ?></h3>
    <?php foreach ([0 => __('All pages'), 1 => __('Only on Homepage'), 2 => __('On all, except Homepage')] as $value => $label): ?>
        <div class="form-check">
            <input type="radio" id="layout<?= $value ?>" name="layout" value="<?= $value ?>" class="form-check-input" <?= (int) $fields['layout'] === $value ? 'checked="checked"' : '' ?>>
            <label class="form-check-label" for="layout<?= $value ?>"><?= $label ?></label>
        </div>
    <?php endforeach; ?>
    <h3 class="mt-3"><?= __('Styling links') ?></h3>
    <div class="form-check">
        <input type="checkbox" class="form-check-input" name="bold" value="1" id="bold" <?= ! empty($fields['bold']) ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="bold"><?= __('Bold') ?></label>
    </div>
    <div class="form-check">
        <input type="checkbox" class="form-check-input" name="italic" value="1" id="italic" <?= ! empty($fields['italic']) ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="italic"><?= __('Italic') ?></label>
    </div>
    <div class="form-check">
        <input type="checkbox" class="form-check-input" name="underline" value="1" id="underline" <?= ! empty($fields['underline']) ? 'checked="checked"' : '' ?>>
        <label class="form-check-label" for="underline"><?= __('Underline') ?></label>
    </div>
    <div class="mt-3">
        <input type="submit" value="<?= __('Save') ?>" class="btn btn-primary"/>
        <a href="/admin/ads" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
