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"); return View::show("errors/404");
} }
$A_returnArray["ADMIN"] = Session::is_admin();
View::show("recipe/view", $A_returnArray); View::show("recipe/view", $A_returnArray);
// print_r($A_urlParams); // print_r($A_urlParams);

View File

@ -2,6 +2,26 @@
final class ApprModel { 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) public function searchRecipeApprs($I_recipe_id)
{ {
$O_model = Model::get(); $O_model = Model::get();

View File

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

View File

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

View File

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

View File

@ -35,37 +35,13 @@
<p>By <?= $A_view["AUTHOR_USERNAME"] ?></p> <p>By <?= $A_view["AUTHOR_USERNAME"] ?></p>
<?php <?php
$appreciations = array( View::show(
"appreciations/view",
array( array(
"NAME" => "test", "APPRS" => $A_view["APPRS"],
"PROFILE_IMG" => "/static/img/users/1.jpg", "ADMIN" => $A_view["ADMIN"]
"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")
),
); );
View::show("appreciations/view", $appreciations)//need to be linked with recipe?
?> ?>
</main> </main>