Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a5131e33dc | |||
| a19d1db990 | |||
| b6e7da6808 | |||
| f21fab937f | |||
| 30fccfe69b | |||
| b692d76f7d | |||
| 56533d4a16 | |||
| 8a22b475f9 | |||
| ae3a1be5e1 | |||
| 8199afc88f | |||
| 2d7ef8fc1d | |||
| d75d78ccb3 | |||
| 42489f50b6 | |||
| 52fde19380 | |||
| b1fb3e5baa | |||
| 5f3dae64c1 | |||
| b31ce66ef9 | |||
| 93bd561ff9 | |||
| d0d93be96b | |||
| 327a05cf63 | |||
| 1394467abe | |||
| ace73f15ef | |||
| a5e1fb4c38 | |||
| ac2451fe64 | |||
| 5f9789a884 | |||
| e0fbd220f0 | |||
| a0932fed04 | |||
| 42aa908f1c | |||
| da9dc0e8fb | |||
| 36f6396148 | |||
| 12facddcd5 | |||
| 429ecb4e0e | |||
| 8019d9c99a | |||
| 9f9c92385d | |||
| 9ecfc3b6f8 | |||
| d00f2d9d53 | |||
| 37a032aa9f | |||
| fd8e13eaa9 | |||
| b5d1e08d22 | |||
| 23321f90c2 | |||
| 90c6f67c24 | |||
| 7e2b29bfb0 | |||
| cd6aa80f59 | |||
| d5fdc9383f | |||
| 53865efc78 | |||
| 8cbd442371 | |||
| f54cf58dc2 | |||
| ede8e1cb21 | |||
| aaff15ee8c | |||
| bb7c85d770 | |||
| b7160f4df6 | |||
| a6b57bc352 | |||
| 70f7e05fe1 | |||
| 15f17b7af4 | |||
| 3c14df129d | |||
| 5660f8d59d | |||
| 198fefbdf5 | |||
| 135bd7b9cd | |||
| 4cd0383322 |
Generated
+18
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="dataSourceStorageLocal" created-in="IU-261.25134.95">
|
||||||
|
<data-source name="articles" uuid="315cb5c9-2b0f-435b-b602-59823b160908">
|
||||||
|
<database-info product="SQLite" version="3.51.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.51.1.0" dbms="SQLITE" exact-version="3.51.1" exact-driver-version="3.51">
|
||||||
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
</database-info>
|
||||||
|
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
|
||||||
|
<secret-storage>master_key</secret-storage>
|
||||||
|
<auth-provider>no-auth</auth-provider>
|
||||||
|
<schema-mapping>
|
||||||
|
<introspection-scope>
|
||||||
|
<node kind="schema" qname="@" />
|
||||||
|
</introspection-scope>
|
||||||
|
</schema-mapping>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="articles" uuid="315cb5c9-2b0f-435b-b602-59823b160908">
|
||||||
|
<driver-ref>sqlite.xerial</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db/articles</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
- Niklas Ortmann
|
- Niklas Ortmann
|
||||||
|
|
||||||
## Login-Informationen für Dummy-User
|
## Login-Informationen für Dummy-User
|
||||||
Jeweils im Format `Anmeldename, Passwort, Mailadresse`:
|
`Anmeldename, Passwort, Mailadresse`:
|
||||||
- `max.mustermann, test123, mustermann@web.de`
|
- `max.mustermann, test12345, mustermann@web.de`
|
||||||
|
|
||||||
## Weitere Voraussetzungen zur Nutzung
|
## Weitere Voraussetzungen zur Nutzung
|
||||||
- Per Klick auf das Logo gelangt man auf die Home-Seite.
|
- Per Klick auf das Logo gelangt man auf die Home-Seite.
|
||||||
@@ -15,7 +15,6 @@ Jeweils im Format `Anmeldename, Passwort, Mailadresse`:
|
|||||||
## Ausgelassene Teilaufgaben
|
## Ausgelassene Teilaufgaben
|
||||||
|
|
||||||
## Bekannte Fehler und Mängel
|
## Bekannte Fehler und Mängel
|
||||||
- Der Beitragseditor fügt beim Laden von Inhalten leere Zeichen ein.
|
|
||||||
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
||||||
- Die Navbar hat noch keine onHover-Effekte und erschwert etwas die Bedienung.
|
- Die Navbar hat noch keine onHover-Effekte und erschwert etwas die Bedienung.
|
||||||
- Suchleiste in der Nav ist in der mobilen Ansicht etwas schmal. Ggf. ein alternatives (kleineres) Logo implementieren.
|
- Suchleiste in der Nav ist in der mobilen Ansicht etwas schmal. Ggf. ein alternatives (kleineres) Logo implementieren.
|
||||||
@@ -26,10 +25,8 @@ Jeweils im Format `Anmeldename, Passwort, Mailadresse`:
|
|||||||
- Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden.
|
- Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden.
|
||||||
Es handelt es sich um eine einfache Version. Später sollen z.B. Bilder und die Positionierung der Elemente folgen.
|
Es handelt es sich um eine einfache Version. Später sollen z.B. Bilder und die Positionierung der Elemente folgen.
|
||||||
- Es sind drei Dummy-Beiträge für den Nutzer max.mustermann hinterlegt.
|
- Es sind drei Dummy-Beiträge für den Nutzer max.mustermann hinterlegt.
|
||||||
- Beim Verwenden der Navbar-Links bitte Folgendes beachten: nur die Kategorien Physik, Mathe, Informatik führen
|
- Die Such-Seite umfasst eine Such- und Sortierfunktion. Jedoch fehlt noch eine
|
||||||
exemplarisch auf eine Beispiel-Seite.
|
|
||||||
Die anderen Links sind erstmal Platzhalter und führen auf eine 404-Seite.
|
|
||||||
- Die Such-Seite umfasst eine Suchfunktion (aber noch nicht nach Tags) und Sortierfunktion. Jedoch fehlt noch eine
|
|
||||||
Filterfunktion (z.B. nur Mathe anzeigen).
|
Filterfunktion (z.B. nur Mathe anzeigen).
|
||||||
Wenn die Filterfunktion implementiert ist, dann können die statischen Seiten "Informatik", "Mathe", "Physik" entfernt
|
|
||||||
und dynamisch auf der Suchseite nach gefiltertem Fach angezeigt werden. (Vorläufige showCategory.php implementiert).
|
## Sonstiges
|
||||||
|
- Das Datenschema befindet sich unter /planung/Datenschema.pdf
|
||||||
@@ -12,50 +12,13 @@ if (!isset($_SESSION["user"])) {
|
|||||||
<form method="post" action="php/controller/createArticle-controller.php" id="editor-form" class="article-editor-scope.editor-container article-editor-scope editor-container">
|
<form method="post" action="php/controller/createArticle-controller.php" id="editor-form" class="article-editor-scope.editor-container article-editor-scope editor-container">
|
||||||
|
|
||||||
<main class="editor-main">
|
<main class="editor-main">
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
<p class="alert-message is-error">
|
|
||||||
Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Die ausgewählte Kategorie ist ungültig.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-50 Zeichen).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title"
|
||||||
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
||||||
placeholder="Titel hier eingeben" required>
|
placeholder="Titel hier eingeben" required>
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."><?php if (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){echo htmlspecialchars($_SESSION['old_content']); unset($_SESSION['old_content']);}elseif (isset($content) && !empty($content)){echo htmlspecialchars($content);}?></textarea>
|
||||||
<?php echo htmlspecialchars($_SESSION['old_content'] ?? ''); unset($_SESSION['old_content']); ?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
|
|||||||
+1
-18
@@ -7,24 +7,7 @@ include_once 'php/controller/home-controller.php';
|
|||||||
Inhalt: Beinhaltet den Inhalt der Startseite
|
Inhalt: Beinhaltet den Inhalt der Startseite
|
||||||
-->
|
-->
|
||||||
<main>
|
<main>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
<p class="alert-message is-error">
|
|
||||||
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "new_article"): ?>
|
|
||||||
<p class="alert-message is-success">
|
|
||||||
Dein Beitrag wurde erfolgreich veröffentlicht!
|
|
||||||
</p>
|
|
||||||
<?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
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<h1>Home</h1>
|
<h1>Home</h1>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
<!--
|
|
||||||
Seite: Informatik
|
|
||||||
Inhalt: Eine Übersicht über alle Beiträge zum Fach
|
|
||||||
-->
|
|
||||||
<main>
|
|
||||||
|
|
||||||
<h1>Informatik</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
|
|
||||||
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
|
|
||||||
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
|
|
||||||
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
|
||||||
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
|
|
||||||
sea takimata sanctus est Lorem ipsum dolor sit amet.
|
|
||||||
</p>
|
|
||||||
<h2>Artikel:</h2>
|
|
||||||
<div>
|
|
||||||
<a href="datenschutzVSdatensicherheit.php">Datenschutz vs. Datensicherheit</a>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<!--
|
|
||||||
Seite: Mathe
|
|
||||||
Inhalt: Eine Übersicht über alle Beiträge zum Fach
|
|
||||||
-->
|
|
||||||
<main>
|
|
||||||
|
|
||||||
<h1>Mathe</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
|
|
||||||
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
|
|
||||||
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
|
|
||||||
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
|
||||||
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
|
|
||||||
sea takimata sanctus est Lorem ipsum dolor sit amet.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h2>Artikel:</h2>
|
|
||||||
<div>
|
|
||||||
<a href="pythagoras.php">Satz des Pythagoras</a>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<!--
|
|
||||||
Seite: Physik
|
|
||||||
Inhalt: Eine Übersicht über alle Beiträge zum Fach
|
|
||||||
-->
|
|
||||||
<main>
|
|
||||||
|
|
||||||
<h1>Physik</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
|
|
||||||
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
|
|
||||||
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
|
|
||||||
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
|
||||||
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
|
|
||||||
sea takimata sanctus est Lorem ipsum dolor sit amet.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h2>Artikel:</h2>
|
|
||||||
<div>
|
|
||||||
<a href="tunneleffekt.php">Der Tunneleffekt</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
+24
-9
@@ -81,18 +81,20 @@ $isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a href="index.php?pfad=deleteAccount" class="button">
|
<form action="php/controller/deleteAccount-controller.php" method="POST">
|
||||||
Account löschen
|
<button type="submit"
|
||||||
</a>
|
class="button"
|
||||||
|
onclick="return confirm('Möchtest du deinen Account wirklich unwiderruflich löschen?');">
|
||||||
|
Account löschen
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<br><br>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=logout" class="button">
|
|
||||||
Abmelden
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
|
|
||||||
<h2 class="section-title">Meine Beiträge</h2>
|
<h2 class="section-title">Meine Beiträge</h2>
|
||||||
|
|
||||||
<div class="articles-list">
|
<div class="articles-list">
|
||||||
@@ -117,7 +119,9 @@ $isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 class="article-title">
|
<h3 class="article-title">
|
||||||
<?php echo htmlspecialchars($userArticle->getTitle()); ?>
|
<a href="index.php?pfad=showArticle&id=<?php echo $userArticle->getID(); ?>">
|
||||||
|
<?php echo htmlspecialchars($userArticle->getTitle()); ?>
|
||||||
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@@ -151,6 +155,17 @@ $isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
|||||||
class="edit-link-button">
|
class="edit-link-button">
|
||||||
Bearbeiten
|
Bearbeiten
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<form action="php/controller/deleteArticle-controller.php" method="POST">
|
||||||
|
<input type="hidden" name="id" value="<?php echo htmlspecialchars($userArticle->getID()); ?>">
|
||||||
|
|
||||||
|
<button type="submit"
|
||||||
|
class="button"
|
||||||
|
onclick="return confirm('Möchtest du diesen Artikel wirklich löschen?');">
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
$results = $_SESSION["search_results"] ?? [];
|
$results = $_SESSION["search_results"] ?? [];
|
||||||
$query = $_SESSION["search_query"] ?? "";
|
$query = $_SESSION["search_query"] ?? "";
|
||||||
@@ -11,6 +13,7 @@ $resultCount = count($results);
|
|||||||
Inhalt: Zeigt die Ergebnisse einer Suche an
|
Inhalt: Zeigt die Ergebnisse einer Suche an
|
||||||
-->
|
-->
|
||||||
<div class="s-res-layout-grid">
|
<div class="s-res-layout-grid">
|
||||||
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
|
|
||||||
<!-- Links: Seitenleiste für Filter und Suche -->
|
<!-- Links: Seitenleiste für Filter und Suche -->
|
||||||
<aside class="s-res-sidebar">
|
<aside class="s-res-sidebar">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ include_once "php/controller/showCategory-controller.php";
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
|
|
||||||
<h1><?php if (isset($category) && !empty($category)){ echo htmlspecialchars($category); } ?></h1>
|
<h1><?php if (isset($category) && !empty($category)){ echo htmlspecialchars($category); } ?></h1>
|
||||||
|
|
||||||
|
|||||||
+10
-61
@@ -13,73 +13,21 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<form method="post" action="php/controller/updateArticle-controller.php?id=<?php if(isset($id) && !empty($id)){echo htmlspecialchars($id);}else{$_SESSION["message"] = "missing_id";} ?>" id="editor-form" class="article-editor-scope.editor-container article-editor-scope editor-container">
|
<form method="post" action="php/controller/updateArticle-controller.php?id=<?php if(isset($id) && !empty($id)){echo htmlspecialchars($id);}else{$_SESSION["message"] = "missing_id";} ?>" id="editor-form" class="article-editor-scope.editor-container article-editor-scope editor-container">
|
||||||
|
|
||||||
<main class="editor-main">
|
<main class="editor-main">
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
<p class="alert-message is-error">
|
|
||||||
Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_id"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Es ist ein Fehler aufgetreten. Die ID konnte nicht ausgelesen werden. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Die ausgewählte Kategorie ist ungültig.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-20 Zeichen).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "unauthorized_access"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title"
|
||||||
value="<?php
|
value="<?php
|
||||||
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
|
if (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
||||||
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_title']);
|
echo htmlspecialchars($_SESSION['old_title']);
|
||||||
unset($_SESSION['old_title']);
|
unset($_SESSION['old_title']);
|
||||||
|
}elseif (isset($title) && !empty($title)){
|
||||||
|
echo htmlspecialchars($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>"
|
?>"
|
||||||
placeholder="Titel hier eingeben" required>
|
placeholder="Titel hier eingeben" required>
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."><?php if (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){echo htmlspecialchars($_SESSION['old_content']); unset($_SESSION['old_content']);}elseif (isset($content) && !empty($content)){echo htmlspecialchars($content);}?></textarea>
|
||||||
<?php
|
|
||||||
if (isset($content) && !empty($content)){echo htmlspecialchars($content);
|
|
||||||
}elseif (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_content']);
|
|
||||||
unset($_SESSION['old_content']);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
@@ -138,10 +86,11 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<label for="tags">Schlagwörter</label>
|
<label for="tags">Schlagwörter</label>
|
||||||
<input type="text" id="tags" name="tags"
|
<input type="text" id="tags" name="tags"
|
||||||
value="<?php
|
value="<?php
|
||||||
if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);
|
if (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
||||||
} elseif (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_tags']);
|
echo htmlspecialchars($_SESSION['old_tags']);
|
||||||
unset($_SESSION['old_tags']);
|
unset($_SESSION['old_tags']);
|
||||||
|
} elseif (isset($tags) && !empty($tags)){
|
||||||
|
echo htmlspecialchars($tags);
|
||||||
}
|
}
|
||||||
?>"
|
?>"
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
|
|||||||
+2
-2
@@ -115,8 +115,8 @@ CSS für die navbar
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Anpassung unter 1210px */
|
/* Responsive Anpassung unter 1240px */
|
||||||
@media (max-width: 1210px) {
|
@media (max-width: 1240px) {
|
||||||
.nav {
|
.nav {
|
||||||
flex-wrap: wrap; /* zweite Nav-Zeile*/
|
flex-wrap: wrap; /* zweite Nav-Zeile*/
|
||||||
padding: 0.5rem 1rem;
|
padding: 0.5rem 1rem;
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?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 if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Die ausgewählte Kategorie ist ungültig.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-50 Zeichen).
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
||||||
|
</p>
|
||||||
|
<?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 if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_id"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Die Artikel-ID fehlt oder ist ungültig.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "not_found_article"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der angeforderte Beitrag konnte nicht gefunden werden.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "unauthorized_access"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Du hast keine Berechtigung, diesen Beitrag zu bearbeiten oder zu löschen.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "article_deleted"): ?>
|
||||||
|
<p class="alert-message is-success">
|
||||||
|
Der Beitrag wurde erfolgreich gelöscht.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "new_article"): ?>
|
||||||
|
<p class="alert-message is-success">
|
||||||
|
Dein Beitrag wurde erfolgreich veröffentlicht!
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
unset($_SESSION["message"]);
|
||||||
|
?>
|
||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
$pfad = $_GET["pfad"] ?? "home";
|
$pfad = $_GET["pfad"] ?? "home";
|
||||||
@@ -17,12 +19,12 @@ if ($pfad === "register") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($pfad === "logout") {
|
if ($pfad === "logout") {
|
||||||
include_once "content/logout-controller.php";
|
include_once "php/controller/logout-controller.php";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pfad === "deleteAccount") {
|
if ($pfad === "deleteAccount") {
|
||||||
include_once "content/deleteAccount-controller.php";
|
include_once "php/controller/deleteAccount-controller.php";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
SESSION_START();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../validator/article-validator.php';
|
require_once '../validator/article-validator.php';
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
require_once "php/model/UserManager.php";
|
require_once __DIR__ . "/../model/UserManager.php";
|
||||||
|
require_once __DIR__ . "/../model/ArticleManager.php";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Deregistrierung
|
Deregistrierung
|
||||||
@@ -10,21 +14,30 @@ require_once "php/model/UserManager.php";
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$dao = UserManager::getInstance();
|
$dao = UserManager::getInstance();
|
||||||
|
$articleManager = ArticleManager::getInstance();
|
||||||
|
|
||||||
if (isset($_SESSION["user_email"])) {
|
if (isset($_SESSION["user_email"])) {
|
||||||
$dao->deleteUser($_SESSION["user_email"]);
|
$dao->deleteUser($_SESSION["user_email"]);
|
||||||
|
|
||||||
|
$articles = $articleManager->getArticlesByAuthor($_SESSION["user_email"]);
|
||||||
|
foreach ($articles as $article) {
|
||||||
|
$articleManager->deleteArticle($article->getId(), $_SESSION["user_email"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new NotFoundException("missing_user_email");
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION = [];
|
$_SESSION = [];
|
||||||
session_destroy();
|
session_destroy();
|
||||||
|
|
||||||
header("Location: index.php");
|
header("Location: ../../index.php");
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
|
|
||||||
header("Location: index.php?pfad=profile");
|
header("Location: ../../index.php?pfad=profile");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . "/../model/ArticleManager.php";
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
|
||||||
|
if (isset($_SESSION["user_email"])) {
|
||||||
|
$user = $_SESSION["user_email"];
|
||||||
|
} else {
|
||||||
|
$_SESSION = [];
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header("Location: ../../index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["id"]) && !empty($_POST["id"])) {
|
||||||
|
$id = $_POST["id"];
|
||||||
|
} else {
|
||||||
|
$_SESSION["message"] = "missing_id";
|
||||||
|
header("location: ../../index.php?pfad=profile");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$articleManager = ArticleManager::getInstance();
|
||||||
|
$articleManager->deleteArticle($id, $user);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$_SESSION["message"] = $e->getMessage();
|
||||||
|
header("location: ../../index.php?pfad=profile");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION["message"] = "article_deleted";
|
||||||
|
header("location: ../../index.php?pfad=profile");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
require_once 'php/model/Article.php';
|
require_once 'php/model/Article.php';
|
||||||
require_once 'php/model/ArticleManager.php';
|
require_once 'php/model/ArticleManager.php';
|
||||||
require_once 'php/model/LocalArticleManager.php';
|
require_once 'php/model/LocalArticleManager.php';
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../model/Article.php';
|
require_once '../model/Article.php';
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
require_once 'php/model/Article.php';
|
require_once 'php/model/Article.php';
|
||||||
require_once 'php/model/ArticleManager.php';
|
require_once 'php/model/ArticleManager.php';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
SESSION_START();
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../model/Article.php';
|
require_once '../model/Article.php';
|
||||||
@@ -21,7 +24,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
|
|
||||||
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}else{
|
}else{
|
||||||
$title = $_POST["title"];
|
$title = $_POST["title"];
|
||||||
@@ -33,31 +36,31 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
// -------------------------------- Validierung der Daten: -------------------------
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
if (!articleAuthorValidator($author)) {
|
if (!articleAuthorValidator($author)) {
|
||||||
$_SESSION["message"] = "author_not_valid";
|
$_SESSION["message"] = "author_not_valid";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
if (!articleTitleValidator($title)) {
|
||||||
$_SESSION["message"] = "invalid_title";
|
$_SESSION["message"] = "invalid_title";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleContentValidator($content)) {
|
if (!articleContentValidator($content)) {
|
||||||
$_SESSION["message"] = "invalid_content";
|
$_SESSION["message"] = "invalid_content";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleCategoryValidator($category)) {
|
if (!articleCategoryValidator($category)) {
|
||||||
$_SESSION["message"] = "invalid_category";
|
$_SESSION["message"] = "invalid_category";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleTagValidator($tags)) {
|
if (!articleTagValidator($tags)) {
|
||||||
$_SESSION["message"] = "invalid_tags";
|
$_SESSION["message"] = "invalid_tags";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$cleanedTags = [];
|
$cleanedTags = [];
|
||||||
@@ -83,7 +86,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$articleManager->updateArticle($id ,$article, $author);
|
$articleManager->updateArticle($id ,$article, $author);
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = $e->getMessage();
|
$_SESSION["message"] = $e->getMessage();
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$_SESSION["message"] = "article_updated";
|
$_SESSION["message"] = "article_updated";
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ArticleManager
|
|||||||
$articleManager->addArticle(
|
$articleManager->addArticle(
|
||||||
"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",
|
"mustermann@web.de",
|
||||||
"mathe",
|
"mathe",
|
||||||
"Dreiecke, Dreiecksseiten berechnen"
|
"Dreiecke, Dreiecksseiten berechnen"
|
||||||
);
|
);
|
||||||
@@ -28,7 +28,7 @@ class ArticleManager
|
|||||||
$articleManager->addArticle(
|
$articleManager->addArticle(
|
||||||
"Tunneleffekt",
|
"Tunneleffekt",
|
||||||
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
||||||
"max.mustermann",
|
"mustermann@web.de",
|
||||||
"physik",
|
"physik",
|
||||||
"Quantenphysik, Energie"
|
"Quantenphysik, Energie"
|
||||||
);
|
);
|
||||||
@@ -37,7 +37,7 @@ class ArticleManager
|
|||||||
$articleManager->addArticle(
|
$articleManager->addArticle(
|
||||||
"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",
|
"mustermann@web.de",
|
||||||
"informatik",
|
"informatik",
|
||||||
"Daten, DSGVO"
|
"Daten, DSGVO"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ interface ArticleManagerDAO
|
|||||||
* (Unabhängig von Groß-und Kleinschreibung)
|
* (Unabhängig von Groß-und Kleinschreibung)
|
||||||
* @param string $keyword Der eingegebene Suchbegriff.
|
* @param string $keyword Der eingegebene Suchbegriff.
|
||||||
* @return array Ein Array von Artikeln ,die dem Suchkriterium entsprechen. Wenn nichts gefunden wird, ein leeres Array.
|
* @return array Ein Array von Artikeln ,die dem Suchkriterium entsprechen. Wenn nichts gefunden wird, ein leeres Array.
|
||||||
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function search(string $keyword): array;
|
public function search(string $keyword): array;
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,8 @@ class DatabaseArticleManager implements ArticleManagerDAO {
|
|||||||
{
|
{
|
||||||
if (!file_exists(__DIR__ . '/../../db/articles.db')) {
|
if (!file_exists(__DIR__ . '/../../db/articles.db')) {
|
||||||
try {
|
try {
|
||||||
$user = 'root';
|
|
||||||
$pw = null;
|
$db = $this->getConnection();
|
||||||
$dsn = 'sqlite:' . __DIR__ . '/../../db/articles.db';
|
|
||||||
$db = new PDO($dsn, $user, $pw);
|
|
||||||
|
|
||||||
$db->exec("
|
$db->exec("
|
||||||
CREATE TABLE articles (
|
CREATE TABLE articles (
|
||||||
@@ -149,7 +147,7 @@ class DatabaseArticleManager implements ArticleManagerDAO {
|
|||||||
|
|
||||||
public function deleteArticle($id, $author)
|
public function deleteArticle($id, $author)
|
||||||
{
|
{
|
||||||
$article = getArticle($id);
|
$article = $this->getArticle($id);
|
||||||
if (empty($article)) {
|
if (empty($article)) {
|
||||||
throw new NotFoundException("not_found_article");
|
throw new NotFoundException("not_found_article");
|
||||||
}
|
}
|
||||||
@@ -308,8 +306,57 @@ class DatabaseArticleManager implements ArticleManagerDAO {
|
|||||||
|
|
||||||
public function search(string $keyword): array
|
public function search(string $keyword): array
|
||||||
{
|
{
|
||||||
// TODO: implement search()
|
$cleankeyword = trim($keyword);
|
||||||
return [];
|
|
||||||
|
// Leeren Suchbegriff sofort abfangen
|
||||||
|
if ($cleankeyword === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$db = $this->getConnection();
|
||||||
|
|
||||||
|
$sql = "SELECT id, title, content, author, category, tags, created
|
||||||
|
FROM articles
|
||||||
|
WHERE title LIKE :keyword
|
||||||
|
OR content LIKE :keyword;";
|
||||||
|
|
||||||
|
$command = $db->prepare($sql);
|
||||||
|
if (!$command) {
|
||||||
|
throw new InternalServerErrorException("internal_error");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wildcards für die Suche hinzufügen
|
||||||
|
$searchParam = '%' . $cleankeyword . '%';
|
||||||
|
|
||||||
|
$success = $command->execute([
|
||||||
|
":keyword" => $searchParam
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$success) {
|
||||||
|
throw new InternalServerErrorException("internal_error");
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = $command->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$filteredArticles = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$filteredArticles[] = new Article(
|
||||||
|
intval($row['id']),
|
||||||
|
$row['title'] ?? '',
|
||||||
|
$row['content'] ?? '',
|
||||||
|
$row['author'] ?? '',
|
||||||
|
$row['category'] ?? '',
|
||||||
|
$row['tags'] ?? '',
|
||||||
|
$row['created'] ?? '' // Nutzt 'created' aus deiner DB-Struktur
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filteredArticles;
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
throw new InternalServerErrorException("internal_error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,14 +36,19 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
* Speichert alle Artikel/Beiträge in der Datei.
|
* Speichert alle Artikel/Beiträge in der Datei.
|
||||||
* @param $articles
|
* @param $articles
|
||||||
* @return void
|
* @return void
|
||||||
* TODO: Exceptions implementieren.
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function saveArticle($articles)
|
private function saveArticle($articles)
|
||||||
{
|
{
|
||||||
file_put_contents(
|
try{
|
||||||
$this->file,
|
file_put_contents(
|
||||||
json_encode($articles, JSON_PRETTY_PRINT)
|
$this->file,
|
||||||
);
|
json_encode($articles, JSON_PRETTY_PRINT)
|
||||||
|
);
|
||||||
|
}catch (Exception $e){
|
||||||
|
throw new InternalServerErrorException($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addArticle($title, $content, $author, $category, $tags)
|
public function addArticle($title, $content, $author, $category, $tags)
|
||||||
@@ -66,7 +71,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
public function updateArticle($id, $article, $author)
|
public function updateArticle($id, $article, $author)
|
||||||
{
|
{
|
||||||
if (empty($article)) {
|
if (empty($article)) {
|
||||||
throw new InternalServerErrorException("internal_error");
|
throw new NotFoundException("not_found_article");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechtigungsprüfung:
|
// Berechtigungsprüfung:
|
||||||
@@ -208,7 +213,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $filteredArticles;
|
return $filteredArticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArticlesByCategory($category)
|
public function getArticlesByCategory($category)
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ class LocalUserManager implements UserManagerDAO {
|
|||||||
/**
|
/**
|
||||||
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
*
|
*
|
||||||
|
* TODO: wenn ein Benutzer gelöscht wird, sollten dann auch seine Beiträge gelöscht werden?
|
||||||
|
*
|
||||||
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
||||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prüft, ob der Autor auch der Eigentümer des Beitrags ist.
|
* Prüft, ob der Autor auch der Eigentümer des Beitrags ist.
|
||||||
* @param $author
|
* @param $author
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user