111 lines
5.8 KiB
PHP
111 lines
5.8 KiB
PHP
<?php
|
|
include_once "php/controller/showCategory-controller.php";
|
|
|
|
$currentSort = isset($sortStyle) ? $sortStyle : 'alphabet';
|
|
$currentPage = isset($page) ? $page : 1;
|
|
?>
|
|
|
|
<!-- Das Formular umschließt jetzt das gesamte Layout -->
|
|
<form id="search-form-id" action="index.php" method="GET" style="display: contents;">
|
|
<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 $currentPage; ?>">
|
|
|
|
<div class="cat-view-container">
|
|
|
|
<!-- LINKE SPALTE: SEITENLEISTE FÜR SORTIERUNG -->
|
|
<aside class="cat-sidebar">
|
|
<div class="cat-sidebar-box">
|
|
<h3 class="cat-sidebar-title">Sortierung</h3>
|
|
<div class="cat-filter-group">
|
|
<label class="cat-filter-option">
|
|
<input type="radio" name="sort" value="alphabet" <?php echo ($currentSort === 'alphabet') ? 'checked' : ''; ?> onchange="this.form.submit();">
|
|
Alphabetisch
|
|
</label>
|
|
<label class="cat-filter-option">
|
|
<input type="radio" name="sort" value="likes" <?php echo ($currentSort === 'likes') ? 'checked' : ''; ?> onchange="this.form.submit();">
|
|
Beliebtheit (Likes)
|
|
</label>
|
|
<label class="cat-filter-option">
|
|
<input type="radio" name="sort" value="newest" <?php echo ($currentSort === 'newest') ? 'checked' : ''; ?> onchange="this.form.submit();">
|
|
Neueste Beiträge
|
|
</label>
|
|
<label class="cat-filter-option">
|
|
<input type="radio" name="sort" value="oldest" <?php echo ($currentSort === 'oldest') ? 'checked' : ''; ?> onchange="this.form.submit();">
|
|
Älteste Beiträge
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
|
|
<!-- RECHTE SPALTE: INHALT & PAGINATOR -->
|
|
<main class="cat-view-main">
|
|
<div class="cat-view-header">
|
|
<h1 class="cat-view-title">Kategorie: <?php echo (isset($category) && !empty($category)) ? htmlspecialchars($category) : 'Unbekannt'; ?></h1>
|
|
<p class="cat-view-meta-text">
|
|
<?php echo (isset($totalArticles)) ? $totalArticles : 0; ?> Treffer in dieser Kategorie
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Beiträge -->
|
|
<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">
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<p style="margin: 0; color: #4a5568;">
|
|
<?php echo (isset($article) && !empty($article->getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>
|
|
</p>
|
|
</div>
|
|
<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>
|
|
|
|
<!-- Footer Paginator -->
|
|
<?php if (isset($totalPages) && $totalPages > 1): ?>
|
|
<div class="cat-view-pagination-footer">
|
|
<div></div>
|
|
<div class="s-res-page-navigation">
|
|
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage - 1; ?>" <?php echo ($currentPage <= 1) ? 'disabled' : ''; ?>>
|
|
«
|
|
</button>
|
|
|
|
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
|
<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; ?>
|
|
|
|
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage + 1; ?>" <?php echo ($currentPage >= $totalPages) ? 'disabled' : ''; ?>>
|
|
»
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
</div>
|
|
</form>
|