From 3b2ed78c1c23b29d9340a7c792cbac0dc56c7209 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 16:16:14 +0200 Subject: [PATCH 01/16] Update showCategory.php --- content/showCategory.php | 208 ++++++++++++++++++++++++++++++++++----- 1 file changed, 185 insertions(+), 23 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index a684f21..c3625a2 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -1,32 +1,194 @@ + +if(isset($articles)){ + $totalResultsCount = count($articles); + + $limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10; + if (!in_array($limit, [10, 20, 50, 100])) { + $limit = 10; + } + +// Gesamtseitenzahl + $totalPages = max(1, ceil($totalResultsCount / $limit)); + +// Aktuelle Seite auslesen und validieren + $currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1; + if ($currentPage < 1) { + $currentPage = 1; + } elseif ($currentPage > $totalPages) { + $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 = $articles; + $resultCount = count($results); +} + +?> + + +
-

+ + + +
+ +
+

Suchergebnisse

+

Treffer für Ihre Suchanfrage ""

+
+ + +
+ + + +
+
+

+ + + +

+
+

Von:

+ + + ❤️ + +
+
+
+
+ + + +

Keine Beiträge zu diesem Suchbegriff gefunden.

+ +

Unzulässige Suchanfrage

+ + + + +
+ +
+ +
From 16cfa92721a681b01a2a0b17bdcebe174a89f79c Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 16:29:11 +0200 Subject: [PATCH 02/16] Update showCategory.php --- content/showCategory.php | 58 ---------------------------------------- 1 file changed, 58 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index c3625a2..672583f 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -53,12 +53,6 @@ if(isset($articles)){ -
-

Suche anpassen

- - -
-

Sortierung

@@ -81,51 +75,11 @@ if(isset($articles)){
- -
-

Kategorie filtern

- -
-
- -
-

Suchergebnisse

-

Treffer für Ihre Suchanfrage ""

-
-
- -

Keine Beiträge zu diesem Suchbegriff gefunden.

- -

Unzulässige Suchanfrage

- - - -
- @@ -134,3 +132,4 @@ if(isset($articles)){
+ From dca716ddc594034e4ffbc9ad5d96dcbcf9fcae36 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 16:59:34 +0200 Subject: [PATCH 04/16] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index e14bd7e..1410e08 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -1,21 +1,41 @@ 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(); } -?> \ No newline at end of file +?> From 1dd128d4803507467d35f528684f86d949e24f47 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 16:59:36 +0200 Subject: [PATCH 05/16] Update showCategory.php --- content/showCategory.php | 168 +++++++++++---------------------------- 1 file changed, 47 insertions(+), 121 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index feb95ba..554c4a2 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -1,135 +1,61 @@ - + +

Kategorie:

- $limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10; - if (!in_array($limit, [10, 20, 50, 100])) { - $limit = 10; - } + +
+ + +
+ +

getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>

+

getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>

+
+ + +

Keine Artikel in dieser Kategorie gefunden.

+ +
-// Gesamtseitenzahl - $totalPages = max(1, ceil($totalResultsCount / $limit)); + + 1): ?> +
-// Aktuelle Seite auslesen und validieren - $currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1; - if ($currentPage < 1) { - $currentPage = 1; - } elseif ($currentPage > $totalPages) { - $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 = $articles; - $resultCount = count($results); -} else { - echo "fehler"; -} - -?> - - -
- - - - - -
- -
- - - -
-
-

- - - -

-
-

Von:

- - - ❤️ - -
-
-
-
- - -
- -
- + +
- From 958ee1c1f55f41bc145f7b1cde015ab9e830a0d1 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:02:11 +0200 Subject: [PATCH 06/16] Update showCategory.php css --- content/showCategory.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index 554c4a2..44d1d43 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -11,7 +11,6 @@ include_once "php/controller/showCategory-controller.php";
-

getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>

getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>

@@ -21,7 +20,7 @@ include_once "php/controller/showCategory-controller.php"; - + 1): ?>
@@ -29,19 +28,19 @@ include_once "php/controller/showCategory-controller.php"; - + - +
- + - + From c0d8fdede6a824fcecb77c61df0b77a3a28dad92 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:04:54 +0200 Subject: [PATCH 07/16] Update showCategory.php --- content/showCategory.php | 92 +++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index 44d1d43..279c69d 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -2,59 +2,73 @@ include_once "php/controller/showCategory-controller.php"; ?> -
- -

Kategorie:

+
+
+ +

Kategorie:

+
- -
+ +
-
-

getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>

-

getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>

-
+
+
+

+ getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?> +

+

+ getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?> +

+
+
+
-

Keine Artikel in dieser Kategorie gefunden.

+

Keine Artikel in dieser Kategorie gefunden.

- + 1): ?> - +
+ From 82e8c8a1a3c50632b9dc8bb42c01675c9b41b9f7 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:08:02 +0200 Subject: [PATCH 08/16] Update showCategory.php --- content/showCategory.php | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index 279c69d..5821942 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -4,23 +4,41 @@ include_once "php/controller/showCategory-controller.php";
- +

Kategorie:

+

Beiträge in dieser Kategorie

- +
+

- getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?> + + getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?> +

-

+ + +

+

+ von getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?> +

+ + + ❤ getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?> + +
+ + +

getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>

+
@@ -29,30 +47,22 @@ include_once "php/controller/showCategory-controller.php";
- + 1): ?> - From 535df85cffef24bac45cbc90bb335047c48b3eb8 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:11:38 +0200 Subject: [PATCH 09/16] neue showCategory.css --- css/showCategory.css | 157 +++++++++++++++++++++++++++++++++++++++++++ index.php | 1 + 2 files changed, 158 insertions(+) create mode 100644 css/showCategory.css diff --git a/css/showCategory.css b/css/showCategory.css new file mode 100644 index 0000000..0e97b18 --- /dev/null +++ b/css/showCategory.css @@ -0,0 +1,157 @@ +/* --- NEUES LAYOUT FÜR KATEGORIEN --- */ +.cat-view-container { + min-width: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; + color: #212529; + line-height: 1.5; +} + +.cat-view-header { + margin-bottom: 2rem; + border-bottom: 2px solid #dee2e6; + padding-bottom: 1rem; +} + +.cat-view-title { + font-size: 2rem; + color: #1a202c; + margin: 0 0 0.5rem 0; + font-weight: 700; +} + +.cat-view-meta-text { + color: #6c757d; + font-size: 0.95rem; + margin: 0; +} + +/* --- LISTE DER BEITRÄGE --- */ +.cat-view-list { + display: flex; + flex-direction: column; + gap: 1rem; +} + +/* Einzelne Beitrags-Box */ +.cat-view-item { + background-color: #ffffff; + border: 1px solid #e2e8f0; + border-radius: 8px; + padding: 1.25rem; + display: flex; + justify-content: space-between; + align-items: center; + transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; +} + +.cat-view-item:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); + border-color: #cbd5e1; +} + +.cat-view-content { + flex: 1; +} + +.cat-view-item-title { + font-size: 1.25rem; + margin: 0 0 0.25rem 0; + font-weight: 600; +} + +.cat-view-link { + color: #3182ce; + text-decoration: none; + transition: color 0.2s ease; +} + +.cat-view-link:hover { + text-decoration: underline; + color: #2b6cb0; +} + +/* Meta-Zeile für Autor & Likes */ +.cat-view-meta-row { + display: flex; + gap: 15px; + align-items: center; + margin-bottom: 0.5rem; +} + +.cat-view-author { + font-size: 0.875rem; + color: #4a5568; + margin: 0; +} + +.cat-view-author-name { + font-weight: 600; + color: #2d3748; +} + +.cat-view-likes { + font-size: 0.9em; + color: #475569; +} + +.cat-view-arrow { + font-size: 1.5rem; + color: #a0aec0; + padding-left: 1rem; + transition: color 0.2s ease, transform 0.2s ease; +} + +.cat-view-item:hover .cat-view-arrow { + color: #3182ce; + transform: translateX(3px); +} + +/* --- PAGINATOR FOOTER --- */ +.cat-view-pagination-footer { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 2rem; + padding-top: 1.5rem; + border-top: 1px solid #e2e8f0; +} + +/* Styling der Buttons (Zugeordnet zu den JS-Klassen) */ +.cat-view-pagination-footer .s-res-page-navigation { + display: flex; + gap: 0.25rem; +} + +.cat-view-pagination-footer .s-res-page-btn { + background-color: #ffffff; + border: 1px solid #cbd5e1; + color: #4a5568; + padding: 0.35rem 0.75rem; + font-size: 0.9rem; + font-weight: 500; + border-radius: 4px; + cursor: pointer; + transition: all 0.2s ease; +} + +.cat-view-pagination-footer .s-res-page-btn:hover:not(:disabled) { + background-color: #f8f9fa; + border-color: #cbd5e1; + color: #2d3748; +} + +/* Aktiver Button-Zustand */ +.cat-view-pagination-footer .cat-active-btn { + background-color: #3182ce; + border-color: #3182ce; + color: #ffffff; + cursor: default; +} + +.cat-view-pagination-footer .s-res-page-btn:disabled:not(.cat-active-btn) { + background-color: #f1f5f9; + border-color: #e2e8f0; + color: #94a3b8; + cursor: not-allowed; +} diff --git a/index.php b/index.php index ba19ad2..c9a5cfb 100644 --- a/index.php +++ b/index.php @@ -63,6 +63,7 @@ if ($pfad === "deleteAccount") { + From f77f09ec6f380b6f6194183eb6a48d3a710069e6 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:11:40 +0200 Subject: [PATCH 10/16] Update showCategory.php --- content/showCategory.php | 53 ++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index 5821942..6cbd6d0 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -2,54 +2,53 @@ include_once "php/controller/showCategory-controller.php"; ?> -
-
- -

Kategorie:

-

Beiträge in dieser Kategorie

+
+
+ +

Kategorie:

+

Beiträge in dieser Kategorie

-
+
-
-
- -

- +
+
+ +

+ getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?>

- -
-

- von getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?> + +

+

+ von getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?>

- - + getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?>
-

+

getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?>

- -
+ +
-

Keine Artikel in dieser Kategorie gefunden.

+

Keine Artikel in dieser Kategorie gefunden.

- + 1): ?> -
From 53bee088339b76bf6823b3eb89e4cf44fb2b763d Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:16:42 +0200 Subject: [PATCH 13/16] Update showCategory.php --- content/showCategory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index 2c70061..d78afbb 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -31,7 +31,7 @@ include_once "php/controller/showCategory-controller.php"; ❤️ getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?>

