Skip to content
Snippets Groups Projects
Commit 5d8c8e96 authored by Addin Munawwar's avatar Addin Munawwar
Browse files

Merge branch 'dev' of https://github.com/moonawar/wbd-10-backup into dev

parents cebfbbec ab634522
No related merge requests found
......@@ -54,8 +54,29 @@ class PremiumController extends Controller implements ControllerInterface
header("Location: /user/login", true, 301);
exit;
}
$premiumView = $this->view('premium', 'PremiumBookDetailView');
$premiumView->render();
try {
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
$bookId = (int)$params;
// User
if(isset($_SESSION['username'])){
$userData = $this->model('UserModel');
$user = $userData->getUserByUsername($_SESSION['username']);
$username = $user['username'];
$nav = ['username'=>$username];
}else{
$nav = ['username'=>null];
}
$premiumView = $this->view('premium', 'PremiumBookDetailView',array_merge($nav, ['bookId'=>$bookId]));
$premiumView->render();
break;
default:
throw new RequestException('Method Not Allowed', 405);
}
} catch (Exception $e) {
http_response_code($e->getCode());
exit;
}
}
}
......@@ -36,10 +36,7 @@
<?php
$collectionId = $this->data['collectionId'];
$raw_data = file_get_contents("http://host.docker.internal:8040/api/curator-collection/$collectionId");
echo var_dump($raw_data);
echo `http://host.docker.internal:8040/api/curator-collection/$collectionId`;
$data = json_decode($raw_data, true);
echo var_dump($data);
$books = $data['books'];
foreach (($books) as $index => $book) {
......@@ -47,7 +44,7 @@
echo "<td>" . $index+1 . "</td>";
echo "<td>" . $book['title'] . "</td>";
echo "<td>" . $book['author'] . "</td>";
echo '<td><a href="/book/update/' . $book['book_id'] .'">Details</a></td>';
echo '<td><a href="/premium/book/' . $book['book_id'] .'">Details</a></td>';
echo "</tr>";
}
?>
......
......@@ -17,44 +17,21 @@
<!-- Navigation bar -->
<?php include(dirname(__DIR__) . '../../components/Navbar.php') ?>
<div class="container">
<?php if(isset($this->data['book_id']) ):?>
<?php if(isset($this->data['bookId']) ):?>
<h2>PREMIUM DETAILS</h2>
<div class="details-container">
<!-- Book Title -->
<h3> <?=$this->data['title']?> </h3>
<?php
$bookId = $this->data['bookId'];
$raw_data = file_get_contents("http://host.docker.internal:8040/api/book-collection/$bookId");
$data = json_decode($raw_data, true);
$book = $data['book'];
<!-- Author Genre Year-->
<h4> <?=$this->data['author']?></h4>
<h4> <?=$this->data['genre']?></h4>
<h4> <?=$this->data['year']?></h4>
<!-- Text -->
<p> <?=$this->data['summary']?></p>
<!-- todo: check ownership -->
<?php
if(isset($this->data['username'])):
if(isset($this->data['own'])):
$bookIdToCheck = $this->data['book_id'];
$found = false;
foreach ($this->data['own'] as $ownedBook) {
if (isset($ownedBook['book_id']) && $ownedBook['book_id'] == $bookIdToCheck) {
$found = true;
break;
}
}
if($found):
echo "<h3> Title: ". $book['title'] ."</h3>";
echo "<h4> Author: ". $book['createdBy'] ."</h4>";
echo "<h4> Year: ". $book['year'] ."</h4>";
echo "<h4> Genre:". $book['genre'] ."</h4>";
echo "<text>". $book['content'] ."</text>";
echo "<h5>Duration: ". $book["duration"] ."</h5>";
?>
<audio controls>
<source src="<?= BASE_URL ?>/<?= str_replace('/var/www/html/config/', '', $this->data['audio_path']) ?>" alt ="book-audio" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</div>
<?php else : ?>
<h2 class="info">Can't find the book you're looking for!</h2>
<?php endif; ?>
......
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