88 lines
4.5 KiB
PHP
88 lines
4.5 KiB
PHP
<?php
|
|
include_once "php/controller/showCategory-controller.php";
|
|
?>
|
|
|
|
<div class="cat-view-container">
|
|
<div class="cat-view-header">
|
|
<!-- Kategorie-Titel sicher ausgeben -->
|
|
<h1 class="cat-view-title">Kategorie: <?php echo (isset($category) && !empty($category)) ? htmlspecialchars($category) : 'Unbekannt'; ?></h1>
|
|
<p class="cat-view-meta-text">Beiträge in dieser Kategorie</p>
|
|
</div>
|
|
|
|
<!-- Die Artikel-Liste -->
|
|
<div class="cat-view-list">
|
|
<?php if (isset($articles) && !empty($articles)): ?>
|
|
<?php foreach ($articles as $article): ?>
|
|
<div class="cat-view-item">
|
|
<div class="cat-view-content">
|
|
<!-- Titel als klickbarer Link -->
|
|
<h2 class="cat-view-item-title">
|
|
<a href="#" class="cat-view-link">
|
|
<?php echo (isset($article) && !empty($article->getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>
|
|
</a>
|
|
</h2>
|
|
|
|
<!-- Meta-Zeile für Autor und Likes -->
|
|
<div class="cat-view-meta-row">
|
|
<p class="cat-view-author">
|
|
von <span class="cat-view-author-name"><?php echo (isset($article) && !empty($article->getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?></span>
|
|
</p>
|
|
<span class="cat-view-likes">
|
|
❤ <?php echo (isset($article) && !empty($article->getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?>
|
|
</span>
|
|
</div>
|
|
|
|
<!-- Beschreibungstext -->
|
|
<p style="margin: 0; color: #4a5568;">
|
|
<?php echo (isset($article) && !empty($article->getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>
|
|
</p>
|
|
</div>
|
|
<!-- Interaktiver Pfeil rechts -->
|
|
<div class="cat-view-arrow">→</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<p class="cat-view-meta-text">Keine Artikel in dieser Kategorie gefunden.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- Der Paginator -->
|
|
<?php if (isset($totalPages) && $totalPages > 1): ?>
|
|
<div class="cat-view-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; ?>">
|
|
|
|
<!-- JS benötigt die Klasse 's-res-page-navigation' -->
|
|
<div class="s-res-page-navigation">
|
|
<?php $currentPage = $page ?? 1; ?>
|
|
|
|
<!-- Zurück-Button (Nutzt JS-Klasse 's-res-page-btn') -->
|
|
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage - 1; ?>" <?php echo ($currentPage <= 1) ? 'disabled' : ''; ?>>
|
|
« Zurück
|
|
</button>
|
|
|
|
<!-- Seitenzahlen generieren -->
|
|
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
|
<!-- Der aktive Button erhält zusätzlich die neue Klasse 'cat-active-btn' -->
|
|
<button type="button"
|
|
class="s-res-page-btn <?php echo ($i === $currentPage) ? 'cat-active-btn' : ''; ?>"
|
|
data-page="<?php echo $i; ?>"
|
|
<?php echo ($i === $currentPage) ? 'disabled' : ''; ?>>
|
|
<?php echo $i; ?>
|
|
</button>
|
|
<?php endfor; ?>
|
|
|
|
<!-- Vor-Button -->
|
|
<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>
|