- +
@@ -58,7 +58,7 @@ include_once "php/controller/showCategory-controller.php"; @@ -74,7 +74,7 @@ include_once "php/controller/showCategory-controller.php";
From a712f5a9936df193c8f63e09efb5e2630561445c Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:17:38 +0200 Subject: [PATCH 14/16] Update showCategory.css --- css/showCategory.css | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/css/showCategory.css b/css/showCategory.css index 0e97b18..575920b 100644 --- a/css/showCategory.css +++ b/css/showCategory.css @@ -1,9 +1,19 @@ /* --- NEUES LAYOUT FÜR KATEGORIEN --- */ .cat-view-container { - min-width: 0; + box-sizing: border-box; + max-width: 95%; + width: 95%; + margin: 2rem auto; + padding: 0 1rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #212529; line-height: 1.5; + min-width: 0; +} + +/* Verhindert Verzerren durch globale Styles im inneren Bereich */ +.cat-view-container * { + box-sizing: border-box; } .cat-view-header { @@ -155,3 +165,17 @@ color: #94a3b8; cursor: not-allowed; } + +/* Responsive Anpassungen unter 768px (Smartphones) */ +@media (max-width: 768px) { + .cat-view-container { + margin: 1rem auto; + width: 100%; + max-width: 100%; + } + .cat-view-pagination-footer { + flex-direction: column; + gap: 1rem; + align-items: flex-start; + } +} From bb2c368b1fb978d60baa38f86cd7701e2dce9992 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:20:54 +0200 Subject: [PATCH 15/16] Seitenleiste --- content/showCategory.php | 171 ++++++++++++--------- css/showCategory.css | 76 +++++++-- php/controller/showCategory-controller.php | 31 +++- 3 files changed, 186 insertions(+), 92 deletions(-) diff --git a/content/showCategory.php b/content/showCategory.php index d78afbb..a9f1489 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -1,83 +1,110 @@ -
-
- -

Kategorie:

-

Beiträge in dieser Kategorie

-
+ +
+ + + - -
- - -
-
- -

- - getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?> - -

+
- -
-

- von getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?> -

- - ❤️ getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?> - + + + + +
+
+

Kategorie:

+

+ Treffer in dieser Kategorie +

+
+ + +
+ + +
+
+

+ + getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?> + +

+ +
+

+ von getAuthor())) ? htmlspecialchars($article->getAuthor()) : 'Anonym'; ?> +

