From e772a8b57f4b06deeeb2b9ecb0a2c1dc50920138 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:29:29 +0200 Subject: [PATCH 01/21] Kategorien nicht statisch sondern dynamisch --- content/home.php | 5 + content/showCategory.php | 33 +++++++ includes/navbar.php | 104 ++++++++++----------- php/controller/showCategory-controller.php | 20 ++++ php/model/ArticleManager.php | 21 +++++ php/model/ArticleManagerDAO.php | 7 ++ 6 files changed, 138 insertions(+), 52 deletions(-) create mode 100644 content/showCategory.php create mode 100644 php/controller/showCategory-controller.php diff --git a/content/home.php b/content/home.php index 58e0993..878295a 100644 --- a/content/home.php +++ b/content/home.php @@ -17,6 +17,11 @@ include_once 'php/controller/home-controller.php'; Dein Beitrag wurde erfolgreich veröffentlicht!

+ +

+ Diese Kategorie ist nicht gültig. +

+ diff --git a/content/showCategory.php b/content/showCategory.php new file mode 100644 index 0000000..e07c14f --- /dev/null +++ b/content/showCategory.php @@ -0,0 +1,33 @@ + + +
+ +

+ +
+ + +
+
+

+ + + +

+

Von:

+
+
+
+ + + +

Es sind noch keine Beiträge in dieser Kategorie enthalten.

