Skip to content
Snippets Groups Projects
Commit 41d7095b authored by SaddamAnnais's avatar SaddamAnnais
Browse files

feat: collection recipe page

parent b6c20765
Branches
Tags
No related merge requests found
<!DOCTYPE html>
<?php
require_once __DIR__ . '/../imports/pageSetup.php';
require_once __DIR__ . '/../templates/navbar.php';
require_once __DIR__ . '/../templates/card.php';
require_once __DIR__ . '/../templates/pagination.php';
?>
<head>
<title>Cooklyst!</title>
<?php pageSetup("Collection recipe page containing recipe videos that is made by creator.") ?>
<link rel="stylesheet" type="text/css" href="/public/styles/styles.css">
<link rel="stylesheet" type="text/css" href="/public/styles/templates/navbar.css">
<link rel="stylesheet" type="text/css" href="/public/styles/templates/card.css">
<link rel="stylesheet" type="text/css" href="/public/styles/templates/pagination.css">
<link rel="stylesheet" type="text/css" href="/public/styles/playlist/playlist.css">
<script type="text/javascript" src="<?= BASE_URL ?>/javascript/templates/navbar.js" defer></script>
</head>
<body>
<?php navbar(false) ?>
<div id="wrapper">
<div id="playlist-details-wrapper">
<div id="playlist-details">
<div id="playlist-title">
<?php echo $this->data->title ?? "Collection not found" ?>
</div>
<!-- later fallback image value should be made its own image, on static -->
<img id="playlist-thumb"
src="<?php echo ($this->data->cover ? $this->data->cover : BASE_URL . "/static/fallback_playlist.png") ?>"
alt="playlist-thumb" />
<div id="playlist-owner">
<?php echo "Collections made by " . $this->data->creator_name ?? "No owner" ?>
</div>
<div id="playlist-created">
<?php echo toDatetimeDescription($this->data->created_at) ?>
</div>
<div id="playlist-total">
<?php echo $this->data->total_recipe != 0 ? $this->data->total_recipe . " Recipes" : "No recipes" ?>
</div>
</div>
</div>
<div id="card-container">
<?php
if (isset($this->data->recipes)) {
// recipes and pages
foreach ($this->data->recipes as $cardItem) {
recipeCard($cardItem, true);
}
}
?>
</div>
</div>
</body>
\ No newline at end of file
......@@ -30,7 +30,7 @@
function recipeCard($data, $isPremium) {
?>
<a href="<?php echo "/recipe/watch/" . $data->recipe_id ?? BASE_URL . "/404" ?>">
<a href="<?php echo $isPremium ? "/creator/watch/" . $data->recipe_id ?? BASE_URL . "/404" : "/recipe/watch/" . $data->recipe_id ?? BASE_URL . "/404" ?>">
<div class="card-item">
<div id="duration" >
<?php echo toMinuteFormat($data->duration ) ?>
......
......@@ -167,7 +167,7 @@ class CreatorController extends Controller implements ControllerInterface
$curl = curl_init();
// FETCH DATA
// IMG from backend preferably as base64 encode. This enables the image to be directly used in img tags
if (!$collectionId) {
if (is_null($collectionId)) {
// no collectionId -> fetch all the collection that the creator Id have
// $response will be
......@@ -201,12 +201,60 @@ class CreatorController extends Controller implements ControllerInterface
];
$data->creator_id = $creatorId;
$viewResult = $this->view("creator", "CollectionList", $data);
$viewResult->render();
if ($e = curl_error($curl)) {
echo $e;
} else {
$viewResult = $this->view("creator", "CollectionList", $data);
$viewResult->render();
}
} else {
// collectionId -> fetch all the collection that the creator Id have
// $response will be
// creator_name
// title
// cover
// total_recipe
// created_at
// an array of
// - recipe_id,
// - duration (in seconds)
// - cover
// - title
// - created_at
// EXAMPLE OF FETCHING
$curl = curl_init();
// $url = "https://dummyjson.com/quotes/" . creatorId;
// curl_setopt($curl, CURLOPT_URL, $url);
// curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// $resp = curl_exec($curl);
// $data = json_decode($resp);
$data = (object) [
'creator_name' => "Pak Gembus",
'title' => 'Sea Shore',
'cover' => "",
'total_recipe' => 10,
'created_at' => date('Y-m-d H:i:s'),
'recipes' => [
(object) [
'recipe_id' => 1,
'duration' => 110,
'title' => 'test title',
'created_at' => date('Y-m-d H:i:s'),
'cover' => ""
]
],
];
if ($e = curl_error($curl)) {
echo $e;
} else {
$viewResult = $this->view("creator", "CollectionRecipe", $data);
$viewResult->render();
}
}
break;
default:
......
<?php
class CollectionRecipeView implements ViewInterface
{
public $data;
public function __construct($data = [])
{
$this->data = $data;
}
public function render()
{
require_once __DIR__ . '/../../components/creator/collectionrecipe.php';
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment