Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82e8c8a1a3 | |||
| c0d8fdede6 | |||
| 958ee1c1f5 | |||
| 1dd128d480 | |||
| dca716ddc5 | |||
| c1dd4fce2b | |||
| 16cfa92721 | |||
| 3b2ed78c1c |
+63
-13
@@ -2,31 +2,81 @@
|
||||
include_once "php/controller/showCategory-controller.php";
|
||||
?>
|
||||
|
||||
<main>
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<h1><?php if (isset($category) && !empty($category)){ echo htmlspecialchars($category); } ?></h1>
|
||||
<div class="s-res-main-content">
|
||||
<div class="s-res-header">
|
||||
<!-- Kategorie-Titel im exakten Stil der Suchergebnisse -->
|
||||
<h1 class="s-res-main-title">Kategorie: <?php echo (isset($category) && !empty($category)) ? htmlspecialchars($category) : 'Unbekannt'; ?></h1>
|
||||
<p class="s-res-meta">Beiträge in dieser Kategorie</p>
|
||||
</div>
|
||||
|
||||
<!-- Die Artikel-Liste -->
|
||||
<div class="s-res-list">
|
||||
<?php
|
||||
if (!empty($articles)): ?>
|
||||
<?php if (isset($articles) && !empty($articles)): ?>
|
||||
<?php foreach ($articles as $article): ?>
|
||||
<div class="s-res-item">
|
||||
<div class="s-res-content">
|
||||
<!-- Titel als klickbarer Link wie im Original -->
|
||||
<h2 class="s-res-item-title">
|
||||
<a href="index.php?pfad=showArticle&id=<?php echo $article->getId(); ?>" class="s-res-link">
|
||||
<?php echo htmlspecialchars($article->getTitle()); ?>
|
||||
<a href="#" class="s-res-link">
|
||||
<?php echo (isset($article) && !empty($article->getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>
|
||||
</a>
|
||||
</h2>
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($article->getAuthor()); ?></span></p>
|
||||
|
||||
<!-- Die fehlende Meta-Zeile für Autor und Likes für das richtige Design -->
|
||||
<div class="s-res-meta-row">
|
||||
<p class="s-res-author">
|
||||
von <span class="s-res-author-name"><?php echo (isset($article) && !empty($article->getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?></span>
|
||||
</p>
|
||||
<!-- Likes Anzeige (Falls dein Objekt getLikes() oder getLikeCount() hat) -->
|
||||
<span class="s-res-likes">
|
||||
❤ <?php echo (isset($article) && !empty($article->getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Beschreibungstext -->
|
||||
<p style="margin-top: 0.5rem; color: #4a5568;">
|
||||
<?php echo (isset($article) && !empty($article->getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Der originale Pfeil rechts -->
|
||||
<div class="s-res-arrow">→</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
else: ?>
|
||||
<p> Es sind noch keine Beiträge in dieser Kategorie enthalten.</p>
|
||||
<?php else: ?>
|
||||
<p class="s-res-meta">Keine Artikel in dieser Kategorie gefunden.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<!-- Der Paginator -->
|
||||
<?php if (isset($totalPages) && $totalPages > 1): ?>
|
||||
<div class="s-res-pagination-footer">
|
||||
<div></div> <!-- Hält die Buttons auf der rechten Seite -->
|
||||
|
||||
<form id="search-form-id" action="index.php" method="GET" style="display: inline;">
|
||||
<input type="hidden" name="pfad" value="showCategory">
|
||||
<input type="hidden" name="category" value="<?php echo (isset($category) && !empty($category)) ? htmlspecialchars($category) : ''; ?>">
|
||||
<input type="hidden" id="s-res-page-input" name="page" value="<?php echo (isset($page) && !empty($page)) ? $page : 1; ?>">
|
||||
|
||||
<div class="s-res-page-navigation">
|
||||
<?php $currentPage = $page ?? 1; ?>
|
||||
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage - 1; ?>" <?php echo ($currentPage <= 1) ? 'disabled' : ''; ?>>
|
||||
« Zurück
|
||||
</button>
|
||||
|
||||
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
||||
<button type="button"
|
||||
class="s-res-page-btn <?php echo ($i === $currentPage) ? 's-res-page-btn-active' : ''; ?>"
|
||||
data-page="<?php echo $i; ?>"
|
||||
<?php echo ($i === $currentPage) ? 'disabled' : ''; ?>>
|
||||
<?php echo $i; ?>
|
||||
</button>
|
||||
<?php endfor; ?>
|
||||
|
||||
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage + 1; ?>" <?php echo ($currentPage >= $totalPages) ? 'disabled' : ''; ?>>
|
||||
Weiter »
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -25,14 +25,6 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){
|
||||
exit();
|
||||
}
|
||||
|
||||
if($_GET["pfad"] == "updateArticle"){
|
||||
if($article->getAuthor() != $_SESSION["user"]){
|
||||
$_SESSION["message"] = "unauthorized_access";
|
||||
header("location: ../../index.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
$commentManager = CommentManager::getInstance();
|
||||
$comments = $commentManager->getCommentsByArticle($_GET["id"]);
|
||||
|
||||
|
||||
@@ -1,19 +1,39 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
require_once 'php/model/Article.php';
|
||||
require_once 'php/model/ArticleManager.php';
|
||||
require_once 'php/validator/article-validator.php';
|
||||
|
||||
if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){
|
||||
$category = $_GET["category"];
|
||||
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
if ($page < 1) { $page = 1; }
|
||||
|
||||
try {
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
$articles = $articleManager->getArticlesByCategory($category);
|
||||
|
||||
$allArticles = $articleManager->getArticlesByCategory($category);
|
||||
|
||||
// Paginierung konfigurieren
|
||||
$limit = 10; // Wie viele Artikel pro Seite?
|
||||
$totalArticles = count($allArticles);
|
||||
$totalPages = ceil($totalArticles / $limit);
|
||||
|
||||
if ($page > $totalPages && $totalPages > 0) { $page = $totalPages; }
|
||||
|
||||
$offset = ($page - 1) * $limit;
|
||||
$articles = array_slice($allArticles, $offset, $limit);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$_SESSION["message"] = "internal_error";
|
||||
include_once "content/404.php";
|
||||
exit();
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$_SESSION["message"] = "invalid_category";
|
||||
include_once "content/404.php";
|
||||
exit();
|
||||
|
||||
Reference in New Issue
Block a user