summaryrefslogtreecommitdiff
path: root/Views/Includes/incl_index_search.php
diff options
context:
space:
mode:
authorDebulois <quentin@debulois.fr>2022-02-03 13:02:21 +0100
committerDebulois <quentin@debulois.fr>2022-02-03 13:02:21 +0100
commit5ddf8de3691fde866c5a48b440cffa2990b2014c (patch)
treee19215cb4a699ed767c731f65d3f796b4435530a /Views/Includes/incl_index_search.php
Initial commit
Diffstat (limited to 'Views/Includes/incl_index_search.php')
-rw-r--r--Views/Includes/incl_index_search.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/Views/Includes/incl_index_search.php b/Views/Includes/incl_index_search.php
new file mode 100644
index 0000000..df6372a
--- /dev/null
+++ b/Views/Includes/incl_index_search.php
@@ -0,0 +1,87 @@
+<?php
+// ****************************************************************************
+// Description: Partie recherche de l'index.
+// ****************************************************************************
+// Import des textes en fonction de la langue définie dans la variable "lang" de la session.
+require_once(dirname(__FILE__)."/".$_SESSION["lang"]."/text.php");
+// Import des en-têtes des tables.
+require_once(dirname( __FILE__ )."/".$_SESSION["lang"]."/table.php");
+// Separateur.
+echo(' <!-- Separateur -->
+ <div id="separator2" class="separator"></div>
+ <div id="search">'.PHP_EOL);
+// Form pour la recherche par nom et envoi au wrappeur.
+echo(' <!-- Form de recherche -->
+ <h2>'.$text[basename(__FILE__, ".php")]["h2"].'</h2>
+ <form action="/Wrapper/wrapper.php" method="post">
+ <label>
+ <i class="fas fa-search"></i>
+ <input type="search" name="search" id="searchBar"placeholder="'.$text[basename(__FILE__, ".php")]["searchBar"].'" required>
+ </label>
+ <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submit"].'">
+ </form>'.PHP_EOL);
+// Si l'index est chargé avec des données dans la variable "search" de la session,
+// c'est qu'une recherche à été effectuée, on affiche alors le contenu de cette recherche en tableau.
+if (isset($_SESSION["search"])) {
+ echo("<table><tr>");
+ // Si la variable isResearch est vrai, c'est une rechreche.
+ if ($_SESSION["search"]["isResearch"]) {
+ foreach ($header[1] as $header) {
+ echo("<th><pre>".$header."</pre></th>");
+ }
+ // Sinon c'est un "Plus d'info".
+ } else {
+ foreach ($header[2] as $header) {
+ echo("<th><pre>".$header."</pre></th>");
+ }
+ }
+ // On affiche le résultat de la recherche ou du "Plus d'info".
+ echo("</tr>");
+ foreach ($_SESSION["search"]["result"] as $rows) {
+ echo("<tr>");
+ foreach ($rows as $key => $value) {
+ if ($key !== "id") {
+ if ($key !== "star") {
+ echo("<td><pre>".$value."</pre></td>");
+ } else {
+ if ($value) {
+ echo('<td>');
+ $missingStar = 5 - $value;
+ for ($i = 0; $i < $value; $i++) {
+ echo('<i class="fa fa-star star checked"></i>');
+ }
+ if ($missingStar) {
+ for ($i = 0; $i < $missingStar; $i++) {
+ echo('<i class="fa fa-star star unchecked"></i>');
+ }
+ }
+ } else {
+ echo('<td>N/A');
+ }
+ echo("</td>");
+ }
+ }
+ }
+ // Si c'est une recherche on ajoute le bouton plus d'info,
+ // pour plus d'info avec une recherche par ID.
+ if ($_SESSION["search"]["isResearch"]) {
+ echo('<td class="noBorder" >
+ <form action="/Wrapper/wrapper.php" method="post">
+ <input type="hidden" name="searchInfo" value="'.$rows["id"].'">
+ <input type="submit" value="'.$text[basename(__FILE__, ".php")]["moreInfo"].'">
+ </form>
+ </td>');
+ }
+ echo("</tr>");
+ }
+ echo('<!-- Espace vide si le tableau est petit -->
+</table>
+<div class="spacer"></div>'.PHP_EOL);
+} else {
+ echo(' <!-- Espace vide -->
+ <div class="spacer"></div>'.PHP_EOL);
+}
+echo(' </div>');
+// On supprime la variable de recherche si elle existe.
+unset($_SESSION["search"]);
+?> \ No newline at end of file