diff --git a/content/showArticle.php b/content/showArticle.php index cd01df6..aea506c 100644 --- a/content/showArticle.php +++ b/content/showArticle.php @@ -45,8 +45,8 @@ include_once 'php/controller/showArticle-controller.php';
- - Von: + + Von:
diff --git a/content/showCategory.php b/content/showCategory.php index 89aa42a..7b83df5 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -58,7 +58,7 @@ $currentPage = isset($page) ? $page : 1;

- + getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>

@@ -71,10 +71,7 @@ $currentPage = isset($page) ? $page : 1; ❤️ getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?>
- -

- getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?> -

+
diff --git a/php/controller/search-results-controller.php b/php/controller/search-results-controller.php index 9907a69..5e6d125 100644 --- a/php/controller/search-results-controller.php +++ b/php/controller/search-results-controller.php @@ -2,8 +2,8 @@ if (session_status() === PHP_SESSION_NONE) { session_start(); } -require_once '../model/LocalArticleManager.php'; require_once '../model/ArticleManager.php'; +require_once '../model/UserManager.php'; require_once '../model/Article.php'; require_once '../validator/search-validator.php'; @@ -18,6 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) { try { $articleManager = ArticleManager::getInstance(); + $userManager = UserManager::getInstance(); $results = $articleManager->search($search); @@ -52,7 +53,7 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) { "id" => $obj->getId(), "title" => $obj->getTitle(), "content" => $obj->getContent(), - "author" => $obj->getAuthor(), + "author" => $userManager->findUser($obj->getAuthor())["vorname"] . " " . $userManager->findUser($obj->getAuthor())["nachname"], "category" => $obj->getCategory(), "tags" => $obj->getTags(), "creationDate" => $obj->getCreationDate(), diff --git a/php/controller/showArticle-controller.php b/php/controller/showArticle-controller.php index 61c6f99..676f812 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/UserManager.php'; require_once 'php/model/CommentManager.php'; if (isset($_GET["id"]) && !empty($_GET["id"])){ @@ -19,6 +20,9 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){ $author = $article->getAuthor(); $tags = $article->getTags(); $articleObj = $article; // Objekt für die Like-Abfagen sichern + + $userManager = UserManager::getInstance(); + $name = $userManager->findUser($author)["vorname"]." ".$userManager->findUser($author)["nachname"]; }else{ //header("location: index.php?pfad=404"); include_once "content/404.php"; diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index df2f1ca..938fca0 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-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/UserManager.php'; require_once 'php/validator/article-validator.php'; if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){ @@ -19,7 +20,11 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali try { $articleManager = ArticleManager::getInstance(); + $userManager = UserManager::getInstance(); $allArticles = $articleManager->getArticlesByCategory($category); + foreach ($allArticles as $article) { + $article->setAuthor($userManager->findUser($article->getAuthor())["vorname"] . " " . $userManager->findUser($article->getAuthor())["nachname"]); + } $totalArticles = count($allArticles); // --- SORTIERUNG LOGIK --- diff --git a/php/model/Article.php b/php/model/Article.php index a0e1b65..a553c43 100644 --- a/php/model/Article.php +++ b/php/model/Article.php @@ -97,6 +97,16 @@ class Article return $this->author; } + /** + * Setzt einen neuen Autor eines Beitrages. + * @param string $author + * @return void + */ + public function setAuthor(string $author) + { + $this->author = $author; + } + /** * Gibt das Veröffentlichungsdatum des Beitrags zurück. * @return string