+ +
+ +
\ No newline at end of file diff --git a/includes/navbar.php b/includes/navbar.php index b233584..2beb981 100644 --- a/includes/navbar.php +++ b/includes/navbar.php @@ -39,50 +39,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
  • @@ -92,50 +92,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php new file mode 100644 index 0000000..59dda14 --- /dev/null +++ b/php/controller/showCategory-controller.php @@ -0,0 +1,20 @@ +getArticlesByCategory($category); + } catch (Exception $e) { + $_SESSION["message"] = "internal_error"; + header("location: ../../index.php"); + exit(); + } +}else{ + $_SESSION["message"] = "invalid_category"; + header("location: ../../index.php"); + exit(); +} +?> \ No newline at end of file diff --git a/php/model/ArticleManager.php b/php/model/ArticleManager.php index 5887cc5..45325e0 100644 --- a/php/model/ArticleManager.php +++ b/php/model/ArticleManager.php @@ -44,5 +44,26 @@ class ArticleManager extends LocalArticleManager return $articleManager; } + + public function getArticlesByCategory($category) + { + $articles = $this->getAllArticles(); + $filteredArticles = []; + + foreach ($articles as $article) { + if (isset($article['category']) && $article['category'] == $category) { + $filteredArticles[] = new Article( + intval($article['id']), + $article['title'], + $article['content'], + $article['author'], + $article['category'], + $article['tags'], + $article['creationDate'] + ); + } + } + return $filteredArticles; + } } \ No newline at end of file diff --git a/php/model/ArticleManagerDAO.php b/php/model/ArticleManagerDAO.php index 191b21a..d33df23 100644 --- a/php/model/ArticleManagerDAO.php +++ b/php/model/ArticleManagerDAO.php @@ -85,6 +85,13 @@ interface ArticleManagerDAO */ public function search(string $keyword): array; + /** + * Gibt alle Beiträge einer gegebenen Kategorie aus. + * @param $category + * @return mixed + */ + public function getArticlesByCategory($category); + } ?> \ No newline at end of file From e35d07ebc3487d294d8520c4efb6f29ab52ece1d Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:33:02 +0200 Subject: [PATCH 02/21] Update LocalArticleManager.php --- php/model/LocalArticleManager.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/php/model/LocalArticleManager.php b/php/model/LocalArticleManager.php index 78a751c..07af019 100644 --- a/php/model/LocalArticleManager.php +++ b/php/model/LocalArticleManager.php @@ -200,6 +200,27 @@ class LocalArticleManager implements ArticleManagerDAO { return $filteredArticles; } + + public function getArticlesByCategory($category) + { + $articles = $this->getAllArticles(); + $filteredArticles = []; + + foreach ($articles as $article) { + if (isset($article['category']) && $article['category'] == $category) { + $filteredArticles[] = new Article( + intval($article['id']), + $article['title'], + $article['content'], + $article['author'], + $article['category'], + $article['tags'], + $article['creationDate'] + ); + } + } + return $filteredArticles; + } } ?> \ No newline at end of file From 18fe69cbcd34b409e852017f135496f03ca05383 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:34:48 +0200 Subject: [PATCH 03/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 59dda14..73f4258 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -9,12 +9,12 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali $articles = $articleManager->getArticlesByCategory($category); } catch (Exception $e) { $_SESSION["message"] = "internal_error"; - header("location: ../../index.php"); + include_once "content/404.php"; exit(); } }else{ $_SESSION["message"] = "invalid_category"; - header("location: ../../index.php"); + include_once "content/404.php"; exit(); } ?> \ No newline at end of file From ded98ed75712aeda47bf0a9f5d7e713229750dee Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:34:51 +0200 Subject: [PATCH 04/21] Update LocalArticleManager.php --- php/model/LocalArticleManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/model/LocalArticleManager.php b/php/model/LocalArticleManager.php index 07af019..2ee8ce9 100644 --- a/php/model/LocalArticleManager.php +++ b/php/model/LocalArticleManager.php @@ -200,7 +200,7 @@ class LocalArticleManager implements ArticleManagerDAO { return $filteredArticles; } - + public function getArticlesByCategory($category) { $articles = $this->getAllArticles(); From e28620d9fb75f03cfa779347741a89e27c91f295 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:35:13 +0200 Subject: [PATCH 05/21] debugging --- php/controller/showCategory-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 73f4258..47796a5 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -6,7 +6,7 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali $category = $_GET["category"]; try { $articleManager = ArticleManager::getInstance(); - $articles = $articleManager->getArticlesByCategory($category); + //$articles = $articleManager->getArticlesByCategory($category); } catch (Exception $e) { $_SESSION["message"] = "internal_error"; include_once "content/404.php"; From a08197cc10ea48d53b609f19e4ca99b7e31a9217 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:36:22 +0200 Subject: [PATCH 06/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 47796a5..a9f7cb5 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -1,6 +1,7 @@ Date: Wed, 3 Jun 2026 19:36:49 +0200 Subject: [PATCH 07/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index a9f7cb5..de949fa 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -5,6 +5,7 @@ require_once '../validator/article-validator.php'; if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){ $category = $_GET["category"]; + echo "

    $category

    "; try { $articleManager = ArticleManager::getInstance(); //$articles = $articleManager->getArticlesByCategory($category); From b9c86e2074df801d4e60f6135aeb7b404dddf851 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:37:36 +0200 Subject: [PATCH 08/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index de949fa..4868592 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -3,6 +3,7 @@ require_once '../model/LocalArticleManager.php'; require_once '../model/ArticleManager.php'; require_once '../validator/article-validator.php'; +echo $_GET["category"]; if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){ $category = $_GET["category"]; echo "

    $category

    "; From 9349b91926cfbe297e1f81455e69e4277e61ef59 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:39:46 +0200 Subject: [PATCH 09/21] Update showCategory.php --- content/showCategory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/content/showCategory.php b/content/showCategory.php index e07c14f..6c07282 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -1,5 +1,4 @@ From 86fb37abc4e3f141e14b65742407fb62301a852d Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:39:48 +0200 Subject: [PATCH 10/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 4868592..3078197 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -1,15 +1,13 @@ $category"; try { $articleManager = ArticleManager::getInstance(); - //$articles = $articleManager->getArticlesByCategory($category); + $articles = $articleManager->getArticlesByCategory($category); } catch (Exception $e) { $_SESSION["message"] = "internal_error"; include_once "content/404.php"; From 46cd524f70e742cc819bd6b24c5d2971b4ee6033 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:43:40 +0200 Subject: [PATCH 11/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 3078197..6799392 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -1,7 +1,7 @@ Date: Wed, 3 Jun 2026 19:43:41 +0200 Subject: [PATCH 12/21] Update showCategory.php --- content/showCategory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/content/showCategory.php b/content/showCategory.php index 6c07282..a535c26 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -22,7 +22,6 @@ include_once "php/controller/showCategory-controller.php";
    -

    Es sind noch keine Beiträge in dieser Kategorie enthalten.

    From bac4334fb8b5e1729c3302608d18dd67f41284a0 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:44:47 +0200 Subject: [PATCH 13/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 6799392..e14bd7e 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -1,5 +1,5 @@ Date: Wed, 3 Jun 2026 19:46:25 +0200 Subject: [PATCH 14/21] Update 404.php --- content/404.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/content/404.php b/content/404.php index 6bb7201..4613a62 100644 --- a/content/404.php +++ b/content/404.php @@ -4,6 +4,14 @@ -->
    + +

    + Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut. +

    + +

    404 - Seite nicht vorhanden

    Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden. From a175765e33077c0c4021a3180d5fe8766dcd8074 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:49:45 +0200 Subject: [PATCH 15/21] Update main.css --- css/main.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/css/main.css b/css/main.css index d2ceeb6..79d5bf0 100644 --- a/css/main.css +++ b/css/main.css @@ -22,6 +22,10 @@ a, button, input, select, textarea, label, main{ font-family: Arial, Helvetica, sans-serif; } +h1 { + text-transform: uppercase; +} + .flexbox { display: flex; flex-direction: row; From 48501a9069b7a02698cabd8eccdd762c29671622 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:51:06 +0200 Subject: [PATCH 16/21] Update ArticleManager.php --- php/model/ArticleManager.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/php/model/ArticleManager.php b/php/model/ArticleManager.php index 45325e0..5887cc5 100644 --- a/php/model/ArticleManager.php +++ b/php/model/ArticleManager.php @@ -44,26 +44,5 @@ class ArticleManager extends LocalArticleManager return $articleManager; } - - public function getArticlesByCategory($category) - { - $articles = $this->getAllArticles(); - $filteredArticles = []; - - foreach ($articles as $article) { - if (isset($article['category']) && $article['category'] == $category) { - $filteredArticles[] = new Article( - intval($article['id']), - $article['title'], - $article['content'], - $article['author'], - $article['category'], - $article['tags'], - $article['creationDate'] - ); - } - } - return $filteredArticles; - } } \ No newline at end of file From cdccb0bfe81719a88f6e4d20dc43a9943c7bcbc7 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:51:58 +0200 Subject: [PATCH 17/21] debugging --- php/controller/showCategory-controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index e14bd7e..2f0678f 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -8,6 +8,7 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali try { $articleManager = ArticleManager::getInstance(); $articles = $articleManager->getArticlesByCategory($category); + echo $articles[0]->getTitle(); } catch (Exception $e) { $_SESSION["message"] = "internal_error"; include_once "content/404.php"; From a7f1729e6efdaf96c05cb5a4967d04c6abd58295 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:56:12 +0200 Subject: [PATCH 18/21] Update ArticleManager.php --- php/model/ArticleManager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php/model/ArticleManager.php b/php/model/ArticleManager.php index 5887cc5..8962aa3 100644 --- a/php/model/ArticleManager.php +++ b/php/model/ArticleManager.php @@ -19,7 +19,7 @@ class ArticleManager extends LocalArticleManager "Satz des Pythagoras", "Der Satz des Pythagoras wurde von dem griechischen Philosophen Pythagoras von Samos formuliert und im dritten Jahrhundert vor Christus veröffentlicht. In der beigefügten Abbildung sehen wir ein rechtwinkliges Dreieck...", "max.mustermann", - "Mathe", + "mathe", "Dreiecke, Dreiecksseiten berechnen" ); } @@ -28,7 +28,7 @@ class ArticleManager extends LocalArticleManager "Tunneleffekt", "Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...", "max.mustermann", - "Physik", + "physik", "Quantenphysik, Energie" ); } @@ -37,7 +37,7 @@ class ArticleManager extends LocalArticleManager "Datenschutz vs Datensicherheit", "Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...", "max.mustermann", - "Informatik", + "informatik", "Daten, DSGVO" ); } From 2a3a15c92de9c79cf55d6479d1e0177c88ecd0ab Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:58:05 +0200 Subject: [PATCH 19/21] 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 a535c26..46594ab 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -13,11 +13,11 @@ include_once "php/controller/showCategory-controller.php";

    - - + + getTitle()); ?>

    -

    Von:

    +

    Von: getAuthor()); ?>

    From 7269ea03db8003ef5502136faa5ce98cc08db8b3 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 19:58:09 +0200 Subject: [PATCH 20/21] Update showCategory-controller.php --- php/controller/showCategory-controller.php | 1 - 1 file changed, 1 deletion(-) diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index 2f0678f..e14bd7e 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -8,7 +8,6 @@ if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryVali try { $articleManager = ArticleManager::getInstance(); $articles = $articleManager->getArticlesByCategory($category); - echo $articles[0]->getTitle(); } catch (Exception $e) { $_SESSION["message"] = "internal_error"; include_once "content/404.php"; From 9321d09489bb8277324ab2e1927d82a31d98c319 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Wed, 3 Jun 2026 20:00:33 +0200 Subject: [PATCH 21/21] Update home.php --- content/home.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/home.php b/content/home.php index 878295a..518845c 100644 --- a/content/home.php +++ b/content/home.php @@ -39,21 +39,21 @@ include_once 'php/controller/home-controller.php';