From 7694396454bee6a7f3bbb5f1046296bf12a383a4 Mon Sep 17 00:00:00 2001 From: Caroline Schulte Date: Mon, 15 Jun 2026 22:56:00 +0200 Subject: [PATCH] =?UTF-8?q?Antwortm=C3=B6glichkeit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/showArticle.php | 74 +++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/content/showArticle.php b/content/showArticle.php index dbd4082..0038341 100644 --- a/content/showArticle.php +++ b/content/showArticle.php @@ -3,11 +3,28 @@ include_once 'php/controller/showArticle-controller.php'; require_once 'php/model/CommentManager.php'; $comments = []; +$mainComments = []; +$repliesByParent = []; if (isset($_GET["id"])) { try { $commentManager = CommentManager::getInstance(); $comments = $commentManager->getCommentsByArticle($_GET["id"]); + + foreach ($comments as $comment) { + if ($comment->isReply()) { + $parentId = $comment->getParentCommentId(); + + if (!isset($repliesByParent[$parentId])) { + $repliesByParent[$parentId] = []; + } + + $repliesByParent[$parentId][] = $comment; + } else { + $mainComments[] = $comment; + } + } + } catch (Exception $e) { $_SESSION["message"] = "internal_error"; } @@ -26,7 +43,7 @@ if (isset($_GET["id"])) {

- +

Es ist ein Fehler aufgetreten. Die ID konnte nicht ausgelesen werden. Bitte versuche es erneut.

@@ -102,40 +119,38 @@ if (isset($_GET["id"])) {

Kommentare

- - - isReply()): ?> -
-

- getAuthor()); ?> - getCreated()); ?> -

+ + +
+

+ getAuthor()); ?> + getCreated()); ?> +

-

getContent())); ?>

+

getContent())); ?>

- + -
- - getParentCommentId() === $comment->getId()): ?> -
-

- getAuthor()); ?> - getCreated()); ?> -

+
+ getId()])): ?> + getId()] as $reply): ?> +
+

+ getAuthor()); ?> + getCreated()); ?> +

-

getContent())); ?>

-
- +

getContent())); ?>

+
-
+
- +

@@ -149,6 +164,7 @@ if (isset($_GET["id"])) { "> +