Merge pull request 'Anzeigenamen' (#51) from AnzeigeNamen into dev

Reviewed-on: #51
This commit was merged in pull request #51.
This commit is contained in:
2026-07-17 18:09:29 +02:00
6 changed files with 26 additions and 9 deletions
+2 -2
View File
@@ -45,8 +45,8 @@ include_once 'php/controller/showArticle-controller.php';
</h1> </h1>
<div class="article-view-meta"> <div class="article-view-meta">
<?php if (isset($author) && !empty($author)): ?> <?php if (isset($name) && !empty($name)): ?>
<span class="article-view-author">Von: <strong><?php echo htmlspecialchars($author); ?></strong></span> <span class="article-view-author">Von: <strong><?php echo htmlspecialchars($name); ?></strong></span>
<?php endif; ?> <?php endif; ?>
</div> </div>
+1 -4
View File
@@ -58,7 +58,7 @@ $currentPage = isset($page) ? $page : 1;
<div class="cat-view-item"> <div class="cat-view-item">
<div class="cat-view-content"> <div class="cat-view-content">
<h2 class="cat-view-item-title"> <h2 class="cat-view-item-title">
<a href="#" class="cat-view-link"> <a href="index.php?pfad=showArticle&id=<?php echo htmlspecialchars($article->getID()); ?>" class="cat-view-link">
<?php echo (isset($article) && !empty($article->getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?> <?php echo (isset($article) && !empty($article->getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>
</a> </a>
</h2> </h2>
@@ -72,9 +72,6 @@ $currentPage = isset($page) ? $page : 1;
</span> </span>
</div> </div>
<p style="margin: 0; color: #4a5568;">
<?php echo (isset($article) && !empty($article->getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>
</p>
</div> </div>
<div class="cat-view-arrow">&rarr;</div> <div class="cat-view-arrow">&rarr;</div>
</div> </div>
+3 -2
View File
@@ -2,8 +2,8 @@
if (session_status() === PHP_SESSION_NONE) { if (session_status() === PHP_SESSION_NONE) {
session_start(); session_start();
} }
require_once '../model/LocalArticleManager.php';
require_once '../model/ArticleManager.php'; require_once '../model/ArticleManager.php';
require_once '../model/UserManager.php';
require_once '../model/Article.php'; require_once '../model/Article.php';
require_once '../validator/search-validator.php'; require_once '../validator/search-validator.php';
@@ -18,6 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
try { try {
$articleManager = ArticleManager::getInstance(); $articleManager = ArticleManager::getInstance();
$userManager = UserManager::getInstance();
$results = $articleManager->search($search); $results = $articleManager->search($search);
@@ -52,7 +53,7 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
"id" => $obj->getId(), "id" => $obj->getId(),
"title" => $obj->getTitle(), "title" => $obj->getTitle(),
"content" => $obj->getContent(), "content" => $obj->getContent(),
"author" => $obj->getAuthor(), "author" => $userManager->findUser($obj->getAuthor())["vorname"] . " " . $userManager->findUser($obj->getAuthor())["nachname"],
"category" => $obj->getCategory(), "category" => $obj->getCategory(),
"tags" => $obj->getTags(), "tags" => $obj->getTags(),
"creationDate" => $obj->getCreationDate(), "creationDate" => $obj->getCreationDate(),
@@ -5,6 +5,7 @@ if (session_status() === PHP_SESSION_NONE) {
require_once 'php/model/Article.php'; require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php'; require_once 'php/model/ArticleManager.php';
require_once 'php/model/UserManager.php';
require_once 'php/model/CommentManager.php'; require_once 'php/model/CommentManager.php';
if (isset($_GET["id"]) && !empty($_GET["id"])){ if (isset($_GET["id"]) && !empty($_GET["id"])){
@@ -19,6 +20,9 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){
$author = $article->getAuthor(); $author = $article->getAuthor();
$tags = $article->getTags(); $tags = $article->getTags();
$articleObj = $article; // Objekt für die Like-Abfagen sichern $articleObj = $article; // Objekt für die Like-Abfagen sichern
$userManager = UserManager::getInstance();
$name = $userManager->findUser($author)["vorname"]." ".$userManager->findUser($author)["nachname"];
}else{ }else{
//header("location: index.php?pfad=404"); //header("location: index.php?pfad=404");
include_once "content/404.php"; include_once "content/404.php";
@@ -5,6 +5,7 @@ if (session_status() === PHP_SESSION_NONE) {
require_once 'php/model/Article.php'; require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php'; require_once 'php/model/ArticleManager.php';
require_once 'php/model/UserManager.php';
require_once 'php/validator/article-validator.php'; require_once 'php/validator/article-validator.php';
if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){
@@ -19,7 +20,11 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali
try { try {
$articleManager = ArticleManager::getInstance(); $articleManager = ArticleManager::getInstance();
$userManager = UserManager::getInstance();
$allArticles = $articleManager->getArticlesByCategory($category); $allArticles = $articleManager->getArticlesByCategory($category);
foreach ($allArticles as $article) {
$article->setAuthor($userManager->findUser($article->getAuthor())["vorname"] . " " . $userManager->findUser($article->getAuthor())["nachname"]);
}
$totalArticles = count($allArticles); $totalArticles = count($allArticles);
// --- SORTIERUNG LOGIK --- // --- SORTIERUNG LOGIK ---
+10
View File
@@ -97,6 +97,16 @@ class Article
return $this->author; 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. * Gibt das Veröffentlichungsdatum des Beitrags zurück.
* @return string * @return string