Merge pull request #90 from ThomasRubini/query_img

This commit is contained in:
Thomas Rubini 2023-01-25 16:53:05 +01:00 committed by GitHub
commit cba94b818a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 11 deletions

View File

@ -85,13 +85,15 @@ final class RecipeController
$O_recipe = RecipeModel::getRecipeByID($A_urlParams[0]); $O_recipe = RecipeModel::getRecipeByID($A_urlParams[0]);
header("Content-Type: image"); header("Content-Type: image");
if (isset($O_recipe) && $O_recipe->getImage() !== null) { if (isset($O_recipe)) {
echo $O_recipe->getImage(); $S_img = $O_recipe->queryImg();
} else { if ($S_img !== null) {
echo file_get_contents(Constants::rootDir()."/static/img/default_recipe.jpg"); echo $S_img;
return Utils::RETURN_RAW;
}
} }
echo file_get_contents(Constants::rootDir()."/static/img/default_recipe.jpg");
return Utils::RETURN_RAW; return Utils::RETURN_RAW;
} }
} }

View File

@ -81,7 +81,7 @@ final class RecipeModel
return self::createFromRow($row, $I_id); return self::createFromRow($row, $I_id);
} }
public function getImageLink(){ public function getImgLink(){
return '/static/img/recipes/'.$this->I_ID; return '/static/img/recipes/'.$this->I_ID;
} }
@ -89,7 +89,7 @@ final class RecipeModel
return '/recipe/view/'.$this->I_ID; return '/recipe/view/'.$this->I_ID;
} }
public function getImage(){ public function queryImg(){
$O_model = Model::get(); $O_model = Model::get();
$stmt = $O_model->prepare("SELECT IMG FROM RECIPE WHERE ID=:id"); $stmt = $O_model->prepare("SELECT IMG FROM RECIPE WHERE ID=:id");
$stmt->bindParam("id", $this->I_ID); $stmt->bindParam("id", $this->I_ID);

View File

@ -111,7 +111,7 @@ final class UserModel extends UserSessionModel
$stmt->execute(); $stmt->execute();
} }
public function getProfilePic(){ public function queryProfilePic(){
$O_model = Model::get(); $O_model = Model::get();
$stmt = $O_model->prepare("SELECT PROFILE_PIC FROM USER WHERE ID=:id"); $stmt = $O_model->prepare("SELECT PROFILE_PIC FROM USER WHERE ID=:id");
$stmt->bindParam("id", $this->I_ID); $stmt->bindParam("id", $this->I_ID);

View File

@ -2,7 +2,7 @@
$O_recipe = $A_view["RECIPE"]; $O_recipe = $A_view["RECIPE"];
?> ?>
<a href="<?= $O_recipe->getLink() ?>"> <a href="<?= $O_recipe->getLink() ?>">
<img src="<?= $O_recipe->getImageLink() ?>" alt="<?= $O_recipe->S_NAME ?>"> <img src="<?= $O_recipe->getImgLink() ?>" alt="<?= $O_recipe->S_NAME ?>">
<section> <section>
<h2> <?= $O_recipe->S_NAME ?> </h2> <h2> <?= $O_recipe->S_NAME ?> </h2>
<p> <?= $O_recipe->queryNote() ?> </p> <p> <?= $O_recipe->queryNote() ?> </p>

View File

@ -4,7 +4,7 @@ $O_recipe = $A_view["RECIPE"];
<main> <main>
<?php View::show("common/category_list") ?> <?php View::show("common/category_list") ?>
<article> <article>
<img src="<?= $O_recipe->getImageLink() ?>" alt="Image d'illustration de la recette"> <img src="<?= $O_recipe->getImgLink() ?>" alt="Image d'illustration de la recette">
<section class="infosRecette"> <section class="infosRecette">
<header> <header>