Compare commits
4
Commits
b785db1b84
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcd315489a | ||
|
|
36efa036a5 | ||
|
|
3235bc50c7 | ||
|
|
df11d023f0 |
No files matched your search
@@ -4,6 +4,8 @@ data/utilisateurs.json
|
||||
data/consoles.json
|
||||
data/jeux.json
|
||||
data/jaquettes/*
|
||||
data/consoles-photos/*
|
||||
data/cache/*
|
||||
!data/jaquettes/.gitkeep
|
||||
!data/consoles-photos/.gitkeep
|
||||
!data/cache/.gitkeep
|
||||
+5
-3
@@ -1,7 +1,10 @@
|
||||
FROM php:8.3-apache
|
||||
|
||||
RUN a2enmod rewrite headers \
|
||||
&& docker-php-ext-install opcache
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends libcurl4-openssl-dev \
|
||||
&& docker-php-ext-install opcache curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf
|
||||
COPY docker/php.ini /usr/local/etc/php/conf.d/jeuxvideotech.ini
|
||||
@@ -11,9 +14,8 @@ WORKDIR /var/www/html
|
||||
COPY public /var/www/html/public
|
||||
COPY src /var/www/html/src
|
||||
COPY templates /var/www/html/templates
|
||||
COPY data /var/www/html/data
|
||||
|
||||
RUN mkdir -p /var/www/html/data/jaquettes /var/www/html/data/cache \
|
||||
RUN mkdir -p /var/www/html/data/jaquettes /var/www/html/data/consoles-photos /var/www/html/data/cache \
|
||||
&& chown -R www-data:www-data /var/www/html/data
|
||||
|
||||
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
||||
|
||||
Whitespace-only changes.
+3
-2
@@ -1,7 +1,8 @@
|
||||
RewriteEngine On
|
||||
|
||||
# Servir les jaquettes stockées hors de public/
|
||||
RewriteRule ^jaquettes/(.*)$ /servir-jaquette.php?fichier=$1 [L,QSA]
|
||||
# Médias stockés hors de public/
|
||||
RewriteRule ^jaquettes/(.*)$ /servir-media.php?type=jaquettes&fichier=$1 [L,QSA]
|
||||
RewriteRule ^consoles-photos/(.*)$ /servir-media.php?type=consoles-photos&fichier=$1 [L,QSA]
|
||||
|
||||
# Fichiers / dossiers existants : ne pas réécrire
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
|
||||
+154
-5
@@ -342,7 +342,8 @@ a:hover
|
||||
{
|
||||
width: 100%;
|
||||
aspect-ratio: 3 / 4;
|
||||
object-fit: cover;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
background: var(--bg-elevated);
|
||||
}
|
||||
|
||||
@@ -378,6 +379,79 @@ a:hover
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.game-card-badges
|
||||
{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.badge-format
|
||||
{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.15rem 0.55rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.03em;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--text);
|
||||
background: rgba(0, 229, 255, 0.08);
|
||||
}
|
||||
|
||||
.format-physique
|
||||
{
|
||||
border-color: rgba(124, 255, 107, 0.45);
|
||||
color: var(--accent-hot);
|
||||
}
|
||||
|
||||
.format-dematerialise
|
||||
{
|
||||
border-color: rgba(0, 229, 255, 0.45);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.format-rom
|
||||
{
|
||||
border-color: rgba(255, 200, 87, 0.45);
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.format-checks
|
||||
{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.format-check
|
||||
{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
padding: 0.55rem 0.85rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: rgba(4, 12, 22, 0.55);
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.format-check:has(input:checked)
|
||||
{
|
||||
border-color: rgba(0, 229, 255, 0.55);
|
||||
box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.2);
|
||||
}
|
||||
|
||||
.format-check input
|
||||
{
|
||||
accent-color: var(--accent);
|
||||
width: 1.05rem;
|
||||
height: 1.05rem;
|
||||
}
|
||||
|
||||
.etat-possede
|
||||
{
|
||||
color: #041018;
|
||||
@@ -441,6 +515,77 @@ a:hover
|
||||
margin-bottom: 0.7rem;
|
||||
}
|
||||
|
||||
.console-photo
|
||||
{
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 10;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
margin-bottom: 0.85rem;
|
||||
background: var(--bg-elevated);
|
||||
}
|
||||
|
||||
.console-photo img,
|
||||
.console-photo-preview img,
|
||||
.console-cover img
|
||||
{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.console-photo-preview,
|
||||
.console-cover
|
||||
{
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
box-shadow: var(--shadow);
|
||||
background: var(--bg-elevated);
|
||||
aspect-ratio: 16 / 10;
|
||||
}
|
||||
|
||||
.console-detail-hero
|
||||
{
|
||||
grid-template-columns: minmax(220px, 340px) 1fr;
|
||||
}
|
||||
|
||||
.photo-upload-bar
|
||||
{
|
||||
padding: 1rem;
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: var(--radius);
|
||||
background: rgba(4, 12, 22, 0.45);
|
||||
}
|
||||
|
||||
.photo-upload-bar .form-label
|
||||
{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.photo-upload-row
|
||||
{
|
||||
display: flex;
|
||||
gap: 0.65rem;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.photo-upload-row .form-control
|
||||
{
|
||||
flex: 1 1 220px;
|
||||
}
|
||||
|
||||
.photo-upload-row .btn
|
||||
{
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.console-card h2
|
||||
{
|
||||
font-size: 1.25rem;
|
||||
@@ -541,7 +686,8 @@ a:hover
|
||||
border: 1px solid var(--line);
|
||||
box-shadow: var(--shadow);
|
||||
aspect-ratio: 3 / 4;
|
||||
object-fit: cover;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
background: var(--bg-elevated);
|
||||
}
|
||||
|
||||
@@ -760,15 +906,18 @@ a:hover
|
||||
{
|
||||
.auth-shell,
|
||||
.detail-hero,
|
||||
.detail-grid
|
||||
.detail-grid,
|
||||
.console-detail-hero
|
||||
{
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.detail-cover,
|
||||
.cover-preview
|
||||
.cover-preview,
|
||||
.console-cover,
|
||||
.console-photo-preview
|
||||
{
|
||||
max-width: 220px;
|
||||
max-width: 340px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="480" height="320" viewBox="0 0 480 320" role="img" aria-label="Photo de console manquante">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#122338"/>
|
||||
<stop offset="100%" stop-color="#07101c"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="480" height="320" fill="url(#bg)"/>
|
||||
<rect x="18" y="18" width="444" height="284" rx="12" fill="none" stroke="#00e5ff" stroke-opacity="0.35" stroke-width="2"/>
|
||||
<rect x="160" y="110" width="160" height="90" rx="14" fill="none" stroke="#7cff6b" stroke-opacity="0.6" stroke-width="3"/>
|
||||
<circle cx="190" cy="155" r="10" fill="#00e5ff" fill-opacity="0.7"/>
|
||||
<circle cx="290" cy="155" r="10" fill="#00e5ff" fill-opacity="0.7"/>
|
||||
<text x="240" y="250" text-anchor="middle" fill="#8aa0b8" font-family="Arial, sans-serif" font-size="18">Pas de photo</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 910 B |
@@ -5,12 +5,69 @@ document.addEventListener("DOMContentLoaded", () =>
|
||||
const zoneResultats = document.getElementById("resultatsApi");
|
||||
const formAppliquer = document.getElementById("formAppliquerApi");
|
||||
const champRawgId = document.getElementById("rawgId");
|
||||
const formJeu = document.getElementById("formJeu");
|
||||
|
||||
if (!boutonRecherche || !champRecherche || !zoneResultats)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const collecterChampsFormulaire = () =>
|
||||
{
|
||||
if (!formJeu || !formAppliquer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
formAppliquer.querySelectorAll("[data-from-form]").forEach((element) =>
|
||||
{
|
||||
element.remove();
|
||||
});
|
||||
|
||||
const noms = [
|
||||
"titre",
|
||||
"description",
|
||||
"dateSortie",
|
||||
"genres",
|
||||
"editeur",
|
||||
"developpeur",
|
||||
"jaquette",
|
||||
"consoleId",
|
||||
"etat",
|
||||
"notes",
|
||||
"sourceEnrichissement"
|
||||
];
|
||||
|
||||
noms.forEach((nom) =>
|
||||
{
|
||||
const champ = formJeu.elements.namedItem(nom);
|
||||
|
||||
if (!champ || typeof champ.value !== "string")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const cache = document.createElement("input");
|
||||
cache.type = "hidden";
|
||||
cache.name = nom;
|
||||
cache.value = champ.value;
|
||||
cache.setAttribute("data-from-form", "1");
|
||||
formAppliquer.appendChild(cache);
|
||||
});
|
||||
|
||||
const formats = formJeu.querySelectorAll('input[name="formats[]"]:checked');
|
||||
|
||||
formats.forEach((caseCochee) =>
|
||||
{
|
||||
const cache = document.createElement("input");
|
||||
cache.type = "hidden";
|
||||
cache.name = "formats[]";
|
||||
cache.value = caseCochee.value;
|
||||
cache.setAttribute("data-from-form", "1");
|
||||
formAppliquer.appendChild(cache);
|
||||
});
|
||||
};
|
||||
|
||||
const lancerRecherche = async () =>
|
||||
{
|
||||
const terme = champRecherche.value.trim();
|
||||
@@ -84,6 +141,7 @@ document.addEventListener("DOMContentLoaded", () =>
|
||||
return;
|
||||
}
|
||||
|
||||
collecterChampsFormulaire();
|
||||
champRawgId.value = String(jeu.rawgId);
|
||||
formAppliquer.submit();
|
||||
});
|
||||
|
||||
@@ -6,15 +6,21 @@ require_once dirname(__DIR__) . "/src/Config.php";
|
||||
|
||||
Config::charger();
|
||||
|
||||
$type = $_GET["type"] ?? "jaquettes";
|
||||
$fichier = basename($_GET["fichier"] ?? "");
|
||||
|
||||
if ($fichier === "" || str_contains($fichier, ".."))
|
||||
$dossiers = [
|
||||
"jaquettes" => Config::get("jaquettesPath"),
|
||||
"consoles-photos" => Config::get("consolesPhotosPath")
|
||||
];
|
||||
|
||||
if ($fichier === "" || str_contains($fichier, "..") || !isset($dossiers[$type]))
|
||||
{
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
||||
$chemin = Config::get("jaquettesPath") . "/" . $fichier;
|
||||
$chemin = $dossiers[$type] . "/" . $fichier;
|
||||
|
||||
if (!is_file($chemin))
|
||||
{
|
||||
@@ -18,6 +18,7 @@ final class Config
|
||||
"sessionLifetime" => (int) self::env("SESSION_LIFETIME", "86400"),
|
||||
"dataPath" => dirname(__DIR__) . "/data",
|
||||
"jaquettesPath" => dirname(__DIR__) . "/data/jaquettes",
|
||||
"consolesPhotosPath" => dirname(__DIR__) . "/data/consoles-photos",
|
||||
"cachePath" => dirname(__DIR__) . "/data/cache"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -62,11 +62,15 @@ final class ConsoleController
|
||||
|
||||
try
|
||||
{
|
||||
$console = $this->consoleService->creer($utilisateur["id"], $_POST);
|
||||
$console = $this->consoleService->creer(
|
||||
$utilisateur["id"],
|
||||
$_POST,
|
||||
$_FILES["photo"] ?? null
|
||||
);
|
||||
Flash::definir("success", "Console ajoutée.");
|
||||
Helpers::rediriger("/consoles/" . $console["id"]);
|
||||
}
|
||||
catch (InvalidArgumentException $exception)
|
||||
catch (InvalidArgumentException | RuntimeException $exception)
|
||||
{
|
||||
Flash::definir("danger", $exception->getMessage());
|
||||
}
|
||||
@@ -97,11 +101,16 @@ final class ConsoleController
|
||||
|
||||
try
|
||||
{
|
||||
$console = $this->consoleService->modifier($id, $utilisateur["id"], $_POST);
|
||||
$console = $this->consoleService->modifier(
|
||||
$id,
|
||||
$utilisateur["id"],
|
||||
$_POST,
|
||||
$_FILES["photo"] ?? null
|
||||
);
|
||||
Flash::definir("success", "Console mise à jour.");
|
||||
Helpers::rediriger("/consoles/" . $console["id"]);
|
||||
}
|
||||
catch (InvalidArgumentException $exception)
|
||||
catch (InvalidArgumentException | RuntimeException $exception)
|
||||
{
|
||||
Flash::definir("danger", $exception->getMessage());
|
||||
}
|
||||
@@ -115,6 +124,54 @@ final class ConsoleController
|
||||
]);
|
||||
}
|
||||
|
||||
public function envoyerPhoto(string $id): void
|
||||
{
|
||||
$utilisateur = $this->auth->exigerConnexion();
|
||||
Csrf::exiger();
|
||||
|
||||
$console = $this->consoleService->trouverPourUtilisateur($id, $utilisateur["id"]);
|
||||
|
||||
if ($console === null)
|
||||
{
|
||||
Flash::definir("danger", "Console introuvable.");
|
||||
Helpers::rediriger("/consoles");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->consoleService->mettreAJourPhoto(
|
||||
$id,
|
||||
$utilisateur["id"],
|
||||
$_FILES["photo"] ?? []
|
||||
);
|
||||
Flash::definir("success", "Photo de la console enregistrée.");
|
||||
}
|
||||
catch (InvalidArgumentException | RuntimeException $exception)
|
||||
{
|
||||
Flash::definir("danger", $exception->getMessage());
|
||||
}
|
||||
|
||||
Helpers::rediriger("/consoles/" . $id);
|
||||
}
|
||||
|
||||
public function supprimerPhoto(string $id): void
|
||||
{
|
||||
$utilisateur = $this->auth->exigerConnexion();
|
||||
Csrf::exiger();
|
||||
|
||||
try
|
||||
{
|
||||
$this->consoleService->supprimerPhoto($id, $utilisateur["id"]);
|
||||
Flash::definir("success", "Photo supprimée.");
|
||||
}
|
||||
catch (RuntimeException $exception)
|
||||
{
|
||||
Flash::definir("danger", $exception->getMessage());
|
||||
}
|
||||
|
||||
Helpers::rediriger("/consoles/" . $id);
|
||||
}
|
||||
|
||||
public function supprimer(string $id): void
|
||||
{
|
||||
$utilisateur = $this->auth->exigerConnexion();
|
||||
|
||||
@@ -19,12 +19,14 @@ final class JeuController
|
||||
$recherche = Helpers::champ("q");
|
||||
$consoleId = Helpers::champ("console");
|
||||
$etat = Helpers::champ("etat");
|
||||
$format = Helpers::champ("format");
|
||||
|
||||
$jeux = $this->jeuService->listerPourUtilisateur(
|
||||
$utilisateur["id"],
|
||||
$recherche !== "" ? $recherche : null,
|
||||
$consoleId !== "" ? $consoleId : null,
|
||||
$etat !== "" ? $etat : null
|
||||
$etat !== "" ? $etat : null,
|
||||
$format !== "" ? $format : null
|
||||
);
|
||||
|
||||
$consoles = $this->consoleService->listerPourUtilisateur($utilisateur["id"]);
|
||||
@@ -44,7 +46,8 @@ final class JeuController
|
||||
"filtres" => [
|
||||
"q" => $recherche,
|
||||
"console" => $consoleId,
|
||||
"etat" => $etat
|
||||
"etat" => $etat,
|
||||
"format" => $format
|
||||
]
|
||||
]);
|
||||
}
|
||||
@@ -69,7 +72,9 @@ final class JeuController
|
||||
"titrePage" => $jeu["titre"],
|
||||
"utilisateur" => $utilisateur,
|
||||
"jeu" => $jeu,
|
||||
"console" => $console
|
||||
"console" => $console,
|
||||
"jaquetteAbsente" => Helpers::jaquetteAbsente($jeu["jaquette"] ?? null),
|
||||
"apiDisponible" => $this->enrichissementService->estDisponible()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -93,6 +98,8 @@ final class JeuController
|
||||
try
|
||||
{
|
||||
$donnees = $this->collecterDonneesFormulaire();
|
||||
$donnees = $this->appliquerUploadJaquette($donnees);
|
||||
$donnees = $this->completerJaquetteSiAbsente($donnees);
|
||||
$jeu = $this->jeuService->creer($utilisateur["id"], $donnees);
|
||||
Flash::definir("success", "Jeu ajouté à votre bibliothèque.");
|
||||
Helpers::rediriger("/jeux/" . $jeu["id"]);
|
||||
@@ -134,6 +141,8 @@ final class JeuController
|
||||
try
|
||||
{
|
||||
$donnees = $this->collecterDonneesFormulaire();
|
||||
$donnees = $this->appliquerUploadJaquette($donnees);
|
||||
$donnees = $this->completerJaquetteSiAbsente($donnees);
|
||||
$jeu = $this->jeuService->modifier($id, $utilisateur["id"], $donnees);
|
||||
Flash::definir("success", "Jeu mis à jour.");
|
||||
Helpers::rediriger("/jeux/" . $jeu["id"]);
|
||||
@@ -144,9 +153,13 @@ final class JeuController
|
||||
$jeu = array_merge($jeu, $_POST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$jeu = $this->appliquerPrefillGetSurJeu($jeu);
|
||||
}
|
||||
|
||||
View::rendre("jeux/formulaire", [
|
||||
"titrePage" => "Modifier " . $jeu["titre"],
|
||||
"titrePage" => "Modifier " . ($jeu["titre"] ?? "jeu"),
|
||||
"utilisateur" => $utilisateur,
|
||||
"jeu" => $jeu,
|
||||
"consoles" => $consoles,
|
||||
@@ -212,21 +225,198 @@ final class JeuController
|
||||
Helpers::rediriger($retour);
|
||||
}
|
||||
|
||||
$jaquette = $this->enrichissementService->telechargerJaquette($detail["jaquetteUrl"] ?? null);
|
||||
$existants = [
|
||||
"titre" => Helpers::champ("titre"),
|
||||
"description" => Helpers::champ("description"),
|
||||
"dateSortie" => Helpers::champ("dateSortie"),
|
||||
"genres" => Helpers::champ("genres"),
|
||||
"editeur" => Helpers::champ("editeur"),
|
||||
"developpeur" => Helpers::champ("developpeur"),
|
||||
"jaquette" => Helpers::champ("jaquette"),
|
||||
"consoleId" => Helpers::champ("consoleId"),
|
||||
"etat" => Helpers::champ("etat"),
|
||||
"notes" => Helpers::champ("notes"),
|
||||
"formats" => isset($_POST["formats"]) && is_array($_POST["formats"])
|
||||
? Helpers::normaliserFormats($_POST["formats"])
|
||||
: []
|
||||
];
|
||||
|
||||
$depuisApi = [
|
||||
"titre" => (string) ($detail["titre"] ?? ""),
|
||||
"description" => (string) ($detail["description"] ?? ""),
|
||||
"dateSortie" => (string) ($detail["dateSortie"] ?? ""),
|
||||
"genres" => implode(", ", $detail["genres"] ?? []),
|
||||
"editeur" => (string) ($detail["editeur"] ?? ""),
|
||||
"developpeur" => (string) ($detail["developpeur"] ?? "")
|
||||
];
|
||||
|
||||
$fusion = [];
|
||||
|
||||
foreach ($depuisApi as $cle => $valeurApi)
|
||||
{
|
||||
$valeurActuelle = trim((string) ($existants[$cle] ?? ""));
|
||||
$fusion[$cle] = $valeurActuelle !== "" ? $valeurActuelle : trim($valeurApi);
|
||||
}
|
||||
|
||||
$fusion["consoleId"] = $existants["consoleId"];
|
||||
$fusion["etat"] = $existants["etat"] !== "" ? $existants["etat"] : "possede";
|
||||
$fusion["notes"] = $existants["notes"];
|
||||
$fusion["formats"] = $existants["formats"];
|
||||
|
||||
if (!Helpers::jaquetteAbsente($existants["jaquette"]))
|
||||
{
|
||||
$fusion["jaquette"] = $existants["jaquette"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$jaquette = $this->enrichissementService->telechargerJaquette($detail["jaquetteUrl"] ?? null);
|
||||
$fusion["jaquette"] = $jaquette ?? "";
|
||||
}
|
||||
|
||||
$fusion["sourceEnrichissement"] = !Helpers::jaquetteAbsente($fusion["jaquette"] ?? null)
|
||||
|| $fusion["description"] !== ""
|
||||
|| $fusion["dateSortie"] !== ""
|
||||
? "api"
|
||||
: (Helpers::champ("sourceEnrichissement", "manuel"));
|
||||
|
||||
$query = http_build_query([
|
||||
"titre" => $detail["titre"] ?? "",
|
||||
"description" => $detail["description"] ?? "",
|
||||
"dateSortie" => $detail["dateSortie"] ?? "",
|
||||
"genres" => implode(", ", $detail["genres"] ?? []),
|
||||
"editeur" => $detail["editeur"] ?? "",
|
||||
"developpeur" => $detail["developpeur"] ?? "",
|
||||
"jaquette" => $jaquette ?? "",
|
||||
"sourceEnrichissement" => "api"
|
||||
"titre" => $fusion["titre"],
|
||||
"description" => $fusion["description"],
|
||||
"dateSortie" => $fusion["dateSortie"],
|
||||
"genres" => $fusion["genres"],
|
||||
"editeur" => $fusion["editeur"],
|
||||
"developpeur" => $fusion["developpeur"],
|
||||
"jaquette" => $fusion["jaquette"],
|
||||
"consoleId" => $fusion["consoleId"],
|
||||
"etat" => $fusion["etat"],
|
||||
"notes" => $fusion["notes"],
|
||||
"formats" => $fusion["formats"],
|
||||
"sourceEnrichissement" => $fusion["sourceEnrichissement"]
|
||||
]);
|
||||
|
||||
$separateur = str_contains($retour, "?") ? "&" : "?";
|
||||
Helpers::rediriger($retour . $separateur . $query);
|
||||
$cheminRetour = parse_url($retour, PHP_URL_PATH) ?: "/jeux/creer";
|
||||
Helpers::rediriger($cheminRetour . "?" . $query);
|
||||
}
|
||||
|
||||
public function recupererJaquette(string $id): void
|
||||
{
|
||||
$utilisateur = $this->auth->exigerConnexion();
|
||||
Csrf::exiger();
|
||||
|
||||
$jeu = $this->jeuService->trouverPourUtilisateur($id, $utilisateur["id"]);
|
||||
|
||||
if ($jeu === null)
|
||||
{
|
||||
Flash::definir("danger", "Jeu introuvable.");
|
||||
Helpers::rediriger("/jeux");
|
||||
}
|
||||
|
||||
if (!Helpers::jaquetteAbsente($jeu["jaquette"] ?? null))
|
||||
{
|
||||
Flash::definir("success", "Ce jeu a déjà une jaquette.");
|
||||
Helpers::rediriger("/jeux/" . $id);
|
||||
}
|
||||
|
||||
if (!$this->enrichissementService->estDisponible())
|
||||
{
|
||||
Flash::definir("warning", "Clé API RAWG absente : impossible de récupérer la jaquette.");
|
||||
Helpers::rediriger("/jeux/" . $id);
|
||||
}
|
||||
|
||||
$fichier = $this->enrichissementService->recupererJaquetteParTitre($jeu["titre"] ?? "");
|
||||
|
||||
if ($fichier === null)
|
||||
{
|
||||
Flash::definir("warning", "Aucune jaquette trouvée pour ce titre.");
|
||||
Helpers::rediriger("/jeux/" . $id);
|
||||
}
|
||||
|
||||
$this->jeuService->modifier($id, $utilisateur["id"], array_merge($jeu, [
|
||||
"jaquette" => $fichier,
|
||||
"genres" => $jeu["genres"] ?? [],
|
||||
"formats" => $jeu["formats"] ?? [],
|
||||
"sourceEnrichissement" => ($jeu["sourceEnrichissement"] ?? "") === "manuel" ? "api" : ($jeu["sourceEnrichissement"] ?? "api")
|
||||
]));
|
||||
|
||||
Flash::definir("success", "Jaquette récupérée depuis RAWG.");
|
||||
Helpers::rediriger("/jeux/" . $id);
|
||||
}
|
||||
|
||||
public function envoyerJaquette(string $id): void
|
||||
{
|
||||
$utilisateur = $this->auth->exigerConnexion();
|
||||
Csrf::exiger();
|
||||
|
||||
$jeu = $this->jeuService->trouverPourUtilisateur($id, $utilisateur["id"]);
|
||||
|
||||
if ($jeu === null)
|
||||
{
|
||||
Flash::definir("danger", "Jeu introuvable.");
|
||||
Helpers::rediriger("/jeux");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->jeuService->remplacerJaquette(
|
||||
$id,
|
||||
$utilisateur["id"],
|
||||
$_FILES["jaquetteFichier"] ?? []
|
||||
);
|
||||
Flash::definir("success", "Jaquette remplacée.");
|
||||
}
|
||||
catch (InvalidArgumentException | RuntimeException $exception)
|
||||
{
|
||||
Flash::definir("danger", $exception->getMessage());
|
||||
}
|
||||
|
||||
Helpers::rediriger("/jeux/" . $id);
|
||||
}
|
||||
|
||||
private function appliquerUploadJaquette(array $donnees): array
|
||||
{
|
||||
$fichier = $_FILES["jaquetteFichier"] ?? null;
|
||||
|
||||
if (!is_array($fichier) || (($fichier["error"] ?? UPLOAD_ERR_NO_FILE) === UPLOAD_ERR_NO_FILE))
|
||||
{
|
||||
return $donnees;
|
||||
}
|
||||
|
||||
$nomFichier = ImageUpload::enregistrer(
|
||||
$fichier,
|
||||
Config::get("jaquettesPath")
|
||||
);
|
||||
|
||||
$donnees["jaquette"] = $nomFichier;
|
||||
$donnees["sourceEnrichissement"] = "manuel";
|
||||
|
||||
return $donnees;
|
||||
}
|
||||
|
||||
private function completerJaquetteSiAbsente(array $donnees): array
|
||||
{
|
||||
if (!Helpers::jaquetteAbsente($donnees["jaquette"] ?? null))
|
||||
{
|
||||
return $donnees;
|
||||
}
|
||||
|
||||
if (!$this->enrichissementService->estDisponible())
|
||||
{
|
||||
return $donnees;
|
||||
}
|
||||
|
||||
$fichier = $this->enrichissementService->recupererJaquetteParTitre($donnees["titre"] ?? "");
|
||||
|
||||
if ($fichier !== null)
|
||||
{
|
||||
$donnees["jaquette"] = $fichier;
|
||||
|
||||
if (($donnees["sourceEnrichissement"] ?? "manuel") === "manuel")
|
||||
{
|
||||
$donnees["sourceEnrichissement"] = "api";
|
||||
}
|
||||
}
|
||||
|
||||
return $donnees;
|
||||
}
|
||||
|
||||
private function collecterDonneesFormulaire(): array
|
||||
@@ -235,6 +425,7 @@ final class JeuController
|
||||
"titre" => Helpers::champ("titre"),
|
||||
"consoleId" => Helpers::champ("consoleId"),
|
||||
"etat" => Helpers::champ("etat", "possede"),
|
||||
"formats" => $_POST["formats"] ?? [],
|
||||
"jaquette" => Helpers::champ("jaquette"),
|
||||
"description" => Helpers::champ("description"),
|
||||
"dateSortie" => Helpers::champ("dateSortie"),
|
||||
@@ -249,11 +440,18 @@ final class JeuController
|
||||
private function construirePrefillDepuisGet(): array
|
||||
{
|
||||
$genres = Helpers::champ("genres");
|
||||
$formats = $_GET["formats"] ?? [];
|
||||
|
||||
if (!is_array($formats))
|
||||
{
|
||||
$formats = [];
|
||||
}
|
||||
|
||||
return [
|
||||
"titre" => Helpers::champ("titre"),
|
||||
"consoleId" => Helpers::champ("consoleId"),
|
||||
"etat" => Helpers::champ("etat", "possede"),
|
||||
"formats" => Helpers::normaliserFormats($formats),
|
||||
"jaquette" => Helpers::champ("jaquette"),
|
||||
"description" => Helpers::champ("description"),
|
||||
"dateSortie" => Helpers::champ("dateSortie"),
|
||||
@@ -264,4 +462,44 @@ final class JeuController
|
||||
"sourceEnrichissement" => Helpers::champ("sourceEnrichissement", "manuel")
|
||||
];
|
||||
}
|
||||
|
||||
private function appliquerPrefillGetSurJeu(array $jeu): array
|
||||
{
|
||||
if (empty($_GET))
|
||||
{
|
||||
return $jeu;
|
||||
}
|
||||
|
||||
$prefill = $this->construirePrefillDepuisGet();
|
||||
|
||||
foreach ($prefill as $cle => $valeur)
|
||||
{
|
||||
if ($cle === "formats")
|
||||
{
|
||||
if ($valeur !== [])
|
||||
{
|
||||
$jeu[$cle] = $valeur;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($cle === "genres")
|
||||
{
|
||||
if ($valeur !== [])
|
||||
{
|
||||
$jeu[$cle] = $valeur;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_string($valeur) && trim($valeur) !== "")
|
||||
{
|
||||
$jeu[$cle] = $valeur;
|
||||
}
|
||||
}
|
||||
|
||||
return $jeu;
|
||||
}
|
||||
}
|
||||
+93
-2
@@ -52,19 +52,110 @@ final class Helpers
|
||||
return self::etatsJeu()[$etat] ?? $etat;
|
||||
}
|
||||
|
||||
public static function formatsJeu(): array
|
||||
{
|
||||
return [
|
||||
"physique" => "Physique",
|
||||
"dematerialise" => "Dématérialisé",
|
||||
"rom" => "ROM"
|
||||
];
|
||||
}
|
||||
|
||||
public static function libelleFormat(string $format): string
|
||||
{
|
||||
return self::formatsJeu()[$format] ?? $format;
|
||||
}
|
||||
|
||||
public static function normaliserFormats(mixed $formats): array
|
||||
{
|
||||
if (!is_array($formats))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$autorises = array_keys(self::formatsJeu());
|
||||
$resultat = [];
|
||||
|
||||
foreach ($formats as $format)
|
||||
{
|
||||
$format = is_string($format) ? trim($format) : "";
|
||||
|
||||
if ($format !== "" && in_array($format, $autorises, true))
|
||||
{
|
||||
$resultat[] = $format;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($resultat));
|
||||
}
|
||||
|
||||
public static function champCoche(string $nom): bool
|
||||
{
|
||||
return isset($_POST[$nom]) || isset($_GET[$nom]);
|
||||
}
|
||||
|
||||
public static function urlJaquette(?string $chemin): string
|
||||
{
|
||||
if ($chemin === null || $chemin === "")
|
||||
if (self::jaquetteAbsente($chemin))
|
||||
{
|
||||
return "/assets/img/jaquette-manquante.svg";
|
||||
}
|
||||
|
||||
if (str_starts_with((string) $chemin, "http://") || str_starts_with((string) $chemin, "https://"))
|
||||
{
|
||||
return (string) $chemin;
|
||||
}
|
||||
|
||||
return "/jaquettes/" . ltrim((string) $chemin, "/");
|
||||
}
|
||||
|
||||
public static function jaquetteAbsente(?string $chemin): bool
|
||||
{
|
||||
if ($chemin === null || trim($chemin) === "")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_starts_with($chemin, "http://") || str_starts_with($chemin, "https://"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$fichier = Config::get("jaquettesPath") . "/" . basename($chemin);
|
||||
|
||||
return !is_file($fichier);
|
||||
}
|
||||
|
||||
public static function urlPhotoConsole(?string $chemin): string
|
||||
{
|
||||
if ($chemin === null || trim($chemin) === "")
|
||||
{
|
||||
return "/assets/img/console-manquante.svg";
|
||||
}
|
||||
|
||||
if (str_starts_with($chemin, "http://") || str_starts_with($chemin, "https://"))
|
||||
{
|
||||
return $chemin;
|
||||
}
|
||||
|
||||
return "/jaquettes/" . ltrim($chemin, "/");
|
||||
return "/consoles-photos/" . ltrim($chemin, "/");
|
||||
}
|
||||
|
||||
public static function photoConsoleAbsente(?string $chemin): bool
|
||||
{
|
||||
if ($chemin === null || trim($chemin) === "")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_starts_with($chemin, "http://") || str_starts_with($chemin, "https://"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$fichier = Config::get("consolesPhotosPath") . "/" . basename($chemin);
|
||||
|
||||
return !is_file($fichier);
|
||||
}
|
||||
|
||||
public static function tronquer(string $texte, int $longueur = 140): string
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Upload d'images locales (jaquettes, photos de consoles).
|
||||
*/
|
||||
final class ImageUpload
|
||||
{
|
||||
private const EXTENSIONS = [
|
||||
"image/jpeg" => "jpg",
|
||||
"image/png" => "png",
|
||||
"image/webp" => "webp",
|
||||
"image/gif" => "gif"
|
||||
];
|
||||
|
||||
public static function enregistrer(array $fichier, string $dossierCible, int $tailleMaxMo = 5): string
|
||||
{
|
||||
if (($fichier["error"] ?? UPLOAD_ERR_NO_FILE) === UPLOAD_ERR_NO_FILE)
|
||||
{
|
||||
throw new InvalidArgumentException("Aucun fichier sélectionné.");
|
||||
}
|
||||
|
||||
if (($fichier["error"] ?? UPLOAD_ERR_OK) !== UPLOAD_ERR_OK)
|
||||
{
|
||||
throw new InvalidArgumentException("Échec de l'envoi du fichier.");
|
||||
}
|
||||
|
||||
$tailleMax = $tailleMaxMo * 1024 * 1024;
|
||||
|
||||
if (($fichier["size"] ?? 0) <= 0 || ($fichier["size"] ?? 0) > $tailleMax)
|
||||
{
|
||||
throw new InvalidArgumentException("La photo doit faire moins de " . $tailleMaxMo . " Mo.");
|
||||
}
|
||||
|
||||
$tmp = (string) ($fichier["tmp_name"] ?? "");
|
||||
|
||||
if ($tmp === "" || !is_uploaded_file($tmp))
|
||||
{
|
||||
throw new InvalidArgumentException("Fichier upload invalide.");
|
||||
}
|
||||
|
||||
$info = @getimagesize($tmp);
|
||||
|
||||
if ($info === false || empty($info["mime"]))
|
||||
{
|
||||
throw new InvalidArgumentException("Le fichier doit être une image (JPG, PNG, WebP ou GIF).");
|
||||
}
|
||||
|
||||
$mime = (string) $info["mime"];
|
||||
|
||||
if (!isset(self::EXTENSIONS[$mime]))
|
||||
{
|
||||
throw new InvalidArgumentException("Format d'image non supporté.");
|
||||
}
|
||||
|
||||
if (!is_dir($dossierCible))
|
||||
{
|
||||
mkdir($dossierCible, 0775, true);
|
||||
}
|
||||
|
||||
$nomFichier = Helpers::genererId() . "." . self::EXTENSIONS[$mime];
|
||||
$destination = rtrim($dossierCible, "/\\") . "/" . $nomFichier;
|
||||
|
||||
if (!move_uploaded_file($tmp, $destination))
|
||||
{
|
||||
throw new RuntimeException("Impossible d'enregistrer la photo.");
|
||||
}
|
||||
|
||||
return $nomFichier;
|
||||
}
|
||||
|
||||
public static function supprimer(?string $nomFichier, string $dossierCible): void
|
||||
{
|
||||
if ($nomFichier === null || $nomFichier === "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (str_starts_with($nomFichier, "http://") || str_starts_with($nomFichier, "https://"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$chemin = rtrim($dossierCible, "/\\") . "/" . basename($nomFichier);
|
||||
|
||||
if (is_file($chemin))
|
||||
{
|
||||
unlink($chemin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ final class ConsoleService
|
||||
return $console;
|
||||
}
|
||||
|
||||
public function creer(string $utilisateurId, array $donnees): array
|
||||
public function creer(string $utilisateurId, array $donnees, ?array $fichierPhoto = null): array
|
||||
{
|
||||
$nom = trim((string) ($donnees["nom"] ?? ""));
|
||||
$constructeur = trim((string) ($donnees["constructeur"] ?? ""));
|
||||
@@ -47,7 +47,16 @@ final class ConsoleService
|
||||
throw new InvalidArgumentException("Le nom et le constructeur sont obligatoires.");
|
||||
}
|
||||
|
||||
$annee = $this->normaliserAnnee($donnees["annee"] ?? null);
|
||||
$photo = null;
|
||||
|
||||
if ($this->fichierPresent($fichierPhoto))
|
||||
{
|
||||
$photo = ImageUpload::enregistrer(
|
||||
$fichierPhoto,
|
||||
Config::get("consolesPhotosPath")
|
||||
);
|
||||
}
|
||||
|
||||
$maintenant = Helpers::maintenant();
|
||||
|
||||
$console = [
|
||||
@@ -55,7 +64,8 @@ final class ConsoleService
|
||||
"utilisateurId" => $utilisateurId,
|
||||
"nom" => $nom,
|
||||
"constructeur" => $constructeur,
|
||||
"annee" => $annee,
|
||||
"annee" => $this->normaliserAnnee($donnees["annee"] ?? null),
|
||||
"photo" => $photo,
|
||||
"notes" => trim((string) ($donnees["notes"] ?? "")),
|
||||
"createdAt" => $maintenant,
|
||||
"updatedAt" => $maintenant
|
||||
@@ -64,7 +74,7 @@ final class ConsoleService
|
||||
return $this->store->ajouter($console);
|
||||
}
|
||||
|
||||
public function modifier(string $id, string $utilisateurId, array $donnees): array
|
||||
public function modifier(string $id, string $utilisateurId, array $donnees, ?array $fichierPhoto = null): array
|
||||
{
|
||||
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||
|
||||
@@ -81,13 +91,25 @@ final class ConsoleService
|
||||
throw new InvalidArgumentException("Le nom et le constructeur sont obligatoires.");
|
||||
}
|
||||
|
||||
$miseAJour = $this->store->mettreAJour($id, [
|
||||
$champs = [
|
||||
"nom" => $nom,
|
||||
"constructeur" => $constructeur,
|
||||
"annee" => $this->normaliserAnnee($donnees["annee"] ?? null),
|
||||
"notes" => trim((string) ($donnees["notes"] ?? "")),
|
||||
"updatedAt" => Helpers::maintenant()
|
||||
]);
|
||||
];
|
||||
|
||||
if ($this->fichierPresent($fichierPhoto))
|
||||
{
|
||||
$nouvellePhoto = ImageUpload::enregistrer(
|
||||
$fichierPhoto,
|
||||
Config::get("consolesPhotosPath")
|
||||
);
|
||||
ImageUpload::supprimer($console["photo"] ?? null, Config::get("consolesPhotosPath"));
|
||||
$champs["photo"] = $nouvellePhoto;
|
||||
}
|
||||
|
||||
$miseAJour = $this->store->mettreAJour($id, $champs);
|
||||
|
||||
if ($miseAJour === null)
|
||||
{
|
||||
@@ -97,6 +119,59 @@ final class ConsoleService
|
||||
return $miseAJour;
|
||||
}
|
||||
|
||||
public function mettreAJourPhoto(string $id, string $utilisateurId, array $fichierPhoto): array
|
||||
{
|
||||
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||
|
||||
if ($console === null)
|
||||
{
|
||||
throw new RuntimeException("Console introuvable.");
|
||||
}
|
||||
|
||||
$nouvellePhoto = ImageUpload::enregistrer(
|
||||
$fichierPhoto,
|
||||
Config::get("consolesPhotosPath")
|
||||
);
|
||||
|
||||
ImageUpload::supprimer($console["photo"] ?? null, Config::get("consolesPhotosPath"));
|
||||
|
||||
$miseAJour = $this->store->mettreAJour($id, [
|
||||
"photo" => $nouvellePhoto,
|
||||
"updatedAt" => Helpers::maintenant()
|
||||
]);
|
||||
|
||||
if ($miseAJour === null)
|
||||
{
|
||||
throw new RuntimeException("Échec de la mise à jour de la photo.");
|
||||
}
|
||||
|
||||
return $miseAJour;
|
||||
}
|
||||
|
||||
public function supprimerPhoto(string $id, string $utilisateurId): array
|
||||
{
|
||||
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||
|
||||
if ($console === null)
|
||||
{
|
||||
throw new RuntimeException("Console introuvable.");
|
||||
}
|
||||
|
||||
ImageUpload::supprimer($console["photo"] ?? null, Config::get("consolesPhotosPath"));
|
||||
|
||||
$miseAJour = $this->store->mettreAJour($id, [
|
||||
"photo" => null,
|
||||
"updatedAt" => Helpers::maintenant()
|
||||
]);
|
||||
|
||||
if ($miseAJour === null)
|
||||
{
|
||||
throw new RuntimeException("Échec de la suppression de la photo.");
|
||||
}
|
||||
|
||||
return $miseAJour;
|
||||
}
|
||||
|
||||
public function supprimer(string $id, string $utilisateurId): bool
|
||||
{
|
||||
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||
@@ -106,6 +181,8 @@ final class ConsoleService
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageUpload::supprimer($console["photo"] ?? null, Config::get("consolesPhotosPath"));
|
||||
|
||||
return $this->store->supprimer($id);
|
||||
}
|
||||
|
||||
@@ -114,6 +191,12 @@ final class ConsoleService
|
||||
return count($this->listerPourUtilisateur($utilisateurId));
|
||||
}
|
||||
|
||||
private function fichierPresent(?array $fichier): bool
|
||||
{
|
||||
return is_array($fichier)
|
||||
&& (($fichier["error"] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_NO_FILE);
|
||||
}
|
||||
|
||||
private function normaliserAnnee(mixed $annee): ?int
|
||||
{
|
||||
if ($annee === null || $annee === "")
|
||||
|
||||
@@ -82,6 +82,50 @@ final class EnrichissementService
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cherche une jaquette RAWG pour un titre et la télécharge localement.
|
||||
* Ne fait rien (retourne null) si l'API est indisponible ou aucun résultat.
|
||||
*/
|
||||
public function recupererJaquetteParTitre(string $titre): ?string
|
||||
{
|
||||
$titre = trim($titre);
|
||||
|
||||
if ($titre === "" || !$this->estDisponible())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$resultats = $this->rechercher($titre, 5);
|
||||
|
||||
foreach ($resultats as $resultat)
|
||||
{
|
||||
$url = $resultat["jaquetteUrl"] ?? null;
|
||||
|
||||
if ($url === null || $url === "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$fichier = $this->telechargerJaquette($url);
|
||||
|
||||
if ($fichier !== null && !str_starts_with($fichier, "http"))
|
||||
{
|
||||
return $fichier;
|
||||
}
|
||||
|
||||
if ($fichier !== null)
|
||||
{
|
||||
return $fichier;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Télécharge une image distante dans data/jaquettes/.
|
||||
* En cas d'échec réseau, conserve l'URL distante comme repli.
|
||||
*/
|
||||
public function telechargerJaquette(?string $urlImage): ?string
|
||||
{
|
||||
if ($urlImage === null || $urlImage === "")
|
||||
@@ -89,8 +133,15 @@ final class EnrichissementService
|
||||
return null;
|
||||
}
|
||||
|
||||
$dossier = Config::get("jaquettesPath");
|
||||
|
||||
if (!is_dir($dossier))
|
||||
{
|
||||
mkdir($dossier, 0775, true);
|
||||
}
|
||||
|
||||
$extension = pathinfo(parse_url($urlImage, PHP_URL_PATH) ?? "", PATHINFO_EXTENSION);
|
||||
$extension = $extension !== "" ? strtolower($extension) : "jpg";
|
||||
$extension = $extension !== "" ? strtolower(explode("?", $extension)[0]) : "jpg";
|
||||
|
||||
if (!in_array($extension, ["jpg", "jpeg", "png", "webp", "gif"], true))
|
||||
{
|
||||
@@ -98,18 +149,10 @@ final class EnrichissementService
|
||||
}
|
||||
|
||||
$nomFichier = Helpers::genererId() . "." . $extension;
|
||||
$cheminLocal = Config::get("jaquettesPath") . "/" . $nomFichier;
|
||||
$cheminLocal = $dossier . "/" . $nomFichier;
|
||||
$contenu = $this->telechargerContenu($urlImage);
|
||||
|
||||
$contexte = stream_context_create([
|
||||
"http" => [
|
||||
"timeout" => 10,
|
||||
"header" => "User-Agent: JeuxVideoTech/1.0\r\n"
|
||||
]
|
||||
]);
|
||||
|
||||
$contenu = @file_get_contents($urlImage, false, $contexte);
|
||||
|
||||
if ($contenu === false)
|
||||
if ($contenu === null || $contenu === "")
|
||||
{
|
||||
return $urlImage;
|
||||
}
|
||||
@@ -122,6 +165,51 @@ final class EnrichissementService
|
||||
return $nomFichier;
|
||||
}
|
||||
|
||||
private function telechargerContenu(string $url): ?string
|
||||
{
|
||||
if (function_exists("curl_init"))
|
||||
{
|
||||
$curl = curl_init($url);
|
||||
|
||||
if ($curl !== false)
|
||||
{
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_TIMEOUT => 15,
|
||||
CURLOPT_USERAGENT => "JeuxVideoTech/1.0",
|
||||
CURLOPT_SSL_VERIFYPEER => true
|
||||
]);
|
||||
|
||||
$contenu = curl_exec($curl);
|
||||
$codeHttp = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
|
||||
if ($contenu !== false && $codeHttp >= 200 && $codeHttp < 300)
|
||||
{
|
||||
return $contenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$contexte = stream_context_create([
|
||||
"http" => [
|
||||
"method" => "GET",
|
||||
"timeout" => 15,
|
||||
"follow_location" => 1,
|
||||
"header" => "User-Agent: JeuxVideoTech/1.0\r\n"
|
||||
],
|
||||
"ssl" => [
|
||||
"verify_peer" => true,
|
||||
"verify_peer_name" => true
|
||||
]
|
||||
]);
|
||||
|
||||
$contenu = @file_get_contents($url, false, $contexte);
|
||||
|
||||
return $contenu === false ? null : $contenu;
|
||||
}
|
||||
|
||||
private function mapperResultatListe(array $jeu): array
|
||||
{
|
||||
$genres = [];
|
||||
|
||||
@@ -15,7 +15,8 @@ final class JeuService
|
||||
string $utilisateurId,
|
||||
?string $recherche = null,
|
||||
?string $consoleId = null,
|
||||
?string $etat = null
|
||||
?string $etat = null,
|
||||
?string $format = null
|
||||
): array
|
||||
{
|
||||
$jeux = $this->store->filtrer(
|
||||
@@ -38,6 +39,19 @@ final class JeuService
|
||||
));
|
||||
}
|
||||
|
||||
if ($format !== null && $format !== "")
|
||||
{
|
||||
$jeux = array_values(array_filter(
|
||||
$jeux,
|
||||
static function (array $jeu) use ($format): bool
|
||||
{
|
||||
$formats = $jeu["formats"] ?? [];
|
||||
|
||||
return is_array($formats) && in_array($format, $formats, true);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
if ($recherche !== null && $recherche !== "")
|
||||
{
|
||||
$terme = mb_strtolower($recherche);
|
||||
@@ -50,7 +64,8 @@ final class JeuService
|
||||
$jeu["description"] ?? "",
|
||||
$jeu["editeur"] ?? "",
|
||||
$jeu["developpeur"] ?? "",
|
||||
implode(" ", $jeu["genres"] ?? [])
|
||||
implode(" ", $jeu["genres"] ?? []),
|
||||
implode(" ", $jeu["formats"] ?? [])
|
||||
];
|
||||
|
||||
return str_contains(mb_strtolower(implode(" ", $champs)), $terme);
|
||||
@@ -117,6 +132,7 @@ final class JeuService
|
||||
throw new RuntimeException("Jeu introuvable.");
|
||||
}
|
||||
|
||||
$ancienneJaquette = $existant["jaquette"] ?? null;
|
||||
$jeu = $this->preparerDonnees($utilisateurId, $donnees, $existant);
|
||||
$jeu["updatedAt"] = Helpers::maintenant();
|
||||
|
||||
@@ -127,6 +143,47 @@ final class JeuService
|
||||
throw new RuntimeException("Échec de la mise à jour.");
|
||||
}
|
||||
|
||||
$nouvelleJaquette = $miseAJour["jaquette"] ?? null;
|
||||
|
||||
if (
|
||||
$ancienneJaquette !== null
|
||||
&& $ancienneJaquette !== ""
|
||||
&& $ancienneJaquette !== $nouvelleJaquette
|
||||
)
|
||||
{
|
||||
$this->supprimerJaquetteLocale($ancienneJaquette);
|
||||
}
|
||||
|
||||
return $miseAJour;
|
||||
}
|
||||
|
||||
public function remplacerJaquette(string $id, string $utilisateurId, array $fichier): array
|
||||
{
|
||||
$jeu = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||
|
||||
if ($jeu === null)
|
||||
{
|
||||
throw new RuntimeException("Jeu introuvable.");
|
||||
}
|
||||
|
||||
$nouvelleJaquette = ImageUpload::enregistrer(
|
||||
$fichier,
|
||||
Config::get("jaquettesPath")
|
||||
);
|
||||
|
||||
$this->supprimerJaquetteLocale($jeu["jaquette"] ?? null);
|
||||
|
||||
$miseAJour = $this->store->mettreAJour($id, [
|
||||
"jaquette" => $nouvelleJaquette,
|
||||
"sourceEnrichissement" => "manuel",
|
||||
"updatedAt" => Helpers::maintenant()
|
||||
]);
|
||||
|
||||
if ($miseAJour === null)
|
||||
{
|
||||
throw new RuntimeException("Échec de la mise à jour de la jaquette.");
|
||||
}
|
||||
|
||||
return $miseAJour;
|
||||
}
|
||||
|
||||
@@ -199,6 +256,7 @@ final class JeuService
|
||||
"titre" => $titre,
|
||||
"consoleId" => $consoleId,
|
||||
"etat" => $etat,
|
||||
"formats" => Helpers::normaliserFormats($donnees["formats"] ?? []),
|
||||
"jaquette" => $jaquette,
|
||||
"description" => trim((string) ($donnees["description"] ?? "")),
|
||||
"dateSortie" => $this->normaliserDate($donnees["dateSortie"] ?? null),
|
||||
|
||||
+6
-1
@@ -7,6 +7,7 @@ require_once __DIR__ . "/JsonStore.php";
|
||||
require_once __DIR__ . "/Csrf.php";
|
||||
require_once __DIR__ . "/Flash.php";
|
||||
require_once __DIR__ . "/Helpers.php";
|
||||
require_once __DIR__ . "/ImageUpload.php";
|
||||
require_once __DIR__ . "/View.php";
|
||||
require_once __DIR__ . "/Auth.php";
|
||||
require_once __DIR__ . "/Router.php";
|
||||
@@ -22,7 +23,7 @@ require_once __DIR__ . "/Controllers/AdminController.php";
|
||||
|
||||
Config::charger();
|
||||
|
||||
foreach (["", "/jaquettes", "/cache"] as $sousDossier)
|
||||
foreach (["", "/jaquettes", "/consoles-photos", "/cache"] as $sousDossier)
|
||||
{
|
||||
$chemin = Config::get("dataPath") . $sousDossier;
|
||||
|
||||
@@ -63,6 +64,8 @@ $router->post("/consoles/creer", [$consoleController, "creer"]);
|
||||
$router->get("/consoles/{id}", [$consoleController, "detail"]);
|
||||
$router->get("/consoles/{id}/modifier", [$consoleController, "modifier"]);
|
||||
$router->post("/consoles/{id}/modifier", [$consoleController, "modifier"]);
|
||||
$router->post("/consoles/{id}/photo", [$consoleController, "envoyerPhoto"]);
|
||||
$router->post("/consoles/{id}/photo/supprimer", [$consoleController, "supprimerPhoto"]);
|
||||
$router->post("/consoles/{id}/supprimer", [$consoleController, "supprimer"]);
|
||||
|
||||
$router->get("/jeux", [$jeuController, "liste"]);
|
||||
@@ -73,6 +76,8 @@ $router->post("/jeux/api/appliquer", [$jeuController, "appliquerEnrichissement"]
|
||||
$router->get("/jeux/{id}", [$jeuController, "detail"]);
|
||||
$router->get("/jeux/{id}/modifier", [$jeuController, "modifier"]);
|
||||
$router->post("/jeux/{id}/modifier", [$jeuController, "modifier"]);
|
||||
$router->post("/jeux/{id}/jaquette", [$jeuController, "recupererJaquette"]);
|
||||
$router->post("/jeux/{id}/jaquette/upload", [$jeuController, "envoyerJaquette"]);
|
||||
$router->post("/jeux/{id}/supprimer", [$jeuController, "supprimer"]);
|
||||
|
||||
$router->get("/admin/utilisateurs", [$adminController, "index"]);
|
||||
|
||||
+10
-3
@@ -60,9 +60,16 @@
|
||||
<div class="game-card-body">
|
||||
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
||||
<p><?php print Helpers::echapper($consoleNom); ?></p>
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<div class="game-card-badges">
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<?php foreach (Helpers::normaliserFormats($jeu["formats"] ?? []) as $format): ?>
|
||||
<span class="badge-format format-<?php print Helpers::echapper($format); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleFormat($format)); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -1,18 +1,67 @@
|
||||
<section class="page-header">
|
||||
<div>
|
||||
<section class="detail-hero console-detail-hero">
|
||||
<div class="detail-cover console-cover">
|
||||
<img
|
||||
src="<?php print Helpers::echapper(Helpers::urlPhotoConsole($console["photo"] ?? null)); ?>"
|
||||
alt="Photo de <?php print Helpers::echapper($console["nom"]); ?>"
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<p class="eyebrow"><?php print Helpers::echapper($console["constructeur"]); ?><?php if (!empty($console["annee"])): ?> · <?php print (int) $console["annee"]; ?><?php endif; ?></p>
|
||||
<h1 class="page-title"><?php print Helpers::echapper($console["nom"]); ?></h1>
|
||||
<?php if (!empty($console["notes"])): ?>
|
||||
<p class="lead-text"><?php print nl2br(Helpers::echapper($console["notes"])); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="page-actions">
|
||||
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>/modifier" class="btn btn-outline-neon">
|
||||
<i class="mdi mdi-pencil"></i> Modifier
|
||||
</a>
|
||||
<a href="/jeux/creer?consoleId=<?php print Helpers::echapper($console["id"]); ?>" class="btn btn-neon">
|
||||
<i class="mdi mdi-plus"></i> Ajouter un jeu
|
||||
</a>
|
||||
|
||||
<div class="page-actions mt-3">
|
||||
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>/modifier" class="btn btn-outline-neon">
|
||||
<i class="mdi mdi-pencil"></i> Modifier
|
||||
</a>
|
||||
<a href="/jeux/creer?consoleId=<?php print Helpers::echapper($console["id"]); ?>" class="btn btn-neon">
|
||||
<i class="mdi mdi-plus"></i> Ajouter un jeu
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form
|
||||
method="post"
|
||||
action="/consoles/<?php print Helpers::echapper($console["id"]); ?>/photo"
|
||||
enctype="multipart/form-data"
|
||||
class="photo-upload-bar mt-4"
|
||||
>
|
||||
<?php print Csrf::champCache(); ?>
|
||||
<label class="form-label" for="photoConsole">
|
||||
<i class="mdi mdi-camera-outline"></i>
|
||||
<?php print Helpers::photoConsoleAbsente($console["photo"] ?? null) ? "Envoyer une photo" : "Remplacer la photo"; ?>
|
||||
</label>
|
||||
<div class="photo-upload-row">
|
||||
<input
|
||||
type="file"
|
||||
class="form-control"
|
||||
id="photoConsole"
|
||||
name="photo"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/*"
|
||||
capture="environment"
|
||||
required
|
||||
>
|
||||
<button type="submit" class="btn btn-neon">
|
||||
<i class="mdi mdi-upload"></i> Envoyer
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-text">Prenez une photo ou choisissez un fichier (JPG, PNG, WebP, GIF — 5 Mo max).</div>
|
||||
</form>
|
||||
|
||||
<?php if (!Helpers::photoConsoleAbsente($console["photo"] ?? null)): ?>
|
||||
<form
|
||||
method="post"
|
||||
action="/consoles/<?php print Helpers::echapper($console["id"]); ?>/photo/supprimer"
|
||||
class="mt-2"
|
||||
onsubmit="return confirm('Supprimer la photo de cette console ?');"
|
||||
>
|
||||
<?php print Csrf::champCache(); ?>
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="mdi mdi-image-remove-outline"></i> Supprimer la photo
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -38,9 +87,16 @@
|
||||
>
|
||||
<div class="game-card-body">
|
||||
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<div class="game-card-badges">
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<?php foreach (Helpers::normaliserFormats($jeu["formats"] ?? []) as $format): ?>
|
||||
<span class="badge-format format-<?php print Helpers::echapper($format); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleFormat($format)); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -4,7 +4,8 @@ $valeurs = $console ?? [
|
||||
"nom" => Helpers::champ("nom"),
|
||||
"constructeur" => Helpers::champ("constructeur"),
|
||||
"annee" => Helpers::champ("annee"),
|
||||
"notes" => Helpers::champ("notes")
|
||||
"notes" => Helpers::champ("notes"),
|
||||
"photo" => null
|
||||
];
|
||||
?>
|
||||
|
||||
@@ -18,25 +19,47 @@ $valeurs = $console ?? [
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form method="post" action="<?php print Helpers::echapper($action); ?>" class="form-panel">
|
||||
<form method="post" action="<?php print Helpers::echapper($action); ?>" class="form-panel" enctype="multipart/form-data">
|
||||
<?php print Csrf::champCache(); ?>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="nom">Nom</label>
|
||||
<input type="text" class="form-control" id="nom" name="nom" required value="<?php print Helpers::echapper($valeurs["nom"] ?? ""); ?>">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="constructeur">Constructeur</label>
|
||||
<input type="text" class="form-control" id="constructeur" name="constructeur" required value="<?php print Helpers::echapper($valeurs["constructeur"] ?? ""); ?>">
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label" for="annee">Année</label>
|
||||
<input type="number" class="form-control" id="annee" name="annee" min="1970" max="<?php print (int) date("Y") + 2; ?>" value="<?php print Helpers::echapper((string) ($valeurs["annee"] ?? "")); ?>">
|
||||
<div class="console-photo-preview">
|
||||
<img
|
||||
src="<?php print Helpers::echapper(Helpers::urlPhotoConsole($valeurs["photo"] ?? null)); ?>"
|
||||
alt="Photo de la console"
|
||||
id="apercuPhotoConsole"
|
||||
>
|
||||
</div>
|
||||
<label class="form-label mt-3" for="photo">Photo de la console</label>
|
||||
<input
|
||||
type="file"
|
||||
class="form-control"
|
||||
id="photo"
|
||||
name="photo"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
>
|
||||
<div class="form-text">JPG, PNG, WebP ou GIF — 5 Mo max.</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="notes">Notes personnelles</label>
|
||||
<textarea class="form-control" id="notes" name="notes" rows="4"><?php print Helpers::echapper($valeurs["notes"] ?? ""); ?></textarea>
|
||||
<div class="col-md-8">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="nom">Nom</label>
|
||||
<input type="text" class="form-control" id="nom" name="nom" required value="<?php print Helpers::echapper($valeurs["nom"] ?? ""); ?>">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="constructeur">Constructeur</label>
|
||||
<input type="text" class="form-control" id="constructeur" name="constructeur" required value="<?php print Helpers::echapper($valeurs["constructeur"] ?? ""); ?>">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label" for="annee">Année</label>
|
||||
<input type="number" class="form-control" id="annee" name="annee" min="1970" max="<?php print (int) date("Y") + 2; ?>" value="<?php print Helpers::echapper((string) ($valeurs["annee"] ?? "")); ?>">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="notes">Notes personnelles</label>
|
||||
<textarea class="form-control" id="notes" name="notes" rows="4"><?php print Helpers::echapper($valeurs["notes"] ?? ""); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -22,8 +22,12 @@
|
||||
<?php foreach ($consoles as $console): ?>
|
||||
<article class="console-card">
|
||||
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>" class="console-card-link">
|
||||
<div class="console-icon">
|
||||
<i class="mdi mdi-gamepad-variant"></i>
|
||||
<div class="console-photo">
|
||||
<img
|
||||
src="<?php print Helpers::echapper(Helpers::urlPhotoConsole($console["photo"] ?? null)); ?>"
|
||||
alt="Photo de <?php print Helpers::echapper($console["nom"]); ?>"
|
||||
loading="lazy"
|
||||
>
|
||||
</div>
|
||||
<h2><?php print Helpers::echapper($console["nom"]); ?></h2>
|
||||
<p><?php print Helpers::echapper($console["constructeur"]); ?><?php if (!empty($console["annee"])): ?> · <?php print (int) $console["annee"]; ?><?php endif; ?></p>
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<?php foreach (Helpers::normaliserFormats($jeu["formats"] ?? []) as $format): ?>
|
||||
<span class="badge-format format-<?php print Helpers::echapper($format); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleFormat($format)); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!empty($jeu["dateSortie"])): ?>
|
||||
<span><i class="mdi mdi-calendar"></i> <?php print Helpers::echapper($jeu["dateSortie"]); ?></span>
|
||||
<?php endif; ?>
|
||||
@@ -23,6 +28,14 @@
|
||||
<a href="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/modifier" class="btn btn-neon">
|
||||
<i class="mdi mdi-pencil"></i> Modifier
|
||||
</a>
|
||||
<?php if (!empty($jaquetteAbsente) && !empty($apiDisponible)): ?>
|
||||
<form method="post" action="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/jaquette">
|
||||
<?php print Csrf::champCache(); ?>
|
||||
<button type="submit" class="btn btn-outline-neon">
|
||||
<i class="mdi mdi-image-search-outline"></i> Récupérer la jaquette
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<form method="post" action="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/supprimer" onsubmit="return confirm('Supprimer ce jeu ?');">
|
||||
<?php print Csrf::champCache(); ?>
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
@@ -30,6 +43,33 @@
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form
|
||||
method="post"
|
||||
action="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/jaquette/upload"
|
||||
enctype="multipart/form-data"
|
||||
class="photo-upload-bar mt-4"
|
||||
>
|
||||
<?php print Csrf::champCache(); ?>
|
||||
<label class="form-label" for="jaquetteFichier">
|
||||
<i class="mdi mdi-image-edit-outline"></i>
|
||||
<?php print !empty($jaquetteAbsente) ? "Envoyer une jaquette" : "Remplacer la jaquette"; ?>
|
||||
</label>
|
||||
<div class="photo-upload-row">
|
||||
<input
|
||||
type="file"
|
||||
class="form-control"
|
||||
id="jaquetteFichier"
|
||||
name="jaquetteFichier"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/*"
|
||||
required
|
||||
>
|
||||
<button type="submit" class="btn btn-neon">
|
||||
<i class="mdi mdi-upload"></i> Envoyer
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-text">Choisissez une image (JPG, PNG, WebP, GIF — 5 Mo max) pour corriger une jaquette incorrecte.</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -64,6 +104,21 @@
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Supports</dt>
|
||||
<dd>
|
||||
<?php $formats = Helpers::normaliserFormats($jeu["formats"] ?? []); ?>
|
||||
<?php if ($formats === []): ?>
|
||||
—
|
||||
<?php else: ?>
|
||||
<?php foreach ($formats as $format): ?>
|
||||
<span class="badge-format format-<?php print Helpers::echapper($format); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleFormat($format)); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Notes</dt>
|
||||
<dd><?php print nl2br(Helpers::echapper($jeu["notes"] ?: "—")); ?></dd>
|
||||
|
||||
@@ -3,6 +3,7 @@ $estEdition = isset($jeu["id"]);
|
||||
$genresTexte = is_array($jeu["genres"] ?? null)
|
||||
? implode(", ", $jeu["genres"])
|
||||
: (string) ($jeu["genres"] ?? "");
|
||||
$formatsSelectionnes = Helpers::normaliserFormats($jeu["formats"] ?? []);
|
||||
$retourEnrichissement = $action;
|
||||
?>
|
||||
|
||||
@@ -39,7 +40,7 @@ $retourEnrichissement = $action;
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="<?php print Helpers::echapper($action); ?>" class="form-panel" id="formJeu">
|
||||
<form method="post" action="<?php print Helpers::echapper($action); ?>" class="form-panel" id="formJeu" enctype="multipart/form-data">
|
||||
<?php print Csrf::champCache(); ?>
|
||||
<input type="hidden" name="jaquette" id="jaquette" value="<?php print Helpers::echapper($jeu["jaquette"] ?? ""); ?>">
|
||||
<input type="hidden" name="sourceEnrichissement" id="sourceEnrichissement" value="<?php print Helpers::echapper($jeu["sourceEnrichissement"] ?? "manuel"); ?>">
|
||||
@@ -53,6 +54,15 @@ $retourEnrichissement = $action;
|
||||
alt="Aperçu de la jaquette"
|
||||
>
|
||||
</div>
|
||||
<label class="form-label mt-3" for="jaquetteFichier">Remplacer par une image</label>
|
||||
<input
|
||||
type="file"
|
||||
class="form-control"
|
||||
id="jaquetteFichier"
|
||||
name="jaquetteFichier"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/*"
|
||||
>
|
||||
<div class="form-text">Optionnel — JPG, PNG, WebP ou GIF (5 Mo max).</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="row g-3">
|
||||
@@ -70,6 +80,23 @@ $retourEnrichissement = $action;
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<span class="form-label d-block">Support(s)</span>
|
||||
<div class="format-checks">
|
||||
<?php foreach (Helpers::formatsJeu() as $valeur => $libelle): ?>
|
||||
<label class="format-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="formats[]"
|
||||
value="<?php print Helpers::echapper($valeur); ?>"
|
||||
<?php print in_array($valeur, $formatsSelectionnes, true) ? "checked" : ""; ?>
|
||||
>
|
||||
<span><?php print Helpers::echapper($libelle); ?></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="form-text">Cochez toutes les versions que vous possédez.</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="consoleId">Console</label>
|
||||
<select class="form-select" id="consoleId" name="consoleId" required>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<form method="get" action="/jeux" class="filter-bar">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label" for="q">Recherche</label>
|
||||
<input type="search" class="form-control" id="q" name="q" placeholder="Titre, genre, éditeur…" value="<?php print Helpers::echapper($filtres["q"]); ?>">
|
||||
</div>
|
||||
@@ -28,7 +28,7 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-2">
|
||||
<label class="form-label" for="etat">État</label>
|
||||
<select class="form-select" id="etat" name="etat">
|
||||
<option value="">Tous</option>
|
||||
@@ -39,6 +39,17 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label" for="format">Support</label>
|
||||
<select class="form-select" id="format" name="format">
|
||||
<option value="">Tous</option>
|
||||
<?php foreach (Helpers::formatsJeu() as $valeur => $libelle): ?>
|
||||
<option value="<?php print Helpers::echapper($valeur); ?>" <?php print ($filtres["format"] ?? "") === $valeur ? "selected" : ""; ?>>
|
||||
<?php print Helpers::echapper($libelle); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="submit" class="btn btn-outline-neon w-100">Filtrer</button>
|
||||
</div>
|
||||
@@ -63,9 +74,16 @@
|
||||
<div class="game-card-body">
|
||||
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
||||
<p><?php print Helpers::echapper($console["nom"] ?? "Console inconnue"); ?></p>
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<div class="game-card-badges">
|
||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||
</span>
|
||||
<?php foreach (Helpers::normaliserFormats($jeu["formats"] ?? []) as $format): ?>
|
||||
<span class="badge-format format-<?php print Helpers::echapper($format); ?>">
|
||||
<?php print Helpers::echapper(Helpers::libelleFormat($format)); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
|
||||