diff --git a/content/showArticle.php b/content/showArticle.php index d461d16..cd01df6 100644 --- a/content/showArticle.php +++ b/content/showArticle.php @@ -1,28 +1,10 @@ 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"; - } -} +include_once 'php/controller/showArticle-controller.php'; ?>
- - - +
+ +
+ + + + + + +
+ ❤️ + + + + + + +
+ +

diff --git a/css/showArticle.css b/css/showArticle.css index 46ffbad..ec801d5 100644 --- a/css/showArticle.css +++ b/css/showArticle.css @@ -239,4 +239,48 @@ .comment-login-hint p { margin-bottom: 1rem; +} + +/* +Like-Button etc. + */ + +.category-and-likes-row { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; +} + +.article-view-likes { + display: flex; + align-items: center; + gap: 10px; + font-size: 0.95em; +} + +.article-view-likes .like-count { + font-weight: bold; +} + +.article-view-likes .login-hint { + font-size: 0.8em; + color: #777; +} + +/* Interaktiver Like/Unlike-Button */ +.like-toggle-btn { + text-decoration: none; + padding: 4px 10px; + border: 1px solid #bbb; + border-radius: 4px; + background-color: #f5f5f5; + color: #333; + font-weight: 500; + transition: background-color 0.2s ease, border-color 0.2s ease; +} + +.like-toggle-btn:hover { + background-color: #eaeaea; + border-color: #999; } \ No newline at end of file diff --git a/php/controller/showArticle-controller.php b/php/controller/showArticle-controller.php index cff0483..6e140f9 100644 --- a/php/controller/showArticle-controller.php +++ b/php/controller/showArticle-controller.php @@ -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();