définitions en infobulle
This commit is contained in:
parent
64e4113aa7
commit
fcf7977e1a
24
Grille.php
24
Grille.php
@ -12,7 +12,7 @@ function melanger_cles($tableau)
|
||||
}
|
||||
|
||||
|
||||
class Grille implements ArrayAccess {
|
||||
class Grille implements Iterator, ArrayAccess {
|
||||
public $grille;
|
||||
public $hauteur;
|
||||
public $largeur;
|
||||
@ -101,12 +101,12 @@ class Grille implements ArrayAccess {
|
||||
$this->grille[$y][$x] = $lettre;
|
||||
|
||||
if ($x == $this->largeur - 1) {
|
||||
$mots_utilises[$y] = $this->get_ligne($y, $x);
|
||||
$this->mots_utilises[$y] = $this->get_ligne($y, $x);
|
||||
} else {
|
||||
unset($mots_utilises[$y]);
|
||||
unset($this->mots_utilises[$y]);
|
||||
}
|
||||
if ($y == $this->hauteur - 1) {
|
||||
if (in_array($this->get_colonne($x, $y), $mots_utilises)) {
|
||||
if (in_array($this->get_colonne($x, $y), $this->mots_utilises)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -128,12 +128,24 @@ class Grille implements ArrayAccess {
|
||||
return hash('sha256', $string);
|
||||
}
|
||||
|
||||
public function current()
|
||||
public function current(): mixed
|
||||
{
|
||||
return $this->grilles->current();
|
||||
}
|
||||
|
||||
public function valid()
|
||||
public function key(): mixed {
|
||||
return $this->grilles->key();
|
||||
}
|
||||
|
||||
public function next(): void {
|
||||
$this->grilles->next();
|
||||
}
|
||||
|
||||
public function rewind(): void {
|
||||
$this->grilles->rewind();
|
||||
}
|
||||
|
||||
public function valid(): bool
|
||||
{
|
||||
return $this->grilles->valid();
|
||||
}
|
||||
|
32
index.php
32
index.php
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
//ini_set('display_errors', '1');
|
||||
//ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('error_reporting', E_ALL);
|
||||
|
||||
|
||||
if (!isset($_GET["grille"])) {
|
||||
@ -37,7 +37,16 @@ $largeur = filter_input(INPUT_GET, 'c', FILTER_VALIDATE_INT, [
|
||||
|
||||
$grille = new Grille($hauteur, $largeur, $id);
|
||||
$grille->current();
|
||||
|
||||
$definitions = [
|
||||
"horizontales" => [],
|
||||
"verticales" => []
|
||||
];
|
||||
for ($y = 0; $y < $hauteur; $y++) {
|
||||
$definitions["horizontales"][$y] = $dico[$grille->get_ligne($y, $largeur)];
|
||||
}
|
||||
for ($x = 0; $x < $largeur; $x++) {
|
||||
$definitions["verticales"][$x] = $dico[$grille->get_colonne($x, $hauteur)];
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
@ -100,7 +109,8 @@ $grille->current();
|
||||
<?php if ($grille[$y][$x] == " "): ?>
|
||||
<input type="text" maxlength="1" size="1" value=" " disabled />
|
||||
<?php else: ?>
|
||||
<input type="text" maxlength="1" size="1" pattern="[A-Z]" placeholder="<?= $grille[$y][$x] ?>" />
|
||||
<input type="text" maxlength="1" size="1" pattern="[A-Z]" placeholder="<?= $grille[$y][$x] ?>"
|
||||
title="<?= "Horizontalement\n" . strip_tags(implode("\n", $definitions["horizontales"][$y])) . "\nVerticalement\n" . strip_tags(implode("\n", $definitions["verticales"][$x])) ?>" />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endfor; ?>
|
||||
@ -113,12 +123,11 @@ $grille->current();
|
||||
<ol>
|
||||
<?php for ($y = 0; $y < $hauteur; $y++): ?>
|
||||
<li>
|
||||
<?php $definitions = $dico[$grille->get_ligne($y, $largeur)] ?>
|
||||
<?php if (count($definitions) == 1): ?>
|
||||
<?= $definitions[0] ?>
|
||||
<?php if (count($definitions["horizontales"][$y]) == 1): ?>
|
||||
<?= $definitions["horizontales"][$y][0] ?>
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($dico[$grille->get_ligne($y, $largeur)] as $definition) : ?>
|
||||
<?php foreach ($definitions["horizontales"][$y] as $definition) : ?>
|
||||
<li><?= $definition ?></li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
@ -132,12 +141,11 @@ $grille->current();
|
||||
<ol type="A">
|
||||
<?php for ($x = 0; $x < $largeur; $x++): ?>
|
||||
<li>
|
||||
<?php $definitions = $dico[$grille->get_colonne($x, $hauteur)] ?>
|
||||
<?php if (count($definitions) == 1): ?>
|
||||
<?= $definitions[0] ?>
|
||||
<?php if (count($definitions["horizontales"][$x]) == 1): ?>
|
||||
<?= $definitions["horizontales"][$x][0] ?>
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($dico[$grille->get_colonne($x, $hauteur)] as $definition) : ?>
|
||||
<?php foreach ($definitions["horizontales"][$x] as $definition) : ?>
|
||||
<li><?= $definition ?></li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
|
Loading…
x
Reference in New Issue
Block a user