make final version of structure send to recipe view

This commit is contained in:
Thomas Rubini 2023-01-22 22:57:21 +01:00
parent 4dcb58ee16
commit ac78ec31fd
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
6 changed files with 33 additions and 34 deletions

View File

@ -15,6 +15,8 @@ final class RecipeController
return View::show("errors/404");
}
$A_returnArray["ADMIN"] = Session::is_admin();
View::show("recipe/view", $A_returnArray);
// print_r($A_urlParams);

View File

@ -2,6 +2,26 @@
final class ApprModel {
public function searchRecipeApprsWithAuthors($I_recipe_id)
{
$O_model = Model::get();
$stmt = $O_model->prepare("
SELECT APPRECIATION.*, USER.USERNAME as AUTHOR_NAME FROM APPRECIATION
JOIN USER ON USER.ID = APPRECIATION.AUTHOR_ID
WHERE RECIPE_ID = :recipe_id
");
$stmt->bindParam("recipe_id", $I_recipe_id);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach($rows as &$row) {
$row["AUTHOR_IMG_LINK"] = "/static/img/user.jpg";
}
return $rows;
}
public function searchRecipeApprs($I_recipe_id)
{
$O_model = Model::get();

View File

@ -40,7 +40,7 @@ final class RecipeModel
$O_apprModel = new ApprModel();
$A_recipe["APPRS"] = $O_apprModel->searchRecipeApprs($I_id);
$A_recipe["APPRS"] = $O_apprModel->searchRecipeApprsWithAuthors($I_id);
return $A_recipe;
}

View File

@ -1,7 +1,7 @@
<section>
<header>
<img src="<?= $A_view["PROFILE_IMG"] ?>" alt="profile picture">
<h3> <?= $A_view["NAME"] ?> </h3>
<img src="<?= $A_view["AUTHOR_IMG_LINK"] ?>" alt="profile picture">
<h3> <?= $A_view["AUTHOR_NAME"] ?> </h3>
<p> <?= $A_view["COMMENT"] ?> </p>
</header>
<p> <?= $A_view["NOTE"] ?> </p>

View File

@ -16,8 +16,9 @@
</form>
<?php
foreach ($A_view as $appreciation){
View::show("appreciations/appreciation", $appreciation);
foreach ($A_view["APPRS"] as $A_appr){
$A_appr["ADMIN"] = $A_view["ADMIN"];
View::show("appreciations/appreciation", $A_appr);
}
?>
</section>

View File

@ -35,37 +35,13 @@
<p>By <?= $A_view["AUTHOR_USERNAME"] ?></p>
<?php
$appreciations = array(
View::show(
"appreciations/view",
array(
"NAME" => "test",
"PROFILE_IMG" => "/static/img/users/1.jpg",
"COMMENT" => "j'me présente, je m'appelle henry",
"NOTE" => "2",
"DATE" => DATE("2020-07-08")
),
array(
"NAME" => "test",
"PROFILE_IMG" => "/static/img/users/1.jpg",
"COMMENT" => "j'me présente, je m'appelle henry",
"NOTE" => "2",
"DATE" => DATE("2020-07-08")
),
array(
"NAME" => "test",
"PROFILE_IMG" => "/static/img/users/1.jpg",
"COMMENT" => "j'me présente, je m'appelle henry",
"NOTE" => "2",
"DATE" => DATE("2020-07-08")
),
array(
"NAME" => "AAAA",
"PROFILE_IMG" => "/static/img/users/1.jpg",
"COMMENT" => "j'me présente, je m'appelle henry",
"NOTE" => "2",
"DATE" => DATE("2020-07-08")
),
"APPRS" => $A_view["APPRS"],
"ADMIN" => $A_view["ADMIN"]
)
);
View::show("appreciations/view", $appreciations)//need to be linked with recipe?
?>
</main>