Compare commits
2
Commits
b785db1b84
...
3235bc50c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3235bc50c7 | ||
|
|
df11d023f0 |
No files matched your search
@@ -4,6 +4,8 @@ data/utilisateurs.json
|
|||||||
data/consoles.json
|
data/consoles.json
|
||||||
data/jeux.json
|
data/jeux.json
|
||||||
data/jaquettes/*
|
data/jaquettes/*
|
||||||
|
data/consoles-photos/*
|
||||||
data/cache/*
|
data/cache/*
|
||||||
!data/jaquettes/.gitkeep
|
!data/jaquettes/.gitkeep
|
||||||
|
!data/consoles-photos/.gitkeep
|
||||||
!data/cache/.gitkeep
|
!data/cache/.gitkeep
|
||||||
+5
-3
@@ -1,7 +1,10 @@
|
|||||||
FROM php:8.3-apache
|
FROM php:8.3-apache
|
||||||
|
|
||||||
RUN a2enmod rewrite headers \
|
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/apache.conf /etc/apache2/sites-available/000-default.conf
|
||||||
COPY docker/php.ini /usr/local/etc/php/conf.d/jeuxvideotech.ini
|
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 public /var/www/html/public
|
||||||
COPY src /var/www/html/src
|
COPY src /var/www/html/src
|
||||||
COPY templates /var/www/html/templates
|
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
|
&& chown -R www-data:www-data /var/www/html/data
|
||||||
|
|
||||||
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
||||||
|
|||||||
Whitespace-only changes.
+3
-2
@@ -1,7 +1,8 @@
|
|||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
# Servir les jaquettes stockées hors de public/
|
# Médias stockés hors de public/
|
||||||
RewriteRule ^jaquettes/(.*)$ /servir-jaquette.php?fichier=$1 [L,QSA]
|
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
|
# Fichiers / dossiers existants : ne pas réécrire
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
|||||||
+150
-3
@@ -378,6 +378,79 @@ a:hover
|
|||||||
border: 1px solid transparent;
|
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
|
.etat-possede
|
||||||
{
|
{
|
||||||
color: #041018;
|
color: #041018;
|
||||||
@@ -441,6 +514,77 @@ a:hover
|
|||||||
margin-bottom: 0.7rem;
|
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
|
.console-card h2
|
||||||
{
|
{
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
@@ -760,15 +904,18 @@ a:hover
|
|||||||
{
|
{
|
||||||
.auth-shell,
|
.auth-shell,
|
||||||
.detail-hero,
|
.detail-hero,
|
||||||
.detail-grid
|
.detail-grid,
|
||||||
|
.console-detail-hero
|
||||||
{
|
{
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-cover,
|
.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 |
@@ -6,15 +6,21 @@ require_once dirname(__DIR__) . "/src/Config.php";
|
|||||||
|
|
||||||
Config::charger();
|
Config::charger();
|
||||||
|
|
||||||
|
$type = $_GET["type"] ?? "jaquettes";
|
||||||
$fichier = basename($_GET["fichier"] ?? "");
|
$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);
|
http_response_code(404);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$chemin = Config::get("jaquettesPath") . "/" . $fichier;
|
$chemin = $dossiers[$type] . "/" . $fichier;
|
||||||
|
|
||||||
if (!is_file($chemin))
|
if (!is_file($chemin))
|
||||||
{
|
{
|
||||||
@@ -18,6 +18,7 @@ final class Config
|
|||||||
"sessionLifetime" => (int) self::env("SESSION_LIFETIME", "86400"),
|
"sessionLifetime" => (int) self::env("SESSION_LIFETIME", "86400"),
|
||||||
"dataPath" => dirname(__DIR__) . "/data",
|
"dataPath" => dirname(__DIR__) . "/data",
|
||||||
"jaquettesPath" => dirname(__DIR__) . "/data/jaquettes",
|
"jaquettesPath" => dirname(__DIR__) . "/data/jaquettes",
|
||||||
|
"consolesPhotosPath" => dirname(__DIR__) . "/data/consoles-photos",
|
||||||
"cachePath" => dirname(__DIR__) . "/data/cache"
|
"cachePath" => dirname(__DIR__) . "/data/cache"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,11 +62,15 @@ final class ConsoleController
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$console = $this->consoleService->creer($utilisateur["id"], $_POST);
|
$console = $this->consoleService->creer(
|
||||||
|
$utilisateur["id"],
|
||||||
|
$_POST,
|
||||||
|
$_FILES["photo"] ?? null
|
||||||
|
);
|
||||||
Flash::definir("success", "Console ajoutée.");
|
Flash::definir("success", "Console ajoutée.");
|
||||||
Helpers::rediriger("/consoles/" . $console["id"]);
|
Helpers::rediriger("/consoles/" . $console["id"]);
|
||||||
}
|
}
|
||||||
catch (InvalidArgumentException $exception)
|
catch (InvalidArgumentException | RuntimeException $exception)
|
||||||
{
|
{
|
||||||
Flash::definir("danger", $exception->getMessage());
|
Flash::definir("danger", $exception->getMessage());
|
||||||
}
|
}
|
||||||
@@ -97,11 +101,16 @@ final class ConsoleController
|
|||||||
|
|
||||||
try
|
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.");
|
Flash::definir("success", "Console mise à jour.");
|
||||||
Helpers::rediriger("/consoles/" . $console["id"]);
|
Helpers::rediriger("/consoles/" . $console["id"]);
|
||||||
}
|
}
|
||||||
catch (InvalidArgumentException $exception)
|
catch (InvalidArgumentException | RuntimeException $exception)
|
||||||
{
|
{
|
||||||
Flash::definir("danger", $exception->getMessage());
|
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
|
public function supprimer(string $id): void
|
||||||
{
|
{
|
||||||
$utilisateur = $this->auth->exigerConnexion();
|
$utilisateur = $this->auth->exigerConnexion();
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ final class JeuController
|
|||||||
$recherche = Helpers::champ("q");
|
$recherche = Helpers::champ("q");
|
||||||
$consoleId = Helpers::champ("console");
|
$consoleId = Helpers::champ("console");
|
||||||
$etat = Helpers::champ("etat");
|
$etat = Helpers::champ("etat");
|
||||||
|
$format = Helpers::champ("format");
|
||||||
|
|
||||||
$jeux = $this->jeuService->listerPourUtilisateur(
|
$jeux = $this->jeuService->listerPourUtilisateur(
|
||||||
$utilisateur["id"],
|
$utilisateur["id"],
|
||||||
$recherche !== "" ? $recherche : null,
|
$recherche !== "" ? $recherche : null,
|
||||||
$consoleId !== "" ? $consoleId : null,
|
$consoleId !== "" ? $consoleId : null,
|
||||||
$etat !== "" ? $etat : null
|
$etat !== "" ? $etat : null,
|
||||||
|
$format !== "" ? $format : null
|
||||||
);
|
);
|
||||||
|
|
||||||
$consoles = $this->consoleService->listerPourUtilisateur($utilisateur["id"]);
|
$consoles = $this->consoleService->listerPourUtilisateur($utilisateur["id"]);
|
||||||
@@ -44,7 +46,8 @@ final class JeuController
|
|||||||
"filtres" => [
|
"filtres" => [
|
||||||
"q" => $recherche,
|
"q" => $recherche,
|
||||||
"console" => $consoleId,
|
"console" => $consoleId,
|
||||||
"etat" => $etat
|
"etat" => $etat,
|
||||||
|
"format" => $format
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -69,7 +72,9 @@ final class JeuController
|
|||||||
"titrePage" => $jeu["titre"],
|
"titrePage" => $jeu["titre"],
|
||||||
"utilisateur" => $utilisateur,
|
"utilisateur" => $utilisateur,
|
||||||
"jeu" => $jeu,
|
"jeu" => $jeu,
|
||||||
"console" => $console
|
"console" => $console,
|
||||||
|
"jaquetteAbsente" => Helpers::jaquetteAbsente($jeu["jaquette"] ?? null),
|
||||||
|
"apiDisponible" => $this->enrichissementService->estDisponible()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +98,7 @@ final class JeuController
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$donnees = $this->collecterDonneesFormulaire();
|
$donnees = $this->collecterDonneesFormulaire();
|
||||||
|
$donnees = $this->completerJaquetteSiAbsente($donnees);
|
||||||
$jeu = $this->jeuService->creer($utilisateur["id"], $donnees);
|
$jeu = $this->jeuService->creer($utilisateur["id"], $donnees);
|
||||||
Flash::definir("success", "Jeu ajouté à votre bibliothèque.");
|
Flash::definir("success", "Jeu ajouté à votre bibliothèque.");
|
||||||
Helpers::rediriger("/jeux/" . $jeu["id"]);
|
Helpers::rediriger("/jeux/" . $jeu["id"]);
|
||||||
@@ -134,6 +140,7 @@ final class JeuController
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$donnees = $this->collecterDonneesFormulaire();
|
$donnees = $this->collecterDonneesFormulaire();
|
||||||
|
$donnees = $this->completerJaquetteSiAbsente($donnees);
|
||||||
$jeu = $this->jeuService->modifier($id, $utilisateur["id"], $donnees);
|
$jeu = $this->jeuService->modifier($id, $utilisateur["id"], $donnees);
|
||||||
Flash::definir("success", "Jeu mis à jour.");
|
Flash::definir("success", "Jeu mis à jour.");
|
||||||
Helpers::rediriger("/jeux/" . $jeu["id"]);
|
Helpers::rediriger("/jeux/" . $jeu["id"]);
|
||||||
@@ -229,12 +236,84 @@ final class JeuController
|
|||||||
Helpers::rediriger($retour . $separateur . $query);
|
Helpers::rediriger($retour . $separateur . $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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
private function collecterDonneesFormulaire(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"titre" => Helpers::champ("titre"),
|
"titre" => Helpers::champ("titre"),
|
||||||
"consoleId" => Helpers::champ("consoleId"),
|
"consoleId" => Helpers::champ("consoleId"),
|
||||||
"etat" => Helpers::champ("etat", "possede"),
|
"etat" => Helpers::champ("etat", "possede"),
|
||||||
|
"formats" => $_POST["formats"] ?? [],
|
||||||
"jaquette" => Helpers::champ("jaquette"),
|
"jaquette" => Helpers::champ("jaquette"),
|
||||||
"description" => Helpers::champ("description"),
|
"description" => Helpers::champ("description"),
|
||||||
"dateSortie" => Helpers::champ("dateSortie"),
|
"dateSortie" => Helpers::champ("dateSortie"),
|
||||||
@@ -254,6 +333,7 @@ final class JeuController
|
|||||||
"titre" => Helpers::champ("titre"),
|
"titre" => Helpers::champ("titre"),
|
||||||
"consoleId" => Helpers::champ("consoleId"),
|
"consoleId" => Helpers::champ("consoleId"),
|
||||||
"etat" => Helpers::champ("etat", "possede"),
|
"etat" => Helpers::champ("etat", "possede"),
|
||||||
|
"formats" => [],
|
||||||
"jaquette" => Helpers::champ("jaquette"),
|
"jaquette" => Helpers::champ("jaquette"),
|
||||||
"description" => Helpers::champ("description"),
|
"description" => Helpers::champ("description"),
|
||||||
"dateSortie" => Helpers::champ("dateSortie"),
|
"dateSortie" => Helpers::champ("dateSortie"),
|
||||||
|
|||||||
+93
-2
@@ -52,19 +52,110 @@ final class Helpers
|
|||||||
return self::etatsJeu()[$etat] ?? $etat;
|
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
|
public static function urlJaquette(?string $chemin): string
|
||||||
{
|
{
|
||||||
if ($chemin === null || $chemin === "")
|
if (self::jaquetteAbsente($chemin))
|
||||||
{
|
{
|
||||||
return "/assets/img/jaquette-manquante.svg";
|
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://"))
|
if (str_starts_with($chemin, "http://") || str_starts_with($chemin, "https://"))
|
||||||
{
|
{
|
||||||
return $chemin;
|
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
|
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;
|
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"] ?? ""));
|
$nom = trim((string) ($donnees["nom"] ?? ""));
|
||||||
$constructeur = trim((string) ($donnees["constructeur"] ?? ""));
|
$constructeur = trim((string) ($donnees["constructeur"] ?? ""));
|
||||||
@@ -47,7 +47,16 @@ final class ConsoleService
|
|||||||
throw new InvalidArgumentException("Le nom et le constructeur sont obligatoires.");
|
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();
|
$maintenant = Helpers::maintenant();
|
||||||
|
|
||||||
$console = [
|
$console = [
|
||||||
@@ -55,7 +64,8 @@ final class ConsoleService
|
|||||||
"utilisateurId" => $utilisateurId,
|
"utilisateurId" => $utilisateurId,
|
||||||
"nom" => $nom,
|
"nom" => $nom,
|
||||||
"constructeur" => $constructeur,
|
"constructeur" => $constructeur,
|
||||||
"annee" => $annee,
|
"annee" => $this->normaliserAnnee($donnees["annee"] ?? null),
|
||||||
|
"photo" => $photo,
|
||||||
"notes" => trim((string) ($donnees["notes"] ?? "")),
|
"notes" => trim((string) ($donnees["notes"] ?? "")),
|
||||||
"createdAt" => $maintenant,
|
"createdAt" => $maintenant,
|
||||||
"updatedAt" => $maintenant
|
"updatedAt" => $maintenant
|
||||||
@@ -64,7 +74,7 @@ final class ConsoleService
|
|||||||
return $this->store->ajouter($console);
|
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);
|
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||||
|
|
||||||
@@ -81,13 +91,25 @@ final class ConsoleService
|
|||||||
throw new InvalidArgumentException("Le nom et le constructeur sont obligatoires.");
|
throw new InvalidArgumentException("Le nom et le constructeur sont obligatoires.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$miseAJour = $this->store->mettreAJour($id, [
|
$champs = [
|
||||||
"nom" => $nom,
|
"nom" => $nom,
|
||||||
"constructeur" => $constructeur,
|
"constructeur" => $constructeur,
|
||||||
"annee" => $this->normaliserAnnee($donnees["annee"] ?? null),
|
"annee" => $this->normaliserAnnee($donnees["annee"] ?? null),
|
||||||
"notes" => trim((string) ($donnees["notes"] ?? "")),
|
"notes" => trim((string) ($donnees["notes"] ?? "")),
|
||||||
"updatedAt" => Helpers::maintenant()
|
"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)
|
if ($miseAJour === null)
|
||||||
{
|
{
|
||||||
@@ -97,6 +119,59 @@ final class ConsoleService
|
|||||||
return $miseAJour;
|
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
|
public function supprimer(string $id, string $utilisateurId): bool
|
||||||
{
|
{
|
||||||
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
$console = $this->trouverPourUtilisateur($id, $utilisateurId);
|
||||||
@@ -106,6 +181,8 @@ final class ConsoleService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageUpload::supprimer($console["photo"] ?? null, Config::get("consolesPhotosPath"));
|
||||||
|
|
||||||
return $this->store->supprimer($id);
|
return $this->store->supprimer($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +191,12 @@ final class ConsoleService
|
|||||||
return count($this->listerPourUtilisateur($utilisateurId));
|
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
|
private function normaliserAnnee(mixed $annee): ?int
|
||||||
{
|
{
|
||||||
if ($annee === null || $annee === "")
|
if ($annee === null || $annee === "")
|
||||||
|
|||||||
@@ -82,6 +82,50 @@ final class EnrichissementService
|
|||||||
return $detail;
|
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
|
public function telechargerJaquette(?string $urlImage): ?string
|
||||||
{
|
{
|
||||||
if ($urlImage === null || $urlImage === "")
|
if ($urlImage === null || $urlImage === "")
|
||||||
@@ -89,8 +133,15 @@ final class EnrichissementService
|
|||||||
return null;
|
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 = 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))
|
if (!in_array($extension, ["jpg", "jpeg", "png", "webp", "gif"], true))
|
||||||
{
|
{
|
||||||
@@ -98,18 +149,10 @@ final class EnrichissementService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$nomFichier = Helpers::genererId() . "." . $extension;
|
$nomFichier = Helpers::genererId() . "." . $extension;
|
||||||
$cheminLocal = Config::get("jaquettesPath") . "/" . $nomFichier;
|
$cheminLocal = $dossier . "/" . $nomFichier;
|
||||||
|
$contenu = $this->telechargerContenu($urlImage);
|
||||||
|
|
||||||
$contexte = stream_context_create([
|
if ($contenu === null || $contenu === "")
|
||||||
"http" => [
|
|
||||||
"timeout" => 10,
|
|
||||||
"header" => "User-Agent: JeuxVideoTech/1.0\r\n"
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
$contenu = @file_get_contents($urlImage, false, $contexte);
|
|
||||||
|
|
||||||
if ($contenu === false)
|
|
||||||
{
|
{
|
||||||
return $urlImage;
|
return $urlImage;
|
||||||
}
|
}
|
||||||
@@ -122,6 +165,51 @@ final class EnrichissementService
|
|||||||
return $nomFichier;
|
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
|
private function mapperResultatListe(array $jeu): array
|
||||||
{
|
{
|
||||||
$genres = [];
|
$genres = [];
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ final class JeuService
|
|||||||
string $utilisateurId,
|
string $utilisateurId,
|
||||||
?string $recherche = null,
|
?string $recherche = null,
|
||||||
?string $consoleId = null,
|
?string $consoleId = null,
|
||||||
?string $etat = null
|
?string $etat = null,
|
||||||
|
?string $format = null
|
||||||
): array
|
): array
|
||||||
{
|
{
|
||||||
$jeux = $this->store->filtrer(
|
$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 !== "")
|
if ($recherche !== null && $recherche !== "")
|
||||||
{
|
{
|
||||||
$terme = mb_strtolower($recherche);
|
$terme = mb_strtolower($recherche);
|
||||||
@@ -50,7 +64,8 @@ final class JeuService
|
|||||||
$jeu["description"] ?? "",
|
$jeu["description"] ?? "",
|
||||||
$jeu["editeur"] ?? "",
|
$jeu["editeur"] ?? "",
|
||||||
$jeu["developpeur"] ?? "",
|
$jeu["developpeur"] ?? "",
|
||||||
implode(" ", $jeu["genres"] ?? [])
|
implode(" ", $jeu["genres"] ?? []),
|
||||||
|
implode(" ", $jeu["formats"] ?? [])
|
||||||
];
|
];
|
||||||
|
|
||||||
return str_contains(mb_strtolower(implode(" ", $champs)), $terme);
|
return str_contains(mb_strtolower(implode(" ", $champs)), $terme);
|
||||||
@@ -199,6 +214,7 @@ final class JeuService
|
|||||||
"titre" => $titre,
|
"titre" => $titre,
|
||||||
"consoleId" => $consoleId,
|
"consoleId" => $consoleId,
|
||||||
"etat" => $etat,
|
"etat" => $etat,
|
||||||
|
"formats" => Helpers::normaliserFormats($donnees["formats"] ?? []),
|
||||||
"jaquette" => $jaquette,
|
"jaquette" => $jaquette,
|
||||||
"description" => trim((string) ($donnees["description"] ?? "")),
|
"description" => trim((string) ($donnees["description"] ?? "")),
|
||||||
"dateSortie" => $this->normaliserDate($donnees["dateSortie"] ?? null),
|
"dateSortie" => $this->normaliserDate($donnees["dateSortie"] ?? null),
|
||||||
|
|||||||
+5
-1
@@ -7,6 +7,7 @@ require_once __DIR__ . "/JsonStore.php";
|
|||||||
require_once __DIR__ . "/Csrf.php";
|
require_once __DIR__ . "/Csrf.php";
|
||||||
require_once __DIR__ . "/Flash.php";
|
require_once __DIR__ . "/Flash.php";
|
||||||
require_once __DIR__ . "/Helpers.php";
|
require_once __DIR__ . "/Helpers.php";
|
||||||
|
require_once __DIR__ . "/ImageUpload.php";
|
||||||
require_once __DIR__ . "/View.php";
|
require_once __DIR__ . "/View.php";
|
||||||
require_once __DIR__ . "/Auth.php";
|
require_once __DIR__ . "/Auth.php";
|
||||||
require_once __DIR__ . "/Router.php";
|
require_once __DIR__ . "/Router.php";
|
||||||
@@ -22,7 +23,7 @@ require_once __DIR__ . "/Controllers/AdminController.php";
|
|||||||
|
|
||||||
Config::charger();
|
Config::charger();
|
||||||
|
|
||||||
foreach (["", "/jaquettes", "/cache"] as $sousDossier)
|
foreach (["", "/jaquettes", "/consoles-photos", "/cache"] as $sousDossier)
|
||||||
{
|
{
|
||||||
$chemin = Config::get("dataPath") . $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}", [$consoleController, "detail"]);
|
||||||
$router->get("/consoles/{id}/modifier", [$consoleController, "modifier"]);
|
$router->get("/consoles/{id}/modifier", [$consoleController, "modifier"]);
|
||||||
$router->post("/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->post("/consoles/{id}/supprimer", [$consoleController, "supprimer"]);
|
||||||
|
|
||||||
$router->get("/jeux", [$jeuController, "liste"]);
|
$router->get("/jeux", [$jeuController, "liste"]);
|
||||||
@@ -73,6 +76,7 @@ $router->post("/jeux/api/appliquer", [$jeuController, "appliquerEnrichissement"]
|
|||||||
$router->get("/jeux/{id}", [$jeuController, "detail"]);
|
$router->get("/jeux/{id}", [$jeuController, "detail"]);
|
||||||
$router->get("/jeux/{id}/modifier", [$jeuController, "modifier"]);
|
$router->get("/jeux/{id}/modifier", [$jeuController, "modifier"]);
|
||||||
$router->post("/jeux/{id}/modifier", [$jeuController, "modifier"]);
|
$router->post("/jeux/{id}/modifier", [$jeuController, "modifier"]);
|
||||||
|
$router->post("/jeux/{id}/jaquette", [$jeuController, "recupererJaquette"]);
|
||||||
$router->post("/jeux/{id}/supprimer", [$jeuController, "supprimer"]);
|
$router->post("/jeux/{id}/supprimer", [$jeuController, "supprimer"]);
|
||||||
|
|
||||||
$router->get("/admin/utilisateurs", [$adminController, "index"]);
|
$router->get("/admin/utilisateurs", [$adminController, "index"]);
|
||||||
|
|||||||
@@ -60,9 +60,16 @@
|
|||||||
<div class="game-card-body">
|
<div class="game-card-body">
|
||||||
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
||||||
<p><?php print Helpers::echapper($consoleNom); ?></p>
|
<p><?php print Helpers::echapper($consoleNom); ?></p>
|
||||||
|
<div class="game-card-badges">
|
||||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||||
</span>
|
</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>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
<section class="page-header">
|
<section class="detail-hero console-detail-hero">
|
||||||
<div>
|
<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>
|
<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>
|
<h1 class="page-title"><?php print Helpers::echapper($console["nom"]); ?></h1>
|
||||||
<?php if (!empty($console["notes"])): ?>
|
<?php if (!empty($console["notes"])): ?>
|
||||||
<p class="lead-text"><?php print nl2br(Helpers::echapper($console["notes"])); ?></p>
|
<p class="lead-text"><?php print nl2br(Helpers::echapper($console["notes"])); ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
|
||||||
<div class="page-actions">
|
<div class="page-actions mt-3">
|
||||||
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>/modifier" class="btn btn-outline-neon">
|
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>/modifier" class="btn btn-outline-neon">
|
||||||
<i class="mdi mdi-pencil"></i> Modifier
|
<i class="mdi mdi-pencil"></i> Modifier
|
||||||
</a>
|
</a>
|
||||||
@@ -14,6 +20,49 @@
|
|||||||
<i class="mdi mdi-plus"></i> Ajouter un jeu
|
<i class="mdi mdi-plus"></i> Ajouter un jeu
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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>
|
</section>
|
||||||
|
|
||||||
<section class="mt-4">
|
<section class="mt-4">
|
||||||
@@ -38,9 +87,16 @@
|
|||||||
>
|
>
|
||||||
<div class="game-card-body">
|
<div class="game-card-body">
|
||||||
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
||||||
|
<div class="game-card-badges">
|
||||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||||
</span>
|
</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>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ $valeurs = $console ?? [
|
|||||||
"nom" => Helpers::champ("nom"),
|
"nom" => Helpers::champ("nom"),
|
||||||
"constructeur" => Helpers::champ("constructeur"),
|
"constructeur" => Helpers::champ("constructeur"),
|
||||||
"annee" => Helpers::champ("annee"),
|
"annee" => Helpers::champ("annee"),
|
||||||
"notes" => Helpers::champ("notes")
|
"notes" => Helpers::champ("notes"),
|
||||||
|
"photo" => null
|
||||||
];
|
];
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -18,9 +19,29 @@ $valeurs = $console ?? [
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</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(); ?>
|
<?php print Csrf::champCache(); ?>
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<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-md-8">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label" for="nom">Nom</label>
|
<label class="form-label" for="nom">Nom</label>
|
||||||
@@ -39,6 +60,8 @@ $valeurs = $console ?? [
|
|||||||
<textarea class="form-control" id="notes" name="notes" rows="4"><?php print Helpers::echapper($valeurs["notes"] ?? ""); ?></textarea>
|
<textarea class="form-control" id="notes" name="notes" rows="4"><?php print Helpers::echapper($valeurs["notes"] ?? ""); ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-neon">
|
<button type="submit" class="btn btn-neon">
|
||||||
|
|||||||
@@ -22,8 +22,12 @@
|
|||||||
<?php foreach ($consoles as $console): ?>
|
<?php foreach ($consoles as $console): ?>
|
||||||
<article class="console-card">
|
<article class="console-card">
|
||||||
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>" class="console-card-link">
|
<a href="/consoles/<?php print Helpers::echapper($console["id"]); ?>" class="console-card-link">
|
||||||
<div class="console-icon">
|
<div class="console-photo">
|
||||||
<i class="mdi mdi-gamepad-variant"></i>
|
<img
|
||||||
|
src="<?php print Helpers::echapper(Helpers::urlPhotoConsole($console["photo"] ?? null)); ?>"
|
||||||
|
alt="Photo de <?php print Helpers::echapper($console["nom"]); ?>"
|
||||||
|
loading="lazy"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<h2><?php print Helpers::echapper($console["nom"]); ?></h2>
|
<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>
|
<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"]); ?>">
|
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||||
</span>
|
</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"])): ?>
|
<?php if (!empty($jeu["dateSortie"])): ?>
|
||||||
<span><i class="mdi mdi-calendar"></i> <?php print Helpers::echapper($jeu["dateSortie"]); ?></span>
|
<span><i class="mdi mdi-calendar"></i> <?php print Helpers::echapper($jeu["dateSortie"]); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -23,6 +28,14 @@
|
|||||||
<a href="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/modifier" class="btn btn-neon">
|
<a href="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/modifier" class="btn btn-neon">
|
||||||
<i class="mdi mdi-pencil"></i> Modifier
|
<i class="mdi mdi-pencil"></i> Modifier
|
||||||
</a>
|
</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 ?');">
|
<form method="post" action="/jeux/<?php print Helpers::echapper($jeu["id"]); ?>/supprimer" onsubmit="return confirm('Supprimer ce jeu ?');">
|
||||||
<?php print Csrf::champCache(); ?>
|
<?php print Csrf::champCache(); ?>
|
||||||
<button type="submit" class="btn btn-outline-danger">
|
<button type="submit" class="btn btn-outline-danger">
|
||||||
@@ -64,6 +77,21 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</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>
|
<div>
|
||||||
<dt>Notes</dt>
|
<dt>Notes</dt>
|
||||||
<dd><?php print nl2br(Helpers::echapper($jeu["notes"] ?: "—")); ?></dd>
|
<dd><?php print nl2br(Helpers::echapper($jeu["notes"] ?: "—")); ?></dd>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ $estEdition = isset($jeu["id"]);
|
|||||||
$genresTexte = is_array($jeu["genres"] ?? null)
|
$genresTexte = is_array($jeu["genres"] ?? null)
|
||||||
? implode(", ", $jeu["genres"])
|
? implode(", ", $jeu["genres"])
|
||||||
: (string) ($jeu["genres"] ?? "");
|
: (string) ($jeu["genres"] ?? "");
|
||||||
|
$formatsSelectionnes = Helpers::normaliserFormats($jeu["formats"] ?? []);
|
||||||
$retourEnrichissement = $action;
|
$retourEnrichissement = $action;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -70,6 +71,23 @@ $retourEnrichissement = $action;
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div class="col-md-6">
|
||||||
<label class="form-label" for="consoleId">Console</label>
|
<label class="form-label" for="consoleId">Console</label>
|
||||||
<select class="form-select" id="consoleId" name="consoleId" required>
|
<select class="form-select" id="consoleId" name="consoleId" required>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<form method="get" action="/jeux" class="filter-bar">
|
<form method="get" action="/jeux" class="filter-bar">
|
||||||
<div class="row g-3 align-items-end">
|
<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>
|
<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"]); ?>">
|
<input type="search" class="form-control" id="q" name="q" placeholder="Titre, genre, éditeur…" value="<?php print Helpers::echapper($filtres["q"]); ?>">
|
||||||
</div>
|
</div>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-2">
|
||||||
<label class="form-label" for="etat">État</label>
|
<label class="form-label" for="etat">État</label>
|
||||||
<select class="form-select" id="etat" name="etat">
|
<select class="form-select" id="etat" name="etat">
|
||||||
<option value="">Tous</option>
|
<option value="">Tous</option>
|
||||||
@@ -39,6 +39,17 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div class="col-md-2">
|
||||||
<button type="submit" class="btn btn-outline-neon w-100">Filtrer</button>
|
<button type="submit" class="btn btn-outline-neon w-100">Filtrer</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,9 +74,16 @@
|
|||||||
<div class="game-card-body">
|
<div class="game-card-body">
|
||||||
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
<h3><?php print Helpers::echapper($jeu["titre"]); ?></h3>
|
||||||
<p><?php print Helpers::echapper($console["nom"] ?? "Console inconnue"); ?></p>
|
<p><?php print Helpers::echapper($console["nom"] ?? "Console inconnue"); ?></p>
|
||||||
|
<div class="game-card-badges">
|
||||||
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
<span class="badge-etat etat-<?php print Helpers::echapper($jeu["etat"]); ?>">
|
||||||
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
<?php print Helpers::echapper(Helpers::libelleEtat($jeu["etat"])); ?>
|
||||||
</span>
|
</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>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||