Начат запил страницы отображающей пост
This commit is contained in:
106
front/pages/view_post/page.php
Normal file
106
front/pages/view_post/page.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// View post by ID
|
||||
|
||||
|
||||
|
||||
// Includes
|
||||
// API
|
||||
require_once("api/post/index.php");
|
||||
require_once("api/comments/index.php");
|
||||
// Markup includes
|
||||
require_once("front/pages/main_nav.php");
|
||||
require_once("front/notifications.php");
|
||||
|
||||
|
||||
|
||||
// Processing request
|
||||
$reqResult = Post_GetByID_Method($_GET);
|
||||
$postData = null;
|
||||
if ($reqResult->IsError()) { // Something happened, very likely that post is not found
|
||||
header("Location: .");
|
||||
exit();
|
||||
} else {
|
||||
$postData = $reqResult->GetData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
NTFY_EchoAllNotices();
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<div class="visualbox">
|
||||
<div class="postviewer">
|
||||
<div class="stats">
|
||||
<div title="Positive votes">
|
||||
<img src="front/images/plus.png" alt="Positive votes icon">
|
||||
<p><?php echo $postData["votes_up"]; ?></p>
|
||||
</div>
|
||||
<div title="Negative votes">
|
||||
<img src="front/images/minus.png" alt="Negative votes icon">
|
||||
<p><?php echo $postData["votes_down"]; ?></p>
|
||||
</div>
|
||||
<div title="Views count">
|
||||
<img src="front/images/eye.png" alt="Views count icon">
|
||||
<p><?php echo $postData["views"]; ?></p>
|
||||
</div>
|
||||
<!--TODO: reset button for moderators-->
|
||||
</div>
|
||||
<div class="picture">
|
||||
<?php
|
||||
echo "<img src=\"" . $postData["pic_path"] . "\" alt=\"" . $postData["tags"] . "\" title=\"" . $postData["tags"] . "\">\n";
|
||||
?>
|
||||
</div>
|
||||
<div class="tags">
|
||||
<ul>
|
||||
<?php
|
||||
$tagsArr = explode(",", $postData["tags"]);
|
||||
foreach ($tagsArr as $tag)
|
||||
echo "<li>$tag</li>\n";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="comments">
|
||||
<?php
|
||||
if (!$postData["comments_enabled"]) {
|
||||
echo "<p style=\"color: gray;\"><i>Comments disabled</i></p>\n";
|
||||
} else { // TODO: this part down is untested (and incomplete), so beware
|
||||
$reqResult = Comments_GetSectionRange_Method(array("id" => $postData["comment_section_id"]));
|
||||
if ($reqResult->IsError()) {
|
||||
echo "<p style=\"color: gray;\"><i>Can't fetch comments</i></p>\n";
|
||||
} else {
|
||||
$commentsList = $reqResult->GetData();
|
||||
$commentsAmount = count($commentsList);
|
||||
echo "<p>Comments: " . strval($commentsAmount) . "</p>\n";
|
||||
foreach ($commentsList as $commentData) { // TODO
|
||||
echo "<div class=\"entry\">\n";
|
||||
echo "<div class=\"meta\">\n";
|
||||
echo "<img src=\"front/images/pfp_placeholder.png\" alt=\"Guy's pfp\">\n";
|
||||
echo "<p>\n";
|
||||
echo strval($commentData["created_at"]) . "<br>\n"; //"04/04/2024 04:20<br>\n";
|
||||
echo "<a href=\"./noway\">Guy</a>\n";
|
||||
echo "</p>\n";
|
||||
echo "</div>\n";
|
||||
echo "<p>cool story bob</p>\n";
|
||||
echo "</div>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!--
|
||||
<p>Comments: 54</p>
|
||||
<div class="entry">
|
||||
<div class="meta">
|
||||
<img src="front/images/pfp_placeholder.png" alt="Guy's pfp">
|
||||
<p>
|
||||
04/04/2024 04:20<br>
|
||||
<a href="./noway">Guy</a>
|
||||
</p>
|
||||
</div>
|
||||
<p>cool story bob</p>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user