47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
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 {
|
|
$id = $_GET["id"];
|
|
$articleManager = ArticleManager::getInstance();
|
|
$article = $articleManager->getArticle($id);
|
|
if($article != null){
|
|
$title = $article->getTitle();
|
|
$content = $article->getContent();
|
|
$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();
|
|
}
|
|
}else{
|
|
$_SESSION["message"] = "missing_id";
|
|
}
|
|
?>
|