showArticle -> like-Button

This commit is contained in:
2026-06-17 12:53:33 +02:00
parent ee41dd4cfe
commit 8d683cc1a0
3 changed files with 83 additions and 23 deletions
+15
View File
@@ -5,6 +5,7 @@ if (session_status() === PHP_SESSION_NONE) {
require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php';
require_once 'php/model/CommentManager.php';
if (isset($_GET["id"]) && !empty($_GET["id"])){
try {
@@ -17,11 +18,25 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){
$category = $article->getCategory();
$author = $article->getAuthor();
$tags = $article->getTags();
$articleObj = $article; // Objekt für die Like-Abfagen sichern
}else{
//header("location: index.php?pfad=404");
include_once "content/404.php";
exit();
}
$commentManager = CommentManager::getInstance();
$comments = $commentManager->getCommentsByArticle($_GET["id"]);
foreach ($comments as $comment) {
if ($comment->isReply()) {
$parentId = $comment->getParentCommentId();
$repliesByParent[$parentId][] = $comment;
} else {
$mainComments[] = $comment;
}
}
} catch (Exception $e){
$_SESSION["message"] = "internal_error";
exit();