<?php

/**
 * @var Mobicms\Render\Template\Template $this
 * @var array<string, mixed> $config
 * @var string $form_action
 * @var string $manage_url
 * @var string|null $error_message
 * @var string|null $success_message
 * @var string $csrf_token
 */

$this->layout('system::layout/default');
?>
<div style="max-width: 640px">
    <?php if (! empty($error_message)): ?>
        <div class="alert alert-danger shadow border-0"><?= $this->e($error_message) ?></div>
    <?php endif ?>
    <?php if (! empty($success_message)): ?>
        <div class="alert alert-success shadow border-0"><?= $this->e($success_message) ?></div>
    <?php endif ?>
    <form method="post" action="<?= $this->e($form_action) ?>">
        <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>">
        <fieldset>
            <legend><?= __('Default language') ?></legend>
            <?php foreach ($config['lng_list'] as $key => $val): ?>
                <div class="form-check mb-2">
                    <input type="radio" id="lng-<?= $this->e($key) ?>" name="lng" class="form-check-input" value="<?= $this->e($key) ?>" <?= ($key === $config['lng'] ? ' checked="checked"' : '') ?>>
                    <label class="form-check-label" for="lng-<?= $this->e($key) ?>">
                        <img class="icon icon-flag" src="<?= $this->asset('images/flags/' . strtolower($key) . '.svg') ?>" alt=".">
                        <?= $this->e($val['name']) ?>
                    </label>
                </div>
            <?php endforeach ?>
        </fieldset>
        <input type="submit" class="btn btn-primary mt-4 mb-2" name="submit" value="<?= __('Save') ?>"/>
        <input type="submit" class="btn btn-link mt-4 mb-2" name="update" value="<?= __('Update List') ?>"/>
    </form>
    <div class="mt-3 mb-3">
        <a href="<?= $this->e($manage_url) ?>"><?= __('Managing languages') ?></a>
    </div>
</div>
