sauver les grilles invalides

This commit is contained in:
2026-07-30 14:35:35 +02:00
parent 1f543ba622
commit 95b46e7a69
4 changed files with 58 additions and 41 deletions
+8 -11
View File
@@ -1,7 +1,4 @@
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
include_once "Grille.php";
@@ -35,17 +32,17 @@ $basedir = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["HTTP_HOST"] . dirname(
if (!isset($_GET["grille"]) || $_GET["grille"] == "") {
do {
$id = uniqid();
$grille_valide = $grille->genere($id);
} while (!$grille_valide);
$grille->genere($id);
} while (!$grille->valide);
$_GET["grille"] = $id;
header("Location: $basedir/?" . http_build_query($_GET));
} else {
$id = htmlspecialchars($_GET["grille"]);
$grille_valide = $grille->load($id) || $grille->genere($id);
$grille->load($id) || $grille->genere($id);
}
function formatter_definition($definition) {
function formatter_definition(Array $definition) {
if (isset($definition["nb_mots"]) && $definition["nb_mots"] > 1) {
$nb_mots = $definition["nb_mots"];
$nb_mots = " <small>($nb_mots mots)</small>";
@@ -61,7 +58,7 @@ function formatter_definition($definition) {
return ucfirst($definition["definition"]) . $nb_mots . $auteur;
}
function definition_courante($definitions, $position) {
function definition_courante(Array $definitions, int $position) {
foreach ($definitions as $id => $definition) {
if ($position <= $definition["fin"])
return [$id, $definition];
@@ -129,7 +126,7 @@ function definition_courante($definitions, $position) {
</h1>
<h1 class="small width"><a href=".">Mots■croisés</a></h1>
<div class="grille-et-definitions">
<?php if ($grille_valide): ?>
<?php if ($grille->valide): ?>
<div class="grille">
<table>
<tr>
@@ -154,10 +151,10 @@ function definition_courante($definitions, $position) {
$title = [];
[$iddh, $definition_horizontale] = definition_courante($grille->definitions["horizontales"][$y], $x);
[$iddv, $definition_verticale] = definition_courante($grille->definitions["verticales"][$x], $y);
if (isset($definition_horizontale["definition"])) $title[0] = "→ " . $definition_horizontale["definition"];
if (isset($definition_horizontale["definition"])) $title[0] = "→ " . strip_tags($definition_horizontale["definition"]);
if (isset($definition_horizontale["nb_mots"])) $title[0] .= " [" . $definition_horizontale["nb_mots"] . " mots]";
if (isset($definition_horizontale["auteur"])) $title[0] .= " (" . $definition_horizontale["auteur"] . ")";
if (isset($definition_verticale["definition"])) $title[1] = "↓ " . $definition_verticale["definition"];
if (isset($definition_verticale["definition"])) $title[1] = "↓ " . strip_tags($definition_verticale["definition"]);
if (isset($definition_verticale["nb_mots"])) $title[1] .= " [" . $definition_verticale["nb_mots"] . " mots]";
if (isset($definition_verticale["auteur"])) $title[1] .= " (" . $definition_verticale["auteur"] . ")";
$title = htmlspecialchars(implode("\n", $title));