Merge branch 'PaginatorOhneJS2' into dev
This commit is contained in:
+96
-75
@@ -2,20 +2,37 @@
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
require_once __DIR__ . '/../includes/resultsHelper.php';
|
||||
|
||||
$all_results = $_SESSION["search_results"] ?? [];
|
||||
$rawResults = $_SESSION["search_results"] ?? [];
|
||||
$query = $_SESSION["search_query"] ?? "";
|
||||
$totalResultsCount = count($all_results);
|
||||
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10;
|
||||
// Sortierung / Kategorie / Limit: GET-Parameter haben Vorrang, sonst
|
||||
// Rückfall auf die zuletzt in der Session gemerkten Werte. So bleibt
|
||||
// z.B. ein reiner Pagination-Link (?page=2) bei der aktuellen
|
||||
// Sortierung/Filterung.
|
||||
$currentSort = $_GET['sort'] ?? ($_SESSION['search_sort'] ?? 'alphabet');
|
||||
if (!in_array($currentSort, ['alphabet', 'likes', 'newest', 'oldest'])) {
|
||||
$currentSort = 'alphabet';
|
||||
}
|
||||
$_SESSION['search_sort'] = $currentSort;
|
||||
|
||||
$currentCategory = strtolower($_GET['category'] ?? ($_SESSION['search_category'] ?? 'all'));
|
||||
$_SESSION['search_category'] = $currentCategory;
|
||||
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : ($_SESSION['search_limit'] ?? 10);
|
||||
if (!in_array($limit, [10, 20, 50, 100])) {
|
||||
$limit = 10;
|
||||
}
|
||||
$_SESSION['search_limit'] = $limit;
|
||||
|
||||
// Gesamtseitenzahl
|
||||
$totalPages = max(1, ceil($totalResultsCount / $limit));
|
||||
// Serverseitig sortieren + filtern
|
||||
$filteredResults = sortSearchResults($rawResults, $currentSort);
|
||||
$filteredResults = filterSearchResultsByCategory($filteredResults, $currentCategory);
|
||||
|
||||
$totalResultsCount = count($filteredResults);
|
||||
$totalPages = max(1, (int)ceil($totalResultsCount / $limit));
|
||||
|
||||
// Aktuelle Seite auslesen und validieren
|
||||
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
if ($currentPage < 1) {
|
||||
$currentPage = 1;
|
||||
@@ -23,42 +40,59 @@ if ($currentPage < 1) {
|
||||
$currentPage = $totalPages;
|
||||
}
|
||||
|
||||
// Startpunkt im Array berechnen (Offset)
|
||||
$offset = ($currentPage - 1) * $limit;
|
||||
|
||||
// Nur die Ergebnisse für die aktuelle Seite ausschneiden
|
||||
//$results = array_slice($all_results, $offset, $limit);
|
||||
$results = $all_results;
|
||||
// Dies ist die No-JS-Basisversion: nur die aktuelle Seite wird gerendert.
|
||||
// Bei aktiviertem JS lädt js/results-app.js zusätzlich den kompletten
|
||||
// Datensatz nach (ein einziger Request) und übernimmt Sortierung, Filter
|
||||
// und Pagination danach komplett im Browser, ohne weitere Serveranfragen.
|
||||
$results = array_slice($filteredResults, $offset, $limit);
|
||||
$resultCount = count($results);
|
||||
|
||||
// Kategorien für das Auswahlfeld (Wert => Label)
|
||||
$categories = [
|
||||
'Deutsch' => 'Deutsch', 'Englisch' => 'Englisch', 'Franzoesisch' => 'Französisch',
|
||||
'Latein' => 'Latein', 'Literatur' => 'Literatur', 'Mathematik' => 'Mathematik',
|
||||
'Biologie' => 'Biologie', 'Informatik' => 'Informatik', 'Chemie' => 'Chemie',
|
||||
'Physik' => 'Physik', 'Astronomie' => 'Astronomie', 'Geschichte' => 'Geschichte',
|
||||
'Erdkunde' => 'Erdkunde', 'Sozialkunde' => 'Sozialkunde', 'Wirtschaftskunde' => 'Wirtschaftskunde',
|
||||
'Religion' => 'Religion', 'Ethikunterricht' => 'Ethikunterricht', 'Philosophie' => 'Philosophie',
|
||||
'Psychologie' => 'Psychologie', 'Kunst' => 'Kunst', 'Musik' => 'Musik', 'Theater' => 'Theater',
|
||||
'Technik' => 'Technik', 'Werken' => 'Werken', 'Hauswirtschaft' => 'Hauswirtschaft', 'Sport' => 'Sport',
|
||||
];
|
||||
?>
|
||||
<noscript>
|
||||
Bitte JavaScript aktivieren!
|
||||
</noscript>
|
||||
<!--
|
||||
Seite: Suchergebnisse
|
||||
Inhalt: Zeigt die Ergebnisse einer Suche an
|
||||
Inhalt: Zeigt die Ergebnisse einer Suche an.
|
||||
Funktioniert ohne JavaScript (serverseitige Sortierung/Filter/Pagination
|
||||
über echte Links + Formulare) und wird bei aktiviertem JS von
|
||||
js/search-results.js vollständig client-seitig übernommen.
|
||||
-->
|
||||
<div class="s-res-layout-grid">
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
<?php include_once "includes/alertMessages.php" ?>
|
||||
|
||||
<!-- Links: Seitenleiste für Filter und Suche -->
|
||||
<aside class="s-res-sidebar">
|
||||
|
||||
<!-- Sortierfuntion Box und Such Box-->
|
||||
<!-- Formular 1: startet eine NEUE Suche (löst immer einen Server-Request aus) -->
|
||||
<form action="php/controller/search-results-controller.php" method="GET" id="search-form-id" class="s-res-sidebar-form">
|
||||
|
||||
<input type="hidden" id="s-res-page-input" name="page" value="<?php echo $_GET['page'] ?? 1; ?>">
|
||||
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" value="<?php echo htmlspecialchars($query); ?>" maxlength="50" required>
|
||||
<button type="submit" class="nav__search-button">Suchen</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Formular 2: sortiert/filtert die BEREITS gefundenen Ergebnisse.
|
||||
Ohne JS: echter Reload dieser Seite, aber ohne erneute Datenbank-Suche.
|
||||
Mit JS: search-results.js übernimmt das live im Browser, der Submit-Button
|
||||
wird dafür nicht benötigt und über <noscript> versteckt. -->
|
||||
<form action="index.php" method="GET" id="s-res-filter-form" class="s-res-sidebar-form">
|
||||
<input type="hidden" name="pfad" value="search-results">
|
||||
<input type="hidden" name="q" value="<?php echo htmlspecialchars($query); ?>">
|
||||
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||
<?php $currentSort = $_SESSION['search_sort'] ?? 'alphabet'; ?>
|
||||
<div class="s-res-filter-group">
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="alphabet" class="sort-radio" <?php echo $currentSort === 'alphabet' ? 'checked' : ''; ?>>
|
||||
@@ -81,37 +115,17 @@ $resultCount = count($results);
|
||||
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Kategorie filtern</h3>
|
||||
<select id="category-filter" class="s-res-limit-select" style="width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1;">
|
||||
<option value="all">Alle Kategorien</option>
|
||||
<option value="Deutsch">Deutsch</option>
|
||||
<option value="Englisch">Englisch</option>
|
||||
<option value="Franzoesisch">Französisch</option>
|
||||
<option value="Latein">Latein</option>
|
||||
<option value="Literatur">Literatur</option>
|
||||
<option value="Mathematik">Mathematik</option>
|
||||
<option value="Biologie">Biologie</option>
|
||||
<option value="Informatik">Informatik</option>
|
||||
<option value="Chemie">Chemie</option>
|
||||
<option value="Physik">Physik</option>
|
||||
<option value="Astronomie">Astronomie</option>
|
||||
<option value="Geschichte">Geschichte</option>
|
||||
<option value="Erdkunde">Erdkunde</option>
|
||||
<option value="Sozialkunde">Sozialkunde</option>
|
||||
<option value="Wirtschaftskunde">Wirtschaftskunde</option>
|
||||
<option value="Religion">Religion</option>
|
||||
<option value="Ethikunterricht">Ethikunterricht</option>
|
||||
<option value="Philosophie">Philosophie</option>
|
||||
<option value="Psychologie">Psychologie</option>
|
||||
<option value="Kunst">Kunst</option>
|
||||
<option value="Musik">Musik</option>
|
||||
<option value="Theater">Theater</option>
|
||||
<option value="Technik">Technik</option>
|
||||
<option value="Werken">Werken</option>
|
||||
<option value="Hauswirtschaft">Hauswirtschaft</option>
|
||||
<option value="Sport">Sport</option>
|
||||
<select id="category-filter" name="category" class="s-res-limit-select" style="width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1;">
|
||||
<option value="all" <?php echo $currentCategory === 'all' ? 'selected' : ''; ?>>Alle Kategorien</option>
|
||||
<?php foreach ($categories as $value => $label): ?>
|
||||
<option value="<?php echo htmlspecialchars($value); ?>" <?php echo $currentCategory === strtolower($value) ? 'selected' : ''; ?>><?php echo htmlspecialchars($label); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<noscript>
|
||||
<button type="submit" class="nav__search-button">Filter anwenden</button>
|
||||
</noscript>
|
||||
</form>
|
||||
|
||||
</aside>
|
||||
@@ -120,18 +134,16 @@ $resultCount = count($results);
|
||||
|
||||
<div class="s-res-header">
|
||||
<h1 class="s-res-main-title">Suchergebnisse</h1>
|
||||
<p class="s-res-meta"><?php echo $totalResultsCount; ?> Treffer für Ihre Suchanfrage "<?php echo htmlspecialchars($query); ?>"</p>
|
||||
<p class="s-res-meta"><span id="s-res-result-count"><?php echo $totalResultsCount; ?></span> Treffer für Ihre Suchanfrage "<?php echo htmlspecialchars($query); ?>"</p>
|
||||
</div>
|
||||
|
||||
<!-- Ergebnisliste -->
|
||||
<div class="s-res-list">
|
||||
<?php
|
||||
if (!empty($results)): ?>
|
||||
|
||||
<?php foreach ($results as $item):
|
||||
// Anzahl der Likes ermitteln (falls es ein Array ist, zählen; falls Zahl, direkt nutzen)
|
||||
$likesCount = isset($item['likes']) && is_array($item['likes']) ? count($item['likes']) : ($item['likes'] ?? 0);
|
||||
?>
|
||||
<?php if (!empty($results)): ?>
|
||||
|
||||
<?php foreach ($results as $item):
|
||||
$likesCount = getLikeCount($item);
|
||||
?>
|
||||
<div class="s-res-item" data-likes="<?php echo $likesCount; ?>" data-category="<?php echo strtolower($item['category'] ?? ''); ?>">
|
||||
<div class="s-res-content">
|
||||
<h2 class="s-res-item-title">
|
||||
@@ -151,41 +163,50 @@ $resultCount = count($results);
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php
|
||||
elseif (isset($_SESSION["search_query"]) && $_SESSION["search_query"] !== "" && $resultCount === 0): ?>
|
||||
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
||||
<?php
|
||||
elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_search_query"): ?>
|
||||
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] === "invalid_search_query"): ?>
|
||||
<p>Unzulässige Suchanfrage</p>
|
||||
|
||||
|
||||
<?php elseif ($query !== "" && $totalResultsCount === 0 && count($rawResults) > 0): ?>
|
||||
<p>Keine Beiträge in dieser Kategorie gefunden.</p>
|
||||
|
||||
<?php elseif ($query !== "" && $totalResultsCount === 0): ?>
|
||||
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
<?php unset($_SESSION["message"]); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="s-res-pagination-footer">
|
||||
|
||||
<!-- Auswahl der Ergebnisse pro Seite -->
|
||||
<!-- Auswahl der Ergebnisse pro Seite. Gehört per form="..." logisch
|
||||
zum Filterformular oben -->
|
||||
<div class="s-res-limit-selector">
|
||||
<label for="s-res-per-page" class="s-res-limit-label">Ergebnisse pro Seite:</label>
|
||||
<select id="s-res-per-page" name="limit" class="s-res-limit-select">
|
||||
<select id="s-res-per-page" name="limit" form="s-res-filter-form" class="s-res-limit-select">
|
||||
<option value="10" <?php echo $limit === 10 ? 'selected' : ''; ?>>10</option>
|
||||
<option value="20" <?php echo $limit === 20 ? 'selected' : ''; ?>>20</option>
|
||||
<option value="50" <?php echo $limit === 50 ? 'selected' : ''; ?>>50</option>
|
||||
<option value="100" <?php echo $limit === 100 ? 'selected' : ''; ?>>100</option>
|
||||
</select>
|
||||
<noscript><button type="submit" form="s-res-filter-form" class="nav__search-button">Übernehmen</button></noscript>
|
||||
</div>
|
||||
|
||||
<div class="s-res-page-navigation">
|
||||
<button type="button" class="s-res-page-btn" id="prev-page-btn" data-page="0">«</button>
|
||||
|
||||
<span id="dynamic-page-numbers"></span>
|
||||
|
||||
<button type="button" class="s-res-page-btn" id="next-page-btn" data-page="2">»</button>
|
||||
</div>
|
||||
<nav class="s-res-page-navigation" aria-label="Seitennavigation">
|
||||
<!-- No-JS-Fallback: -->
|
||||
<noscript>
|
||||
<?php echo renderNoJsPagination($currentPage, $totalPages, $query, $currentSort, $currentCategory, $limit); ?>
|
||||
</noscript>
|
||||
|
||||
<!-- JS-Version: wird per search-results.js befüllt/eingeblendet: -->
|
||||
<div id="js-page-navigation" style="display:none;">
|
||||
<button type="button" class="s-res-page-btn" id="prev-page-btn">«</button>
|
||||
<span id="dynamic-page-numbers"></span>
|
||||
<button type="button" class="s-res-page-btn" id="next-page-btn">»</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
+160
-87
@@ -1,111 +1,184 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
include_once "php/controller/showCategory-controller.php";
|
||||
require_once __DIR__ . '/../includes/resultsHelper.php';
|
||||
|
||||
$currentSort = isset($sortStyle) ? $sortStyle : 'alphabet';
|
||||
$currentPage = isset($page) ? $page : 1;
|
||||
$rawResults = $_SESSION['category_results'] ?? [];
|
||||
$category = $_SESSION['category_name'] ?? ($_GET['category'] ?? '');
|
||||
|
||||
// Sortierung / Suche / Limit: GET-Parameter haben Vorrang, sonst Rückfall auf
|
||||
// die zuletzt in der Session gemerkten Werte (analog zu search-results.php).
|
||||
$currentSort = $_GET['sort'] ?? ($_SESSION['cat_sort'] ?? 'alphabet');
|
||||
if (!in_array($currentSort, ['alphabet', 'likes', 'newest', 'oldest'])) {
|
||||
$currentSort = 'alphabet';
|
||||
}
|
||||
$_SESSION['cat_sort'] = $currentSort;
|
||||
|
||||
$query = trim($_GET['q'] ?? ($_SESSION['cat_query'] ?? ''));
|
||||
$_SESSION['cat_query'] = $query;
|
||||
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : ($_SESSION['cat_limit'] ?? 10);
|
||||
if (!in_array($limit, [10, 20, 50, 100])) {
|
||||
$limit = 10;
|
||||
}
|
||||
$_SESSION['cat_limit'] = $limit;
|
||||
|
||||
// Serverseitig sortieren + nach Suchbegriff filtern (Kategorie steht bereits fest)
|
||||
$filteredResults = sortSearchResults($rawResults, $currentSort);
|
||||
$filteredResults = filterResultsByQuery($filteredResults, $query);
|
||||
|
||||
$totalResultsCount = count($filteredResults);
|
||||
$totalPages = max(1, (int)ceil($totalResultsCount / $limit));
|
||||
|
||||
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
if ($currentPage < 1) {
|
||||
$currentPage = 1;
|
||||
} elseif ($currentPage > $totalPages) {
|
||||
$currentPage = $totalPages;
|
||||
}
|
||||
|
||||
$offset = ($currentPage - 1) * $limit;
|
||||
|
||||
// Dies ist die No-JS-Basisversion: nur die aktuelle Seite wird gerendert.
|
||||
// Bei aktiviertem JS lädt js/showCategory.js zusätzlich den kompletten
|
||||
// Kategorie-Datensatz nach (ein einziger Request) und übernimmt Sortierung,
|
||||
// Suche und Pagination danach komplett im Browser, ohne weitere Serveranfragen.
|
||||
$results = array_slice($filteredResults, $offset, $limit);
|
||||
$resultCount = count($results);
|
||||
?>
|
||||
<!--
|
||||
Seite: Kategorie-Ansicht
|
||||
Inhalt: Zeigt alle Beiträge einer Kategorie an, sortierbar und innerhalb
|
||||
der Kategorie durchsuchbar.
|
||||
Funktioniert ohne JavaScript (serverseitige Sortierung/Suche/Pagination
|
||||
über echte Links + Formulare) und wird bei aktiviertem JS von
|
||||
js/showCategory.js vollständig client-seitig übernommen.
|
||||
-->
|
||||
<div class="s-res-layout-grid">
|
||||
<?php include_once "includes/alertMessages.php" ?>
|
||||
|
||||
<noscript>
|
||||
Bitte JavaScript aktivieren!
|
||||
</noscript>
|
||||
<!-- Links: Seitenleiste für Suche (innerhalb der Kategorie) und Sortierung -->
|
||||
<aside class="s-res-sidebar">
|
||||
|
||||
<!-- 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; ?>">
|
||||
<!-- Sortiert/durchsucht die BEREITS geladenen Kategorie-Beiträge.
|
||||
Ohne JS: echter Reload dieser Seite, aber ohne erneute Datenbank-Abfrage.
|
||||
Mit JS: js/showCategory.js übernimmt das live im Browser, der Submit-Button
|
||||
wird dafür nicht benötigt und über <noscript> versteckt. -->
|
||||
<form action="index.php" method="GET" id="cat-filter-form" class="s-res-sidebar-form">
|
||||
<input type="hidden" name="pfad" value="showCategory">
|
||||
<input type="hidden" name="category" value="<?php echo htmlspecialchars($category); ?>">
|
||||
|
||||
<div class="cat-view-container">
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">In dieser Kategorie suchen</h3>
|
||||
<input type="search" id="cat-search-input" name="q" placeholder="Suchen..." class="nav__search" value="<?php echo htmlspecialchars($query); ?>" maxlength="50">
|
||||
</div>
|
||||
|
||||
<!-- 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
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||
<div class="s-res-filter-group">
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="alphabet" class="sort-radio" <?php echo $currentSort === 'alphabet' ? 'checked' : ''; ?>>
|
||||
<span>Alphabetisch</span>
|
||||
</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 class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="likes" class="sort-radio" <?php echo $currentSort === 'likes' ? 'checked' : ''; ?>>
|
||||
<span>Beliebtheit (Likes)</span>
|
||||
</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 class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="newest" class="sort-radio" <?php echo $currentSort === 'newest' ? 'checked' : ''; ?>>
|
||||
<span>Neueste Beiträge</span>
|
||||
</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 class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="oldest" class="sort-radio" <?php echo $currentSort === 'oldest' ? 'checked' : ''; ?>>
|
||||
<span>Älteste Beiträge</span>
|
||||
</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>
|
||||
<noscript>
|
||||
<button type="submit" class="nav__search-button">Anwenden</button>
|
||||
</noscript>
|
||||
</form>
|
||||
|
||||
<!-- 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="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'; ?>
|
||||
</a>
|
||||
</h2>
|
||||
</aside>
|
||||
|
||||
<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>
|
||||
|
||||
<main class="s-res-main-content">
|
||||
|
||||
<div class="s-res-header">
|
||||
<h1 class="s-res-main-title">Kategorie: <?php echo htmlspecialchars($category); ?></h1>
|
||||
<p class="s-res-meta">
|
||||
<span id="s-res-result-count"><?php echo $totalResultsCount; ?></span> Treffer in dieser Kategorie<?php echo $query !== '' ? ' für "' . htmlspecialchars($query) . '"' : ''; ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Ergebnisliste -->
|
||||
<div class="s-res-list">
|
||||
<?php if (!empty($results)): ?>
|
||||
|
||||
<?php foreach ($results as $item):
|
||||
$likesCount = getLikeCount($item);
|
||||
?>
|
||||
<div class="s-res-item" data-likes="<?php echo $likesCount; ?>" data-category="<?php echo strtolower($item['category'] ?? ''); ?>">
|
||||
<div class="s-res-content">
|
||||
<h2 class="s-res-item-title">
|
||||
<a href="index.php?pfad=showArticle&id=<?php echo $item['id']; ?>" class="s-res-link">
|
||||
<?php echo htmlspecialchars($item['title']); ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="s-res-meta-row">
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($item['author']); ?></span></p>
|
||||
|
||||
<span class="s-res-likes">
|
||||
❤️ <?php echo $likesCount; ?>
|
||||
</span>
|
||||
</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 class="s-res-arrow">→</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php elseif ($query !== ''): ?>
|
||||
<p>Keine Beiträge in dieser Kategorie zu diesem Suchbegriff gefunden.</p>
|
||||
|
||||
<?php else: ?>
|
||||
<p>Keine Beiträge in dieser Kategorie gefunden.</p>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php unset($_SESSION["message"]); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="s-res-pagination-footer">
|
||||
|
||||
<!-- Auswahl der Ergebnisse pro Seite -->
|
||||
<div class="s-res-limit-selector">
|
||||
<label for="s-res-per-page" class="s-res-limit-label">Ergebnisse pro Seite:</label>
|
||||
<select id="s-res-per-page" name="limit" form="cat-filter-form" class="s-res-limit-select">
|
||||
<option value="10" <?php echo $limit === 10 ? 'selected' : ''; ?>>10</option>
|
||||
<option value="20" <?php echo $limit === 20 ? 'selected' : ''; ?>>20</option>
|
||||
<option value="50" <?php echo $limit === 50 ? 'selected' : ''; ?>>50</option>
|
||||
<option value="100" <?php echo $limit === 100 ? 'selected' : ''; ?>>100</option>
|
||||
</select>
|
||||
<noscript><button type="submit" form="cat-filter-form" class="nav__search-button">Übernehmen</button></noscript>
|
||||
</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>
|
||||
<nav class="s-res-page-navigation" aria-label="Seitennavigation">
|
||||
<!-- No-JS-Fallback: -->
|
||||
<noscript>
|
||||
<?php echo renderNoJsPaginationCategory($currentPage, $totalPages, $category, $currentSort, $query, $limit); ?>
|
||||
</noscript>
|
||||
|
||||
<?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>
|
||||
<!-- JS-Version: wird per js/showCategory.js befüllt/eingeblendet: -->
|
||||
<div id="js-page-navigation" style="display:none;">
|
||||
<button type="button" class="s-res-page-btn" id="prev-page-btn">«</button>
|
||||
<span id="dynamic-page-numbers"></span>
|
||||
<button type="button" class="s-res-page-btn" id="next-page-btn">»</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user