<?php
ob_start(); // Start reading html
$relativePath = "../../";
require_once $relativePath . 'classes/dao.php';
?>
    <div class="inner">
        <h1>ADMIN</h1>
        <h2>Edition de la carte</h2>


        <select id="mapSelect">
            <?php setup_map_dropdown() ?>
        </select>

        <br>

        <label for="titleInput">Titre</label>
        <input type="text" id="titleInput">

        <label for="descriptionInput">Description</label>
        <textarea rows="15" id="descriptionInput"></textarea>

        <div class="save">
            <i class="fas fa-save"></i> Enregistrer
        </div>
        <br>
        <div class="buttons-container">
            <a href="../index.php" class="admin-back-button">
                <i class="fas fa-chevron-left"></i>
                Retour sur la page admin
            </a>
            <a href="<?= $relativePath ?>map.php" class="website-back-button">
                Voir sur le site
            </a>
        </div>
    </div>


    <link rel="stylesheet" type="text/css" media="screen" href="<?= $relativePath ?>assets/css/adminEdit.css"/>

<?php
$pageContent = ob_get_clean(); // Store html content in variable
$pageTitle = "Édition carte";

$pageScripts = "<script type=\"text/javascript\" src=\"".$relativePath."assets/js/admin/mapManager.js\"></script>";

include($relativePath . "includes/template.php"); // Display template with variable content

function setup_map_dropdown()
{
    $dao = new Dao();
    foreach ($dao->get_map_selectors() as $row) {
        echo "<option value='" . $row['selector'] . "'>" . $row['selector'] . "</option>";
    }
}

?>
