Compare commits

..

22 Commits

Author SHA1 Message Date
niklas.ortmann 7f891b6ebf Merge pull request 'Kategorien nicht statisch sondern dynamisch' (#20) from dynamicCategories into dev
Reviewed-on: #20
2026-06-03 20:15:16 +02:00
niklas.ortmann 9321d09489 Update home.php 2026-06-03 20:00:33 +02:00
niklas.ortmann 7269ea03db Update showCategory-controller.php 2026-06-03 19:58:09 +02:00
niklas.ortmann 2a3a15c92d Update showCategory.php 2026-06-03 19:58:05 +02:00
niklas.ortmann a7f1729e6e Update ArticleManager.php 2026-06-03 19:56:12 +02:00
niklas.ortmann cdccb0bfe8 debugging 2026-06-03 19:51:58 +02:00
niklas.ortmann 48501a9069 Update ArticleManager.php 2026-06-03 19:51:06 +02:00
niklas.ortmann a175765e33 Update main.css 2026-06-03 19:49:45 +02:00
niklas.ortmann 3d57c2e482 Update 404.php 2026-06-03 19:46:25 +02:00
niklas.ortmann bac4334fb8 Update showCategory-controller.php 2026-06-03 19:44:47 +02:00
niklas.ortmann aa3e7c2f36 Update showCategory.php 2026-06-03 19:43:41 +02:00
niklas.ortmann 46cd524f70 Update showCategory-controller.php 2026-06-03 19:43:40 +02:00
niklas.ortmann 86fb37abc4 Update showCategory-controller.php 2026-06-03 19:39:48 +02:00
niklas.ortmann 9349b91926 Update showCategory.php 2026-06-03 19:39:46 +02:00
niklas.ortmann b9c86e2074 Update showCategory-controller.php 2026-06-03 19:37:36 +02:00
niklas.ortmann 68672474e4 Update showCategory-controller.php 2026-06-03 19:36:49 +02:00
niklas.ortmann a08197cc10 Update showCategory-controller.php 2026-06-03 19:36:22 +02:00
niklas.ortmann e28620d9fb debugging 2026-06-03 19:35:13 +02:00
niklas.ortmann ded98ed757 Update LocalArticleManager.php 2026-06-03 19:34:51 +02:00
niklas.ortmann 18fe69cbcd Update showCategory-controller.php 2026-06-03 19:34:48 +02:00
niklas.ortmann e35d07ebc3 Update LocalArticleManager.php 2026-06-03 19:33:02 +02:00
niklas.ortmann e772a8b57f Kategorien nicht statisch sondern dynamisch 2026-06-03 19:29:29 +02:00
9 changed files with 155 additions and 58 deletions
+8
View File
@@ -4,6 +4,14 @@
--> -->
<main> <main>
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
<p class="alert-message is-error">
Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
</p>
<?php endif; ?>
<?php
unset($_SESSION["message"]);
?>
<h1>404 - Seite nicht vorhanden</h1> <h1>404 - Seite nicht vorhanden</h1>
<p> <p>
Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden. Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden.
+8 -3
View File
@@ -17,6 +17,11 @@ include_once 'php/controller/home-controller.php';
Dein Beitrag wurde erfolgreich veröffentlicht! Dein Beitrag wurde erfolgreich veröffentlicht!
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
<p class="alert-message is-error">
Diese Kategorie ist nicht gültig.
</p>
<?php endif; ?>
<?php <?php
unset($_SESSION["message"]); unset($_SESSION["message"]);
?> ?>
@@ -34,21 +39,21 @@ include_once 'php/controller/home-controller.php';
<!-- Flexbox --> <!-- Flexbox -->
<div class="flexbox"> <div class="flexbox">
<div class="container"> <div class="container">
<a href="index.php?pfad=informatik" class="category-link">Informatik</a> <a href="index.php?pfad=showCategory&category=informatik" class="category-link">Informatik</a>
<div class="article-link"> <div class="article-link">
<a href="index.php?pfad=showArticle&id=<?php echo $dummy3->getId()?>"><?php if(isset($dummy3)){echo $dummy3->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a> <a href="index.php?pfad=showArticle&id=<?php echo $dummy3->getId()?>"><?php if(isset($dummy3)){echo $dummy3->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<a href="index.php?pfad=mathe" class="category-link">Mathe</a> <a href="index.php?pfad=showCategory&category=mathe" class="category-link">Mathe</a>
<div class="article-link"> <div class="article-link">
<a href="index.php?pfad=showArticle&id=<?php echo $dummy1->getId()?>"><?php if(isset($dummy1)){echo $dummy1->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a> <a href="index.php?pfad=showArticle&id=<?php echo $dummy1->getId()?>"><?php if(isset($dummy1)){echo $dummy1->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<a href="index.php?pfad=physik" class="category-link">Physik</a> <a href="index.php?pfad=showCategory&category=physik" class="category-link">Physik</a>
<div class="article-link"> <div class="article-link">
<a href="index.php?pfad=showArticle&id=<?php echo $dummy2->getId()?>"><?php if(isset($dummy2)){echo $dummy2->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a> <a href="index.php?pfad=showArticle&id=<?php echo $dummy2->getId()?>"><?php if(isset($dummy2)){echo $dummy2->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
</div> </div>
+31
View File
@@ -0,0 +1,31 @@
<?php
include_once "php/controller/showCategory-controller.php";
?>
<main>
<h1><?php if (isset($category) && !empty($category)){ echo htmlspecialchars($category); } ?></h1>
<div class="s-res-list">
<?php
if (!empty($articles)): ?>
<?php foreach ($articles as $article): ?>
<div class="s-res-item">
<div class="s-res-content">
<h2 class="s-res-item-title">
<a href="index.php?pfad=showArticle&id=<?php echo $article->getId(); ?>" class="s-res-link">
<?php echo htmlspecialchars($article->getTitle()); ?>
</a>
</h2>
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($article->getAuthor()); ?></span></p>
</div>
<div class="s-res-arrow">&rarr;</div>
</div>
<?php endforeach; ?>
<?php
else: ?>
<p> Es sind noch keine Beiträge in dieser Kategorie enthalten.</p>
<?php endif; ?>
</div>
</main>
+4
View File
@@ -22,6 +22,10 @@ a, button, input, select, textarea, label, main{
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
} }
h1 {
text-transform: uppercase;
}
.flexbox { .flexbox {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
+52 -52
View File
@@ -39,50 +39,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
<li> <li>
<label class="nav__mobile-label">Sprachen</label> <label class="nav__mobile-label">Sprachen</label>
<ul class="nav__mobile-submenu"> <ul class="nav__mobile-submenu">
<li><a href="index.php?pfad=deutsch">Deutsch</a></li> <li><a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a></li>
<li><a href="index.php?pfad=englisch">Englisch</a></li> <li><a href="index.php?pfad=showCategory&category=englisch">Englisch</a></li>
<li><a href="index.php?pfad=franzoesisch">Französisch</a></li> <li><a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a></li>
<li><a href="index.php?pfad=latein">Latein</a></li> <li><a href="index.php?pfad=showCategory&category=latein">Latein</a></li>
<li><a href="index.php?pfad=literatur">Literatur</a></li> <li><a href="index.php?pfad=showCategory&category=literatur">Literatur</a></li>
</ul> </ul>
</li> </li>
<li> <li>
<label class="nav__mobile-label">MINT</label> <label class="nav__mobile-label">MINT</label>
<ul class="nav__mobile-submenu"> <ul class="nav__mobile-submenu">
<li><a href="index.php?pfad=mathe">Mathematik</a></li> <li><a href="index.php?pfad=showCategory&category=mathe">Mathematik</a></li>
<li><a href="index.php?pfad=biologie">Biologie</a></li> <li><a href="index.php?pfad=showCategory&category=biologie">Biologie</a></li>
<li><a href="index.php?pfad=chemie">Chemie</a></li> <li><a href="index.php?pfad=showCategory&category=chemie">Chemie</a></li>
<li><a href="index.php?pfad=physik">Physik</a></li> <li><a href="index.php?pfad=showCategory&category=physik">Physik</a></li>
<li><a href="index.php?pfad=informatik">Informatik</a></li> <li><a href="index.php?pfad=showCategory&category=informatik">Informatik</a></li>
<li><a href="index.php?pfad=astronomie">Astronomie</a></li> <li><a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a></li>
</ul> </ul>
</li> </li>
<li> <li>
<label class="nav__mobile-label">Gesellschaft & Werte</label> <label class="nav__mobile-label">Gesellschaft & Werte</label>
<ul class="nav__mobile-submenu"> <ul class="nav__mobile-submenu">
<li><a href="index.php?pfad=geschichte">Geschichte</a></li> <li><a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a></li>
<li><a href="index.php?pfad=erdkunde">Erdkunde</a></li> <li><a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a></li>
<li><a href="index.php?pfad=sozialkunde">Sozialkunde</a></li> <li><a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a></li>
<li><a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a></li> <li><a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a></li>
<li><a href="index.php?pfad=religion">Religion</a></li> <li><a href="index.php?pfad=showCategory&category=religion">Religion</a></li>
<li><a href="index.php?pfad=ethik">Ethikunterricht</a></li> <li><a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a></li>
<li><a href="index.php?pfad=philosophie">Philosophie</a></li> <li><a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a></li>
<li><a href="index.php?pfad=psychologie">Psychologie</a></li> <li><a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a></li>
<li><a href="index.php?pfad=kunst">Kunst</a></li> <li><a href="index.php?pfad=showCategory&category=kunst">Kunst</a></li>
<li><a href="index.php?pfad=musik">Musik</a></li> <li><a href="index.php?pfad=showCategory&category=musik">Musik</a></li>
<li><a href="index.php?pfad=theater">Theater</a></li> <li><a href="index.php?pfad=showCategory&category=theater">Theater</a></li>
</ul> </ul>
</li> </li>
<li> <li>
<label class="nav__mobile-label">Technik & Praxis</label> <label class="nav__mobile-label">Technik & Praxis</label>
<ul class="nav__mobile-submenu"> <ul class="nav__mobile-submenu">
<li><a href="index.php?pfad=technik">Technik</a></li> <li><a href="index.php?pfad=showCategory&category=technik">Technik</a></li>
<li><a href="index.php?pfad=werken">Werken</a></li> <li><a href="index.php?pfad=showCategory&category=werken">Werken</a></li>
<li><a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a></li> <li><a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a></li>
<li><a href="index.php?pfad=sport">Sport</a></li> <li><a href="index.php?pfad=showCategory&category=sport">Sport</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@@ -92,50 +92,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
<div class="nav__item nav__dropdown"> <div class="nav__item nav__dropdown">
<button class="nav__dropdown-toggle">Sprachen</button> <button class="nav__dropdown-toggle">Sprachen</button>
<div class="nav__dropdown-menu"> <div class="nav__dropdown-menu">
<a href="index.php?pfad=deutsch">Deutsch</a> <a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a>
<a href="index.php?pfad=englisch">Englisch</a> <a href="index.php?pfad=showCategory&category=englisch">Englisch</a>
<a href="index.php?pfad=franzoesisch">Französisch</a> <a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a>
<a href="index.php?pfad=latein">Latein</a> <a href="index.php?pfad=showCategory&category=latein">Latein</a>
<a href="index.php?pfad=literatur">Literatur</a> <a href="index.php?pfad=showCategory&category=literatur">Literatur</a>
</div> </div>
</div> </div>
<div class="nav__item nav__dropdown"> <div class="nav__item nav__dropdown">
<button class="nav__dropdown-toggle">MINT</button> <button class="nav__dropdown-toggle">MINT</button>
<div class="nav__dropdown-menu"> <div class="nav__dropdown-menu">
<a href="index.php?pfad=mathe">Mathematik</a> <a href="index.php?pfad=showCategory&category=mathe">Mathematik</a>
<a href="index.php?pfad=biologie">Biologie</a> <a href="index.php?pfad=showCategory&category=biologie">Biologie</a>
<a href="index.php?pfad=chemie">Chemie</a> <a href="index.php?pfad=showCategory&category=chemie">Chemie</a>
<a href="index.php?pfad=physik">Physik</a> <a href="index.php?pfad=showCategory&category=physik">Physik</a>
<a href="index.php?pfad=informatik">Informatik</a> <a href="index.php?pfad=showCategory&category=informatik">Informatik</a>
<a href="index.php?pfad=astronomie">Astronomie</a> <a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a>
</div> </div>
</div> </div>
<div class="nav__item nav__dropdown"> <div class="nav__item nav__dropdown">
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button> <button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
<div class="nav__dropdown-menu"> <div class="nav__dropdown-menu">
<a href="index.php?pfad=geschichte">Geschichte</a> <a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a>
<a href="index.php?pfad=erdkunde">Erdkunde</a> <a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a>
<a href="index.php?pfad=sozialkunde">Sozialkunde</a> <a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a>
<a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a> <a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a>
<a href="index.php?pfad=religion">Religion</a> <a href="index.php?pfad=showCategory&category=religion">Religion</a>
<a href="index.php?pfad=ethik">Ethikunterricht</a> <a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a>
<a href="index.php?pfad=philosophie">Philosophie</a> <a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a>
<a href="index.php?pfad=psychologie">Psychologie</a> <a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a>
<a href="index.php?pfad=kunst">Kunst</a> <a href="index.php?pfad=showCategory&category=kunst">Kunst</a>
<a href="index.php?pfad=musik">Musik</a> <a href="index.php?pfad=showCategory&category=musik">Musik</a>
<a href="index.php?pfad=theater">Theater</a> <a href="index.php?pfad=showCategory&category=theater">Theater</a>
</div> </div>
</div> </div>
<div class="nav__item nav__dropdown"> <div class="nav__item nav__dropdown">
<button class="nav__dropdown-toggle">Technik & Praxis</button> <button class="nav__dropdown-toggle">Technik & Praxis</button>
<div class="nav__dropdown-menu"> <div class="nav__dropdown-menu">
<a href="index.php?pfad=technik">Technik</a> <a href="index.php?pfad=showCategory&category=technik">Technik</a>
<a href="index.php?pfad=werken">Werken</a> <a href="index.php?pfad=showCategory&category=werken">Werken</a>
<a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a> <a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a>
<a href="index.php?pfad=sport">Sport</a> <a href="index.php?pfad=showCategory&category=sport">Sport</a>
</div> </div>
</div> </div>
</div> </div>
@@ -0,0 +1,21 @@
<?php
require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php';
require_once 'php/validator/article-validator.php';
if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){
$category = $_GET["category"];
try {
$articleManager = ArticleManager::getInstance();
$articles = $articleManager->getArticlesByCategory($category);
} catch (Exception $e) {
$_SESSION["message"] = "internal_error";
include_once "content/404.php";
exit();
}
}else{
$_SESSION["message"] = "invalid_category";
include_once "content/404.php";
exit();
}
?>
+3 -3
View File
@@ -19,7 +19,7 @@ class ArticleManager extends LocalArticleManager
"Satz des Pythagoras", "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...", "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", "max.mustermann",
"Mathe", "mathe",
"Dreiecke, Dreiecksseiten berechnen" "Dreiecke, Dreiecksseiten berechnen"
); );
} }
@@ -28,7 +28,7 @@ class ArticleManager extends LocalArticleManager
"Tunneleffekt", "Tunneleffekt",
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...", "Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
"max.mustermann", "max.mustermann",
"Physik", "physik",
"Quantenphysik, Energie" "Quantenphysik, Energie"
); );
} }
@@ -37,7 +37,7 @@ class ArticleManager extends LocalArticleManager
"Datenschutz vs Datensicherheit", "Datenschutz vs Datensicherheit",
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...", "Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
"max.mustermann", "max.mustermann",
"Informatik", "informatik",
"Daten, DSGVO" "Daten, DSGVO"
); );
} }
+7
View File
@@ -85,6 +85,13 @@ interface ArticleManagerDAO
*/ */
public function search(string $keyword): array; public function search(string $keyword): array;
/**
* Gibt alle Beiträge einer gegebenen Kategorie aus.
* @param $category
* @return mixed
*/
public function getArticlesByCategory($category);
} }
?> ?>
+21
View File
@@ -201,5 +201,26 @@ class LocalArticleManager implements ArticleManagerDAO {
return $filteredArticles; 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;
}
} }
?> ?>