Image details
This commit is contained in:
parent
4647018639
commit
7d5f2880dc
6 changed files with 76 additions and 1 deletions
13
controllers/c_photo.php
Normal file
13
controllers/c_photo.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$photo = false;
|
||||||
|
|
||||||
|
if (isset($_GET["id"]) and $_GET["id"]) {
|
||||||
|
$id = htmlspecialchars($_GET["id"]);
|
||||||
|
require_once(PATH_MODELS . $page . ".php");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$photo)
|
||||||
|
$alert = choixAlert("invalid_photo");
|
||||||
|
|
||||||
|
require_once(PATH_VIEWS.$page.'.php');
|
|
@ -9,3 +9,8 @@ define('MESSAGE_ERREUR',"Une erreur s'est produite");
|
||||||
define("TITRE_PAGE_ACCUEIL_TOUS", "Toutes les photos");
|
define("TITRE_PAGE_ACCUEIL_TOUS", "Toutes les photos");
|
||||||
define('TITRE', 'Mes photos');
|
define('TITRE', 'Mes photos');
|
||||||
define('ERREUR_QUERY', 'Problème d\'accès à la base de données. Contactez l\'administrateur');
|
define('ERREUR_QUERY', 'Problème d\'accès à la base de données. Contactez l\'administrateur');
|
||||||
|
define("TITRE_PAGE_PHOTO", "Les détails sur cette photo");
|
||||||
|
define("PHOTO_NOT_FOUND", "Identifiant de photo incorrect dans l'URL");
|
||||||
|
define("DESCRIPTION", "Description");
|
||||||
|
define("FILE_NAME", "Nom du fichier");
|
||||||
|
define("CATEGORY", "Catégorie");
|
||||||
|
|
|
@ -11,6 +11,9 @@ function choixAlert($message)
|
||||||
case 'url_non_valide' :
|
case 'url_non_valide' :
|
||||||
$alert['messageAlert'] = TEXTE_PAGE_404;
|
$alert['messageAlert'] = TEXTE_PAGE_404;
|
||||||
break;
|
break;
|
||||||
|
case "invalid_photo":
|
||||||
|
$alert["messageAlert"] = PHOTO_NOT_FOUND;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
$alert['messageAlert'] = MESSAGE_ERREUR;
|
$alert['messageAlert'] = MESSAGE_ERREUR;
|
||||||
}
|
}
|
||||||
|
|
18
models/m_photo.php
Normal file
18
models/m_photo.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once("lib/getPDD.php");
|
||||||
|
|
||||||
|
$bdd = getPDO();
|
||||||
|
|
||||||
|
if ($bdd instanceof PDO) {
|
||||||
|
try {
|
||||||
|
$req = $bdd->prepare("SELECT * FROM Photo p INNER JOIN Categorie c ON c.catId = p.catId WHERE p.photoId = ?");
|
||||||
|
$req->execute(array($id));
|
||||||
|
|
||||||
|
$photo = $req->fetch();
|
||||||
|
$req->closeCursor();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$alert = choixAlert("query");
|
||||||
|
}
|
||||||
|
} elseif ($bdd instanceof Exception)
|
||||||
|
$alert = choixAlert("query");
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<?php if(isset($photos) and $photos) {
|
<?php if(isset($photos) and $photos) {
|
||||||
foreach ($photos as $photo) {?>
|
foreach ($photos as $photo) {?>
|
||||||
<img src="<?= PATH_IMAGES ?>/<?= $photo['nomFich'] ?>" alt="<?= $photo['description'] ?>">
|
<a href="index.php?page=photo&id=<?= $photo["photoId"] ?>"><img src="<?= PATH_IMAGES ?>/<?= $photo['nomFich'] ?>" alt="<?= $photo['description'] ?>"></a>
|
||||||
<?php }
|
<?php }
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
|
|
36
views/v_photo.php
Normal file
36
views/v_photo.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
// En tête de page
|
||||||
|
?>
|
||||||
|
<?php require_once(PATH_VIEWS.'header.php');?>
|
||||||
|
|
||||||
|
<!-- Zone message d'alerte -->
|
||||||
|
<?php require_once(PATH_VIEWS.'alert.php');?>
|
||||||
|
|
||||||
|
<!-- Début de la page -->
|
||||||
|
<?php if (isset($photo) and $photo) { ?>
|
||||||
|
<h1><?= TITRE_PAGE_PHOTO ?></h1>
|
||||||
|
<div class = "col-md-6 col-sm-6 col-xs-12">
|
||||||
|
<img src="<?= PATH_IMAGES ?>/<?= $photo['nomFich'] ?>" alt="<?= $photo['description'] ?>">
|
||||||
|
</div>
|
||||||
|
<div class = "col-md-6 col-sm-6 col-xs-12">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tr>
|
||||||
|
<th><?= DESCRIPTION ?></th>
|
||||||
|
<th><?= $photo["description"] ?></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= FILE_NAME ?></th>
|
||||||
|
<th><?= $photo["nomFich"] ?></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= CATEGORY ?></th>
|
||||||
|
<th><?= $photo["nomCat"] ?></th>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<!-- Fin de la page -->
|
||||||
|
|
||||||
|
<!-- Pied de page -->
|
||||||
|
<?php require_once(PATH_VIEWS.'footer.php');
|
Reference in a new issue