liste unique de définition
This commit is contained in:
parent
bcfe6da555
commit
584f1a81a0
17
dico.php
17
dico.php
@ -12,15 +12,20 @@ if (($lecteur = fopen("dico.csv", "r")) !== FALSE) {
|
|||||||
while (($ligne = fgetcsv($lecteur, 0, "\t")) !== FALSE) {
|
while (($ligne = fgetcsv($lecteur, 0, "\t")) !== FALSE) {
|
||||||
if (substr($ligne[0], 0, 1) != "#" && count($ligne) >= 3) {
|
if (substr($ligne[0], 0, 1) != "#" && count($ligne) >= 3) {
|
||||||
[$mot, $definition, $auteur] = $ligne;
|
[$mot, $definition, $auteur] = $ligne;
|
||||||
|
$mot = strtoupper($mot);
|
||||||
if ($auteur) {
|
if ($auteur) {
|
||||||
$dico[strtoupper($mot)] = "$definition <small><em>$auteur</em></small>";
|
$definition .= " <small><em>$auteur</em></small>";
|
||||||
} else {
|
|
||||||
$dico[strtoupper($mot)] = $definition;
|
|
||||||
}
|
}
|
||||||
$nb_espaces = substr_count($mot, ' ');
|
$nb_espaces = substr_count($mot, ' ');
|
||||||
if ($nb_espaces > 0) {
|
if ($nb_espaces > 0) {
|
||||||
$dico[$mot] .= " <small>(" . ($nb_espaces + 1) . " mots)</small>";
|
$definition .= " <small>(" . ($nb_espaces + 1) . " mots)</small>";
|
||||||
}
|
}
|
||||||
|
if (strlen($definition)) {
|
||||||
|
$dico[$mot] = [$definition];
|
||||||
|
} else {
|
||||||
|
$dico[$mot] = [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($lecteur);
|
fclose($lecteur);
|
||||||
@ -62,9 +67,9 @@ function mots_espaces($longueur)
|
|||||||
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
||||||
foreach (mots_espaces($longueur - $i - 1) as $mot2) {
|
foreach (mots_espaces($longueur - $i - 1) as $mot2) {
|
||||||
if ($mot1 != $mot2) {
|
if ($mot1 != $mot2) {
|
||||||
$dico["$mot1 $mot2"] = $dico[$mot1] && $dico[$mot2] ? "<li>{$dico[$mot1]}</li><li>{$dico[$mot2]}</li>" : $dico[$mot1] . $dico[$mot2];
|
$dico["$mot1 $mot2"] = array_merge($dico[$mot1], $dico[$mot2]);
|
||||||
yield "$mot1 $mot2";
|
yield "$mot1 $mot2";
|
||||||
$dico["$mot2 $mot1"] = $dico[$mot2] && $dico[$mot1] ? "<li>{$dico[$mot2]}</li><li>{$dico[$mot1]}</li>" : $dico[$mot2] . $dico[$mot1];
|
$dico["$mot2 $mot1"] = array_merge($dico[$mot2], $dico[$mot1]);
|
||||||
yield "$mot2 $mot1";
|
yield "$mot2 $mot1";
|
||||||
$nb_mots += 2;
|
$nb_mots += 2;
|
||||||
if ($nb_mots > MAX_MOTS) {
|
if ($nb_mots > MAX_MOTS) {
|
||||||
|
28
index.php
28
index.php
@ -106,7 +106,18 @@ $grille = new Grille($hauteur, $largeur, $id);
|
|||||||
<h2>Horizontalement</h2>
|
<h2>Horizontalement</h2>
|
||||||
<ol>
|
<ol>
|
||||||
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
||||||
<li><ol><?= $dico[$grille->get_ligne($l, $largeur)] ?></ol></li>
|
<li>
|
||||||
|
<?php $definitions = $dico[$grille->get_ligne($l, $largeur)] ?>
|
||||||
|
<?php if (count($definitions) == 1): ?>
|
||||||
|
<?= $definitions[0] ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<ol>
|
||||||
|
<?php foreach ($dico[$grille->get_ligne($l, $largeur)] as $definition) : ?>
|
||||||
|
<li><?= $definition ?></li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ol>
|
||||||
|
<?php endif ?>
|
||||||
|
</li>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -114,12 +125,23 @@ $grille = new Grille($hauteur, $largeur, $id);
|
|||||||
<h2>Verticalement</h2>
|
<h2>Verticalement</h2>
|
||||||
<ol type="A">
|
<ol type="A">
|
||||||
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
||||||
<li><ol><?= $dico[$grille->get_colonne($c, $hauteur)] ?></ol></li>
|
<li>
|
||||||
|
<?php $definitions = $dico[$grille->get_colonne($c, $hauteur)] ?>
|
||||||
|
<?php if (count($definitions) == 1): ?>
|
||||||
|
<?= $definitions[0] ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<ol>
|
||||||
|
<?php foreach ($dico[$grille->get_colonne($c, $hauteur)] as $definition) : ?>
|
||||||
|
<li><?= $definition ?></li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ol>
|
||||||
|
<?php endif ?>
|
||||||
|
</li>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" id="lignes" <?php if (isset($_GET["lignes"])): ?>name="lignes" <?php endif ?>value="<?= $hauteur ?>" />
|
<input type="hidden" id="lignes" <?php if (isset($_GET["lignes"])): ?>name="lignes" <?php endif ?>value="<?= $hauteur ?>" />
|
||||||
<input type="hidden" id="colonnes" <?php if (isset($_GET["colonnes"])): ?>name="colonnes" <?php endif ?>value="<?= $largeur ?>" />
|
<input type="hidden" id="colonnes" <?php if (isset($_GET["colonnes"])): ?>name="colonnes" <?php endif ?>value="<?= $largeur ?>" />
|
||||||
<input type="hidden" id="solution_hashee" value="<?= $grille->hash() ?>" />
|
<input type="hidden" id="solution_hashee" value="<?= $grille->hash() ?>" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user