+ + ❤️ getLikes())) ? htmlspecialchars($article->getLikes()) : '0'; ?> + +
+ +

+ getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?> +

+
+
+ + +

Keine Artikel in dieser Kategorie gefunden.

+ +
-
- -
-
- - -

Keine Artikel in dieser Kategorie gefunden.

- -
- - - 1): ?> - - -
- -
+ + + +
+ diff --git a/css/showCategory.css b/css/showCategory.css index 575920b..f6e1835 100644 --- a/css/showCategory.css +++ b/css/showCategory.css @@ -1,21 +1,72 @@ -/* --- NEUES LAYOUT FÜR KATEGORIEN --- */ +/* --- ZWEISPALTIIGES GRID-LAYOUT --- */ .cat-view-container { box-sizing: border-box; - max-width: 95%; + max-width: 95%; /* 95% Monitorbreite wie das Original */ width: 95%; - margin: 2rem auto; + margin: 2rem auto; padding: 0 1rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #212529; line-height: 1.5; - min-width: 0; + + /* Grid für die Zweispaltigkeit */ + display: grid; + grid-template-columns: 320px 1fr; /* 320px Sidebar, Rest für Content */ + gap: 2.5rem; } -/* Verhindert Verzerren durch globale Styles im inneren Bereich */ .cat-view-container * { box-sizing: border-box; } +/* --- SEITENLEISTE (SORTIERUNG) --- */ +.cat-sidebar { + display: flex; + flex-direction: column; + gap: 1.5rem; +} + +.cat-sidebar-box { + background-color: #ffffff; + border: 1px solid #e2e8f0; + border-radius: 8px; + padding: 1.25rem; +} + +.cat-sidebar-title { + font-size: 1rem; + font-weight: 700; + color: #1a202c; + margin: 0 0 1rem 0; + text-transform: uppercase; + letter-spacing: 0.05em; +} + +.cat-filter-group { + display: flex; + flex-direction: column; + gap: 0.75rem; +} + +.cat-filter-option { + display: flex; + align-items: center; + gap: 0.5rem; + cursor: pointer; + font-size: 0.95rem; + color: #4a5568; +} + +.cat-filter-option input[type="radio"] { + margin: 0; + accent-color: #3182ce; +} + +/* --- HAUPTINHALT --- */ +.cat-view-main { + min-width: 0; +} + .cat-view-header { margin-bottom: 2rem; border-bottom: 2px solid #dee2e6; @@ -35,14 +86,13 @@ margin: 0; } -/* --- LISTE DER BEITRÄGE --- */ +/* --- BEITRÄGE LISTE --- */ .cat-view-list { display: flex; flex-direction: column; gap: 1rem; } -/* Einzelne Beitrags-Box */ .cat-view-item { background-color: #ffffff; border: 1px solid #e2e8f0; @@ -73,7 +123,6 @@ .cat-view-link { color: #3182ce; text-decoration: none; - transition: color 0.2s ease; } .cat-view-link:hover { @@ -81,7 +130,6 @@ color: #2b6cb0; } -/* Meta-Zeile für Autor & Likes */ .cat-view-meta-row { display: flex; gap: 15px; @@ -117,7 +165,7 @@ transform: translateX(3px); } -/* --- PAGINATOR FOOTER --- */ +/* --- FOOTER PAGINATION --- */ .cat-view-pagination-footer { display: flex; justify-content: space-between; @@ -127,7 +175,6 @@ border-top: 1px solid #e2e8f0; } -/* Styling der Buttons (Zugeordnet zu den JS-Klassen) */ .cat-view-pagination-footer .s-res-page-navigation { display: flex; gap: 0.25rem; @@ -151,7 +198,6 @@ color: #2d3748; } -/* Aktiver Button-Zustand */ .cat-view-pagination-footer .cat-active-btn { background-color: #3182ce; border-color: #3182ce; @@ -166,12 +212,12 @@ cursor: not-allowed; } -/* Responsive Anpassungen unter 768px (Smartphones) */ +/* RESPONSIVE ANPASSUNG (Unter 768px) */ @media (max-width: 768px) { .cat-view-container { + grid-template-columns: 1fr; /* Stapelt Sidebar und Inhalt untereinander */ + gap: 1.5rem; margin: 1rem auto; - width: 100%; - max-width: 100%; } .cat-view-pagination-footer { flex-direction: column; diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 1410e08..df2f1ca 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -10,19 +10,40 @@ require_once 'php/validator/article-validator.php'; if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){ $category = $_GET["category"]; + // Sortierung auslesen (Standard: alphabet) + $sortStyle = isset($_GET['sort']) ? trim($_GET['sort']) : 'alphabet'; + + // Aktuelle Seite auslesen $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) { $page = 1; } try { $articleManager = ArticleManager::getInstance(); - $allArticles = $articleManager->getArticlesByCategory($category); + $totalArticles = count($allArticles); + + // --- SORTIERUNG LOGIK --- + if ($sortStyle === 'alphabet') { + usort($allArticles, function($a, $b) { + return strcasecmp($a->getTitle(), $b->getTitle()); + }); + } elseif ($sortStyle === 'likes') { + usort($allArticles, function($a, $b) { + return $b->getLikes() <=> $a->getLikes(); // Absteigend nach Likes + }); + } elseif ($sortStyle === 'newest') { + usort($allArticles, function($a, $b) { + return strtotime($b->getCreationDate()) <=> strtotime($a->getCreationDate()); // Neueste zuerst + }); + } elseif ($sortStyle === 'oldest') { + usort($allArticles, function($a, $b) { + return strtotime($a->getCreationDate()) <=> strtotime($b->getCreationDate()); // Älteste zuerst + }); + } // Paginierung konfigurieren - $limit = 10; // Wie viele Artikel pro Seite? - $totalArticles = count($allArticles); + $limit = 10; $totalPages = ceil($totalArticles / $limit); - if ($page > $totalPages && $totalPages > 0) { $page = $totalPages; } $offset = ($page - 1) * $limit; @@ -38,4 +59,4 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali include_once "content/404.php"; exit(); } -?> +?> \ No newline at end of file From 0d009262b63525d0155ca9d1886253abd1f97b84 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Fri, 17 Jul 2026 17:27:16 +0200 Subject: [PATCH 16/16] Update showCategory.php --- content/showCategory.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/showCategory.php b/content/showCategory.php index a9f1489..89aa42a 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -5,6 +5,10 @@ $currentSort = isset($sortStyle) ? $sortStyle : 'alphabet'; $currentPage = isset($page) ? $page : 1; ?> + +