Compare commits
284 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a8df9590fd | |||
| 3e453e22ec | |||
| beeab0ec90 | |||
| 9353a7eaaa | |||
| cac8f3046d | |||
| 66eeac372c | |||
| d597046f41 | |||
| ae1c873536 | |||
| 95251d23ad | |||
| c16bf574ce | |||
| 0e44d92baa | |||
| f9c1c67a38 | |||
| 286e2b6237 | |||
| fb78794261 | |||
| 371a65d361 | |||
| 7bd3c8dfd1 | |||
| e5aa6ea25d | |||
| de9afd3275 | |||
| 79e9f17f70 | |||
| 12cc3c5d5b | |||
| 404cea74ff | |||
| 16e94947f2 | |||
| aff0b0560f | |||
| de19a6fc65 | |||
| 1f669aadfc | |||
| 33f428559c | |||
| 0c3b9eb250 | |||
| c654fab94a | |||
| f2ef3c08a7 | |||
| 8a66e8af3f | |||
| 41d1cc6013 | |||
| c9c6a4ae81 | |||
| 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 | |||
| a5650f2720 | |||
| 4758366063 | |||
| e7a5c2b352 | |||
| 3c14df129d | |||
| 5660f8d59d | |||
| 36ec2a539c | |||
| 339e51cca7 | |||
| 0726ba214c | |||
| 0e032ae029 | |||
| b9dead1c8b | |||
| 9010b68a39 | |||
| 252c14a377 | |||
| 4abfe801ec | |||
| c23a10eb6e | |||
| 11b55008ea | |||
| 46dcc16c59 | |||
| d42dff1165 | |||
| 11da418f60 | |||
| 981e78ff7e | |||
| c798bbd230 | |||
| e22d97e15a | |||
| c662369259 | |||
| 11b7be4ca0 | |||
| a029314bc9 | |||
| 8dd2d4f4ea | |||
| a4efbd4f0b | |||
| f63b8c6506 | |||
| 198fefbdf5 | |||
| 135bd7b9cd | |||
| 4cd0383322 | |||
| caa9a9ff8f | |||
| 524dc2a399 | |||
| 793d9632b2 | |||
| 5892a875c8 | |||
| b130bf9e19 | |||
| 1314362df9 | |||
| 5a1c032f1b | |||
| fae4bc86ad | |||
| 664092d52f | |||
| 22b1dd827d | |||
| 50df844e23 | |||
| 45b6b41d60 | |||
| a0a79e0191 | |||
| 46def40a14 | |||
| a76113dcaf | |||
| f56a04c3ab | |||
| 7f891b6ebf | |||
| 1343496a12 | |||
| 1735dd28a2 | |||
| bfc9ee4d01 | |||
| 9321d09489 | |||
| 7269ea03db | |||
| 2a3a15c92d | |||
| a7f1729e6e | |||
| cdccb0bfe8 | |||
| 48501a9069 | |||
| a175765e33 | |||
| 3d57c2e482 | |||
| bac4334fb8 | |||
| aa3e7c2f36 | |||
| 46cd524f70 | |||
| 86fb37abc4 | |||
| 9349b91926 | |||
| b9c86e2074 | |||
| 68672474e4 | |||
| a08197cc10 | |||
| e28620d9fb | |||
| ded98ed757 | |||
| 18fe69cbcd | |||
| e35d07ebc3 | |||
| e772a8b57f | |||
| 9c3ebc9877 | |||
| 3d13c3b8c8 | |||
| 6c3e788f13 | |||
| aceac0bf8b | |||
| 78d04f1715 | |||
| 1d773ea4e6 | |||
| a595567db1 | |||
| 945d3e1c1f | |||
| d58ea953af | |||
| b9475a045f | |||
| 32c2a1a3d8 | |||
| fc93f2b3f0 | |||
| f33778f97a | |||
| 1c72a03f26 | |||
| 3dcbdbf23c | |||
| 8143d501fa | |||
| 3471eedf4a | |||
| b6a3dad2ab | |||
| 375e6d9625 | |||
| 4d144ec704 | |||
| 92574a0f76 | |||
| ade73f3105 | |||
| ee75620cd8 | |||
| 94486e2b0a | |||
| a26e985edf | |||
| cf9ac795eb | |||
| 370c047c16 | |||
| a562a67923 | |||
| 078dbd8901 | |||
| 64d624a6df | |||
| 90ab57e4cb | |||
| a00ddf18e6 | |||
| 5048dc2466 | |||
| 7209fe3e20 | |||
| 4e35e67ef1 | |||
| 830b57d245 | |||
| 06930644a6 | |||
| a519387773 | |||
| ed40596389 | |||
| 4c855c05ed | |||
| e7189245d5 | |||
| 709a4ba83c | |||
| fb54ba2462 | |||
| c6b55030cf | |||
| af04557f58 | |||
| 2c100bddf2 | |||
| 8e3642c668 | |||
| 87d78b749b | |||
| 604dbeca93 | |||
| 8e9e7d65d0 | |||
| e2c317e507 | |||
| 5a7fa35465 | |||
| 2601a1c1ca | |||
| 0e26679f24 | |||
| d5ab659217 | |||
| 2d5919d572 | |||
| f56a074a3c | |||
| 24dc432f01 | |||
| 016193de07 | |||
| f04d8fecd3 | |||
| 36276c7c88 | |||
| 4a2cf0b55b | |||
| 400436a73f | |||
| 4c378dfba6 | |||
| c3a9de71f4 | |||
| ecf2e9ef57 | |||
| 45ac70eba2 | |||
| 3b66c6aa3a | |||
| e37b882481 | |||
| 5c7a47e002 | |||
| bbaa73dc1a | |||
| 9f5806f019 | |||
| 6de86c3143 | |||
| c9c0de6c3c | |||
| 4f827ed3a8 | |||
| aedac79743 | |||
| 84a39bf0d4 | |||
| 75c6d099f5 | |||
| 319957c01e | |||
| 26dc33ea2f | |||
| 7597eddd7c | |||
| 0441b4e56f | |||
| cbff21136c | |||
| 03f0d19b01 | |||
| ca65c6c6e1 | |||
| 2b095f16bf | |||
| 930bf99fa1 | |||
| 366527e8e9 | |||
| 4e06240307 | |||
| 38608a5278 | |||
| b19f30cca4 | |||
| b206e809ac | |||
| e88f741fa7 | |||
| 6958e71bfb | |||
| c6ad0b2a59 | |||
| da9ea4f413 | |||
| 5703c0a6dd | |||
| b70943dd35 | |||
| 0f7099be81 | |||
| 9cbc1637b4 | |||
| d01be7d84c | |||
| 28511e0cc4 | |||
| 3774a2caee | |||
| 70277d3712 | |||
| 18cb092d06 | |||
| 417f34e35f | |||
| c62ff5b2c0 | |||
| ad422a134d | |||
| 9fce9ec8dd | |||
| a329137de2 | |||
| b328c2613c | |||
| 62a7b6773c | |||
| 21bdb0d66d | |||
| 5db4ad3e63 | |||
| 2ce13cef72 | |||
| 02551049e0 | |||
| 55e9fa6a20 | |||
| c82378baa8 | |||
| 541d5b4c5e | |||
| f9ab3f8db2 | |||
| 6c5047be30 | |||
| 25f6d2bf4a | |||
| 4d8f338649 | |||
| 46a307a5b0 | |||
| 7706c7dfbf | |||
| a946cee891 | |||
| 4d4b8aeb99 |
Generated
+18
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="IU-261.24374.151">
|
||||
<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>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<DataSourcesHistory>
|
||||
<DataSourceFromHistory isRemovedFromProject="true">
|
||||
<data-source source="LOCAL" name="articles" uuid="a0abcd0a-1d6f-40e4-88be-f442bcb431ba">
|
||||
<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" />
|
||||
<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>
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<auth-provider>no-auth</auth-provider>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="schema" qname="@" />
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</DataSourceFromHistory>
|
||||
<DataSourceFromHistory isRemovedFromProject="false">
|
||||
<data-source source="LOCAL" 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" />
|
||||
<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>
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<auth-provider>no-auth</auth-provider>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="schema" qname="@" />
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</DataSourceFromHistory>
|
||||
</DataSourcesHistory>
|
||||
Generated
+1
-3
@@ -10,9 +10,7 @@
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.0">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.5" />
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
|
||||
@@ -1,13 +1,30 @@
|
||||
Team Tag-Buchstabe: DI-14-C-Schulte-Eilers-Ortmann
|
||||
Namen der Studierenden:
|
||||
- Name 1 Caroline Schulte
|
||||
- Name 2 Jacques Eilers
|
||||
- Name 3 Niklas Ortmann
|
||||
Abgabe zu Aufgabenblatt 1
|
||||
# Webprogrammierung: Gruppe DI-14-C
|
||||
|
||||
Hinweise:
|
||||
index.html wurde zu einer index.php umbenannt.
|
||||
webhook.php bitte ignorieren. Diese dient nur als zukünftige Automatisierung des Repo-Pulls (s. https://docs.gitea.com/usage/webhooks)
|
||||
## Beteiligte
|
||||
- Caroline Schulte
|
||||
- Jacques Eilers
|
||||
- Niklas Ortmann
|
||||
|
||||
Beim Verwenden der Navbar-Links bitte Folgendes beachten: nur die Kategorien Physik, Mathe, Informatik führen exemplarisch auf eine Beispiel-Seite.
|
||||
Die anderen Links sind erstmal Platzhalter, dessen dynamischer Inhalt später mit PHP in die index.php eingefügt wird. Alle anderen Links führen auf eine 404-Seite.
|
||||
## Login-Informationen für Dummy-User
|
||||
`Anmeldename, Passwort, Mailadresse`:
|
||||
- `max.mustermann, test12345, mustermann@web.de`
|
||||
|
||||
## Weitere Voraussetzungen zur Nutzung
|
||||
- Per Klick auf das Logo gelangt man auf die Home-Seite.
|
||||
|
||||
## Ausgelassene Teilaufgaben
|
||||
|
||||
## Bekannte Fehler und Mängel
|
||||
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
||||
- Die Suchseite und Kategorieseite packen momentan alle passenden Beiträge untereinander. Später sollen zunächst 10
|
||||
Ergebnisse auf einer Seite angezeigt werden.
|
||||
|
||||
## Besonderheiten des Projektes
|
||||
- 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 sind drei Dummy-Beiträge für den Nutzer max.mustermann hinterlegt.
|
||||
- Die Such-Seite umfasst eine Such- und Sortierfunktion. Jedoch fehlt noch eine
|
||||
Filterfunktion (z.B. nur Mathe anzeigen).
|
||||
|
||||
## Sonstiges
|
||||
- Das Datenschema befindet sich unter /planung/Datenschema.pdf
|
||||
@@ -4,6 +4,14 @@
|
||||
-->
|
||||
<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>
|
||||
<p>
|
||||
Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden.
|
||||
|
||||
+203
-70
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
session_start();
|
||||
$user = $user ?? null;
|
||||
if (!isset($_SESSION["user"])) {
|
||||
header("Location: index.php?pfad=login");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!--
|
||||
Seite: Beitrag erstellen
|
||||
@@ -8,101 +12,230 @@ session_start();
|
||||
<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">
|
||||
<?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
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<input type="text" id="title" name="title"
|
||||
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
||||
placeholder="Titel hier eingeben" required>
|
||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
||||
<?php echo htmlspecialchars($_SESSION['old_content'] ?? ''); unset($_SESSION['old_content']); ?>
|
||||
</textarea>
|
||||
<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>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- Seitenleiste -->
|
||||
<aside class="editor-sidebar">
|
||||
|
||||
<div class="sidebar-block">
|
||||
<button type="submit" class="btn-publish">Veröffentlichen</button>
|
||||
<button type="submit" id="editor-button" class="button">Veröffentlichen</button>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-block">
|
||||
<label for="category">Kategorie <span class="required">*</span></label>
|
||||
<select id="category" name="category" required>
|
||||
<option value="" disabled selected>Kategorie wählen...</option>
|
||||
<option disabled <?php
|
||||
if ((!isset($_SESSION['old_category']) || empty($_SESSION['old_category'])) && (!isset($category) || empty($category))) {
|
||||
echo 'selected';
|
||||
}
|
||||
?>>Kategorie wählen...</option>
|
||||
|
||||
<optgroup label="Sprachen">
|
||||
<option value="deutsch">Deutsch</option>
|
||||
<option value="englisch">Englisch</option>
|
||||
<option value="franzoesisch">Französisch</option>
|
||||
<option value="latein">Latein</option>
|
||||
<option value="literatur">Literatur</option>
|
||||
<option value="deutsch" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'deutsch') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'deutsch') { echo 'selected'; }
|
||||
}
|
||||
?>>Deutsch</option>
|
||||
<option value="englisch" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'englisch') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'englisch') { echo 'selected'; }
|
||||
}
|
||||
?>>Englisch</option>
|
||||
<option value="franzoesisch" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'franzoesisch') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'franzoesisch') { echo 'selected'; }
|
||||
}
|
||||
?>>Französisch</option>
|
||||
<option value="latein" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'latein') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'latein') { echo 'selected'; }
|
||||
}
|
||||
?>>Latein</option>
|
||||
<option value="literatur" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'literatur') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'literatur') { echo 'selected'; }
|
||||
}
|
||||
?>>Literatur</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="MINT">
|
||||
<option value="mathe">Mathematik</option>
|
||||
<option value="biologie">Biologie</option>
|
||||
<option value="chemie">Chemie</option>
|
||||
<option value="physik">Physik</option>
|
||||
<option value="informatik">Informatik</option>
|
||||
<option value="astronomie">Astronomie</option>
|
||||
<option value="mathe" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'mathe') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'mathe') { echo 'selected'; }
|
||||
}
|
||||
?>>Mathematik</option>
|
||||
<option value="biologie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'biologie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'biologie') { echo 'selected'; }
|
||||
}
|
||||
?>>Biologie</option>
|
||||
<option value="chemie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'chemie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'chemie') { echo 'selected'; }
|
||||
}
|
||||
?>>Chemie</option>
|
||||
<option value="physik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'physik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'physik') { echo 'selected'; }
|
||||
}
|
||||
?>>Physik</option>
|
||||
<option value="informatik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'informatik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'informatik') { echo 'selected'; }
|
||||
}
|
||||
?>>Informatik</option>
|
||||
<option value="astronomie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'astronomie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'astronomie') { echo 'selected'; }
|
||||
}
|
||||
?>>Astronomie</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="Gesellschaft & Werte">
|
||||
<option value="geschichte">Geschichte</option>
|
||||
<option value="erdkunde">Erdkunde</option>
|
||||
<option value="sozialkunde">Sozialkunde</option>
|
||||
<option value="wirtschaft">Wirtschaftskunde</option>
|
||||
<option value="religion">Religion</option>
|
||||
<option value="ethik">Ethikunterricht</option>
|
||||
<option value="philosophie">Philosophie</option>
|
||||
<option value="psychologie">Psychologie</option>
|
||||
<option value="kunst">Kunst</option>
|
||||
<option value="musik">Musik</option>
|
||||
<option value="theater">Theater</option>
|
||||
<option value="geschichte" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'geschichte') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'geschichte') { echo 'selected'; }
|
||||
}
|
||||
?>>Geschichte</option>
|
||||
<option value="erdkunde" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'erdkunde') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'erdkunde') { echo 'selected'; }
|
||||
}
|
||||
?>>Erdkunde</option>
|
||||
<option value="sozialkunde" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'sozialkunde') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'sozialkunde') { echo 'selected'; }
|
||||
}
|
||||
?>>Sozialkunde</option>
|
||||
<option value="wirtschaft" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'wirtschaft') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'wirtschaft') { echo 'selected'; }
|
||||
}
|
||||
?>>Wirtschaftskunde</option>
|
||||
<option value="religion" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'religion') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'religion') { echo 'selected'; }
|
||||
}
|
||||
?>>Religion</option>
|
||||
<option value="ethik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'ethik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'ethik') { echo 'selected'; }
|
||||
}
|
||||
?>>Ethikunterricht</option>
|
||||
<option value="philosophie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'philosophie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'philosophie') { echo 'selected'; }
|
||||
}
|
||||
?>>Philosophie</option>
|
||||
<option value="psychologie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'psychologie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'psychologie') { echo 'selected'; }
|
||||
}
|
||||
?>>Psychologie</option>
|
||||
<option value="kunst" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'kunst') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'kunst') { echo 'selected'; }
|
||||
}
|
||||
?>>Kunst</option>
|
||||
<option value="musik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'musik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'musik') { echo 'selected'; }
|
||||
}
|
||||
?>>Musik</option>
|
||||
<option value="theater" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'theater') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'theater') { echo 'selected'; }
|
||||
}
|
||||
?>>Theater</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="Technik & Praxis">
|
||||
<option value="technik">Technik</option>
|
||||
<option value="werken">Werken</option>
|
||||
<option value="hauswirtschaft">Hauswirtschaft</option>
|
||||
<option value="sport">Sport</option>
|
||||
<option value="technik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'technik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'technik') { echo 'selected'; }
|
||||
}
|
||||
?>>Technik</option>
|
||||
<option value="werken" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'werken') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'werken') { echo 'selected'; }
|
||||
}
|
||||
?>>Werken</option>
|
||||
<option value="hauswirtschaft" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'hauswirtschaft') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'hauswirtschaft') { echo 'selected'; }
|
||||
}
|
||||
?>>Hauswirtschaft</option>
|
||||
<option value="sport" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'sport') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'sport') { echo 'selected'; }
|
||||
}
|
||||
?>>Sport</option>
|
||||
</optgroup>
|
||||
|
||||
<?php
|
||||
if (isset($_SESSION['old_category'])) {
|
||||
unset($_SESSION['old_category']);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
+4
-16
@@ -7,19 +7,7 @@ include_once 'php/controller/home-controller.php';
|
||||
Inhalt: Beinhaltet den Inhalt der Startseite
|
||||
-->
|
||||
<main>
|
||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||
<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
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<h1>Home</h1>
|
||||
<p>
|
||||
@@ -34,21 +22,21 @@ include_once 'php/controller/home-controller.php';
|
||||
<!-- Flexbox -->
|
||||
<div class="flexbox">
|
||||
<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">
|
||||
<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 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">
|
||||
<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 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">
|
||||
<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>
|
||||
|
||||
@@ -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>
|
||||
+34
-13
@@ -1,32 +1,53 @@
|
||||
<?php
|
||||
$error = $error ?? null;
|
||||
?>
|
||||
|
||||
<!--
|
||||
Form: Login-Bereich
|
||||
Funktion: Benutzerauthentifizierung und Zugang zum eigenen Profil, Erstellen von Beiträgen, etc.
|
||||
-->
|
||||
<main class="login-page">
|
||||
<div class="login-container">
|
||||
|
||||
|
||||
<h1>Bitte anmelden</h1>
|
||||
|
||||
<form>
|
||||
<label id ="inputEmail" class="screenreader-only">E-Mail Adresse / </label>
|
||||
<?php if ($error): ?>
|
||||
<p style="color:red;">
|
||||
<?php echo htmlspecialchars($error); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="index.php?pfad=login">
|
||||
|
||||
<p class="input-label">Benutzername/E-Mail-Adresse:</p>
|
||||
<input type="email" name="email" class="login-input" placeholder="E-Mail-Adresse" required autofocus>
|
||||
<input type="email"
|
||||
name="email"
|
||||
class="login-input"
|
||||
placeholder="E-Mail-Adresse"
|
||||
required
|
||||
autofocus>
|
||||
|
||||
<p class="input-label">Passwort:</p>
|
||||
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
||||
<input type="password"
|
||||
name="password"
|
||||
class="login-input"
|
||||
placeholder="Passwort"
|
||||
required>
|
||||
|
||||
<div class="checkbox-wrapper">
|
||||
<label>
|
||||
<input type="checkbox" name="remember-me" value="1"> angemeldet bleiben
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">anmelden</button>
|
||||
<button type="submit"
|
||||
value="anmelden"
|
||||
name="loginSubmit"
|
||||
class="button">
|
||||
anmelden
|
||||
</button>
|
||||
|
||||
<div class="register-link">
|
||||
<a href="register.php">Noch keinen Account? Jetzt hier registrieren!</a>
|
||||
<a href="index.php?pfad=register">
|
||||
Noch keinen Account? Jetzt hier registrieren!
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</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>
|
||||
+129
-35
@@ -1,74 +1,148 @@
|
||||
<!--
|
||||
Content: Profil
|
||||
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
||||
-->
|
||||
<?php
|
||||
include_once 'php/controller/profileArticles-controller.php';
|
||||
include_once 'php/controller/profile-controller.php';
|
||||
|
||||
$user = $user ?? null;
|
||||
$isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
||||
?>
|
||||
|
||||
<main class="form-page">
|
||||
<div class="flexbox">
|
||||
<!-- Linke Spalte: Profildaten -->
|
||||
|
||||
<div class="container">
|
||||
<form>
|
||||
|
||||
<?php if (!empty($error)): ?>
|
||||
<p class="alert-message is-error">
|
||||
<?php echo htmlspecialchars($error); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="index.php?pfad=profile">
|
||||
|
||||
<label class="input-label">Vorname</label>
|
||||
<input type="text" name="Vorname" class="login-input" required
|
||||
placeholder="Vorname"
|
||||
value="<?php //DB-Daten ?>">
|
||||
<input type="text"
|
||||
name="vorname"
|
||||
class="login-input"
|
||||
value="<?php echo htmlspecialchars($_POST["vorname"] ?? $user["vorname"] ?? ""); ?>"
|
||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||
required>
|
||||
|
||||
<label class="input-label">Nachname</label>
|
||||
<input type="text" name="Nachname" class="login-input" required
|
||||
placeholder="Nachname"
|
||||
value="<?php //DB-Daten ?>">
|
||||
<input type="text"
|
||||
name="nachname"
|
||||
class="login-input"
|
||||
value="<?php echo htmlspecialchars($_POST["nachname"] ?? $user["nachname"] ?? ""); ?>"
|
||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||
required>
|
||||
|
||||
<label class="input-label">Email-Adresse</label>
|
||||
<input type="email" name="Email" class="login-input" required
|
||||
placeholder="mustermann@web.de"
|
||||
value="<?php //DB-Daten ?>">
|
||||
<input type="email"
|
||||
name="email"
|
||||
class="login-input"
|
||||
value="<?php echo htmlspecialchars($_POST["email"] ?? $user["email"] ?? ""); ?>"
|
||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||
required>
|
||||
|
||||
<label class="input-label">Passwort</label>
|
||||
<input type="password" name="Passwort" class="login-input"
|
||||
required placeholder="Passwort">
|
||||
<label class="input-label">
|
||||
<?php echo $isEditMode ? "Neues Passwort" : "Passwort"; ?>
|
||||
</label>
|
||||
|
||||
<button type="submit" class="login-button">
|
||||
Speichern
|
||||
</button>
|
||||
<?php if ($isEditMode): ?>
|
||||
<input type="password"
|
||||
name="password"
|
||||
class="login-input"
|
||||
placeholder="Leer lassen, wenn es gleich bleiben soll">
|
||||
<?php else: ?>
|
||||
<input type="password"
|
||||
name="password"
|
||||
class="login-input"
|
||||
value="********"
|
||||
readonly>
|
||||
<?php endif; ?>
|
||||
|
||||
<button type="button" class="login-button delete-account-button">
|
||||
<br><br>
|
||||
|
||||
<?php if ($isEditMode): ?>
|
||||
<button type="submit"
|
||||
name="saveProfile"
|
||||
class="button">
|
||||
Speichern
|
||||
</button>
|
||||
|
||||
<a href="index.php?pfad=profile" class="button">
|
||||
Abbrechen
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="index.php?pfad=profile&edit=1" class="button">
|
||||
Bearbeiten
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
</form>
|
||||
|
||||
<br>
|
||||
|
||||
<form action="php/controller/deleteAccount-controller.php" method="POST">
|
||||
<button type="submit"
|
||||
class="button"
|
||||
onclick="return confirm('Möchtest du deinen Account wirklich unwiderruflich löschen?');">
|
||||
Account löschen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Rechte Spalte: Eigene Beiträge -->
|
||||
<div class="container">
|
||||
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<h2 class="section-title">Meine Beiträge</h2>
|
||||
|
||||
<div class="articles-list">
|
||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||
|
||||
<p class="alert-message is-error">
|
||||
Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.
|
||||
</p>
|
||||
|
||||
<?php elseif (isset($userArticles) && count($userArticles) > 0): ?>
|
||||
|
||||
<?php foreach ($userArticles as $userArticle): ?>
|
||||
<!-- Ein einzelner Artikel-Eintrag -->
|
||||
<div class="article-item">
|
||||
<div class="article-meta">
|
||||
<span class="article-date"><?php echo htmlspecialchars($userArticle->getCreationDate()); ?></span>
|
||||
<span class="article-category"><?php echo htmlspecialchars($userArticle->getCategory()); ?></span>
|
||||
<span class="article-date">
|
||||
<?php echo htmlspecialchars($userArticle->getCreationDate()); ?>
|
||||
</span>
|
||||
|
||||
<span class="article-category">
|
||||
<?php echo htmlspecialchars($userArticle->getCategory()); ?>
|
||||
</span>
|
||||
</div>
|
||||
<h3 class="article-title"><?php echo htmlspecialchars($userArticle->getTitle()); ?></h3>
|
||||
|
||||
<h3 class="article-title">
|
||||
<a href="index.php?pfad=showArticle&id=<?php echo $userArticle->getID(); ?>">
|
||||
<?php echo htmlspecialchars($userArticle->getTitle()); ?>
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<?php
|
||||
$tags = $userArticle->getTags();
|
||||
if (isset($tags) && !empty($tags)): ?>
|
||||
if (isset($tags) && !empty($tags)):
|
||||
?>
|
||||
<div class="article-view-bottom-section">
|
||||
<div class="article-view-tags-label">Tags:</div>
|
||||
|
||||
<div class="article-view-tags-list">
|
||||
<?php
|
||||
$tagArray = is_array($tags) ? $tags : explode(',', $tags);
|
||||
|
||||
foreach ($tagArray as $tag):
|
||||
$trimmedTag = trim($tag);
|
||||
|
||||
if (!empty($trimmedTag)):
|
||||
?>
|
||||
<span class="article-view-tag-item"><?php echo htmlspecialchars($trimmedTag); ?></span>
|
||||
<span class="article-view-tag-item">
|
||||
<?php echo htmlspecialchars($trimmedTag); ?>
|
||||
</span>
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
@@ -76,18 +150,38 @@ include_once 'php/controller/profileArticles-controller.php';
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<a href="index.php?pfad=updateArticle&id=<?php echo $userArticle->getID(); ?>" class="edit-link-button">Bearbeiten</a>
|
||||
|
||||
<a href="index.php?pfad=updateArticle&id=<?php echo $userArticle->getID(); ?>"
|
||||
class="edit-link-button">
|
||||
Bearbeiten
|
||||
</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>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p>Du hast noch keine Beiträge erstellt.</p>
|
||||
<button type="button" class="login-button" onclick="window.location.href='index.php?pfad=createArticle';">
|
||||
|
||||
<button type="button"
|
||||
class="button"
|
||||
onclick="window.location.href='index.php?pfad=createArticle';">
|
||||
Beitrag erstellen!
|
||||
</button>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
|
||||
<?php unset($_SESSION["message"]); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+42
-11
@@ -1,3 +1,7 @@
|
||||
<?php
|
||||
$error = $error ?? null;
|
||||
?>
|
||||
|
||||
<!--
|
||||
Form: Registrierung
|
||||
Funktion: Erstellung neuer Benutzerkonten
|
||||
@@ -7,26 +11,53 @@
|
||||
|
||||
<h1>Jetzt Registrieren!</h1>
|
||||
|
||||
<form>
|
||||
<?php if (!empty($error)): ?>
|
||||
<p class="alert-message is-error" style="color:red;">
|
||||
<?php echo htmlspecialchars($error); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="index.php?pfad=register">
|
||||
|
||||
<p class="input-label">Email:</p>
|
||||
<input type="email" name="email" class="login-input" placeholder="mustermann@web.de" required>
|
||||
<input type="email"
|
||||
name="email"
|
||||
class="login-input"
|
||||
placeholder="mustermann@web.de"
|
||||
value="<?php echo htmlspecialchars($_POST["email"] ?? ""); ?>"
|
||||
required>
|
||||
|
||||
<p class="input-label">Vorname:</p>
|
||||
<input type="text" name="vorname" class="login-input" placeholder="Max" required>
|
||||
<input type="text"
|
||||
name="vorname"
|
||||
class="login-input"
|
||||
placeholder="Max"
|
||||
value="<?php echo htmlspecialchars($_POST["vorname"] ?? ""); ?>"
|
||||
required>
|
||||
|
||||
<p class="input-label">Nachname:</p>
|
||||
<input type="text" name="nachname" class="login-input" placeholder="Mustermann" required>
|
||||
<input type="text"
|
||||
name="nachname"
|
||||
class="login-input"
|
||||
placeholder="Mustermann"
|
||||
value="<?php echo htmlspecialchars($_POST["nachname"] ?? ""); ?>"
|
||||
required>
|
||||
|
||||
<p class="input-label">Passwort:</p>
|
||||
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
||||
<input type="password"
|
||||
name="password"
|
||||
class="login-input"
|
||||
placeholder="Passwort"
|
||||
required>
|
||||
|
||||
<div class="checkbox-wrapper">
|
||||
<label>
|
||||
<input type="checkbox" value="remember-me"> angemeldet bleiben
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit"
|
||||
value="register"
|
||||
name="registerSubmit"
|
||||
class="button">
|
||||
kostenlos registrieren
|
||||
</button>
|
||||
|
||||
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">kostenlos registrieren</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
+107
-80
@@ -1,46 +1,79 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$all_results = $_SESSION["search_results"] ?? [];
|
||||
$query = $_SESSION["search_query"] ?? "";
|
||||
$totalResultsCount = count($all_results);
|
||||
|
||||
$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);
|
||||
$resultCount = count($results);
|
||||
|
||||
?>
|
||||
<noscript>
|
||||
Bitte JavaScript aktivieren!
|
||||
</noscript>
|
||||
<!--
|
||||
Seite: Suchergebnisse
|
||||
Inhalt: Zeigt die Ergebnisse einer Suche an
|
||||
-->
|
||||
<div class="s-res-layout-grid">
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<!-- Links: Seitenleiste für Filter und Suche -->
|
||||
<aside class="s-res-sidebar">
|
||||
|
||||
<!-- Suchleiste Box -->
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
||||
<form action="#" method="GET" class="s-res-search-form">
|
||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
||||
<button type="submit" class="nav__search-button">Suchen</button>
|
||||
</form>
|
||||
</div>
|
||||
<form action="php/controller/search-results-controller.php" method="GET" id="search-form-id" class="s-res-sidebar-form">
|
||||
|
||||
<input type="hidden" id="s-res-page-input" name="page" value="<?php echo $_GET['page'] ?? 1; ?>">
|
||||
|
||||
<!-- Sortierfuntion Box -->
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||
<div class="s-res-filter-group">
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="alphabet" checked>
|
||||
<span>Alphabetisch</span>
|
||||
</label>
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="likes">
|
||||
<span>Beliebtheit (Likes)</span>
|
||||
</label>
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="newest">
|
||||
<span>Neueste Beiträge</span>
|
||||
</label>
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="oldest">
|
||||
<span>Älteste Beiträge</span>
|
||||
</label>
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" value="<?php echo htmlspecialchars($query); ?>" maxlength="50" required>
|
||||
<button type="submit" class="nav__search-button">Suchen</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||
<?php $currentSort = $_SESSION['search_sort'] ?? 'alphabet'; ?>
|
||||
<div class="s-res-filter-group">
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="alphabet" class="sort-radio" <?php echo $currentSort === 'alphabet' ? 'checked' : ''; ?>>
|
||||
<span>Alphabetisch</span>
|
||||
</label>
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="newest" class="sort-radio" <?php echo $currentSort === 'newest' ? 'checked' : ''; ?>>
|
||||
<span>Neueste Beiträge</span>
|
||||
</label>
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="oldest" class="sort-radio" <?php echo $currentSort === 'oldest' ? 'checked' : ''; ?>>
|
||||
<span>Älteste Beiträge</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</aside>
|
||||
|
||||
@@ -48,78 +81,72 @@ session_start();
|
||||
|
||||
<div class="s-res-header">
|
||||
<h1 class="s-res-main-title">Suchergebnisse</h1>
|
||||
<p class="s-res-meta">3 Treffer für Ihre Suchanfrage</p>
|
||||
<p class="s-res-meta"><?php echo $totalResultsCount; ?> Treffer für Ihre Suchanfrage "<?php echo htmlspecialchars($query); ?>"</p>
|
||||
</div>
|
||||
|
||||
<!-- Ergebnisliste -->
|
||||
<div class="s-res-list">
|
||||
<?php
|
||||
if (!empty($results)): ?>
|
||||
|
||||
<?php foreach ($results as $item): ?>
|
||||
<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 $item['id']; ?>" class="s-res-link">
|
||||
<?php echo htmlspecialchars($item['title']); ?>
|
||||
</a>
|
||||
</h2>
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($item['author']); ?></span></p>
|
||||
</div>
|
||||
<div class="s-res-arrow">→</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php
|
||||
if(isset($_SESSION['message']) && $_SESSION['message'] == "new_search_results"): ?>
|
||||
<!-- TODO: Hier die Beiträge ausgeben. -->
|
||||
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||
<p>
|
||||
Bitte überprüfe deine Sucheingabe und versuche es erneut!
|
||||
</p>
|
||||
<?php
|
||||
elseif (isset($_SESSION["search_query"]) && $_SESSION["search_query"] !== "" && $resultCount === 0): ?>
|
||||
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
||||
<?php
|
||||
elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||
<p>Bitte überprüfe deine Sucheingabe und versuche es erneut!</p>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
|
||||
<!-- Beispielbeitrag -->
|
||||
<div class="s-res-item">
|
||||
<div class="s-res-content">
|
||||
<h2 class="s-res-item-title">
|
||||
<a href="#" class="s-res-link">Pythagoras</a>
|
||||
</h2>
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name">Max Mustermann</span></p>
|
||||
</div>
|
||||
<div class="s-res-arrow">→</div>
|
||||
</div>
|
||||
|
||||
<!-- Beispielbeitrag -->
|
||||
<div class="s-res-item">
|
||||
<div class="s-res-content">
|
||||
<h2 class="s-res-item-title">
|
||||
<a href="#" class="s-res-link">Pythagoras</a>
|
||||
</h2>
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name">Max Mustermann</span></p>
|
||||
</div>
|
||||
<div class="s-res-arrow">→</div>
|
||||
</div>
|
||||
|
||||
<!-- Beispielbeitrag -->
|
||||
<div class="s-res-item">
|
||||
<div class="s-res-content">
|
||||
<h2 class="s-res-item-title">
|
||||
<a href="#" class="s-res-link">Pythagoras</a>
|
||||
</h2>
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name">Max Mustermann</span></p>
|
||||
</div>
|
||||
<div class="s-res-arrow">→</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="s-res-pagination-footer">
|
||||
|
||||
<!-- Auswahl der Ergebnisse pro Seite -->
|
||||
<div class="s-res-limit-selector">
|
||||
<label for="s-res-per-page" class="s-res-limit-label">Ergebnisse pro Seite:</label>
|
||||
<select id="s-res-per-page" name="limit" class="s-res-limit-select">
|
||||
<option value="10" selected>10</option>
|
||||
<option value="20">20</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
<select id="s-res-per-page" name="limit" class="s-res-limit-select" form="search-form-id" onchange="this.form.submit()">
|
||||
<option value="10" <?php echo $limit === 10 ? 'selected' : ''; ?>>10</option>
|
||||
<option value="20" <?php echo $limit === 20 ? 'selected' : ''; ?>>20</option>
|
||||
<option value="50" <?php echo $limit === 50 ? 'selected' : ''; ?>>50</option>
|
||||
<option value="100" <?php echo $limit === 100 ? 'selected' : ''; ?>>100</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="s-res-page-navigation">
|
||||
<button type="button" class="s-res-page-btn" disabled>«</button>
|
||||
<button type="button" class="s-res-page-btn s-res-page-btn-active">1</button>
|
||||
<button type="button" class="s-res-page-btn">»</button>
|
||||
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage - 1; ?>" <?php echo $currentPage <= 1 ? 'disabled' : ''; ?>>
|
||||
«
|
||||
</button>
|
||||
<!-- Dynamische Seitenzahlen -->
|
||||
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
||||
<button type="button"
|
||||
class="s-res-page-btn <?php echo $i === $currentPage ? 's-res-page-btn-active' : ''; ?>"
|
||||
data-page="<?php echo $i; ?>">
|
||||
<?php echo $i; ?>
|
||||
</button>
|
||||
<?php endfor; ?>
|
||||
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage + 1; ?>" <?php echo $currentPage >= $totalPages ? 'disabled' : ''; ?>>
|
||||
»
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
include_once "php/controller/showCategory-controller.php";
|
||||
?>
|
||||
|
||||
<main>
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<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">→</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
else: ?>
|
||||
<p> Es sind noch keine Beiträge in dieser Kategorie enthalten.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
+209
-84
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
$user = $user ?? null;
|
||||
if (!isset($_SESSION["user"])) {
|
||||
header("Location: index.php?pfad=login");
|
||||
exit();
|
||||
}
|
||||
include_once 'php/controller/showArticle-controller.php';
|
||||
?>
|
||||
<!--
|
||||
@@ -8,119 +13,238 @@ 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">
|
||||
|
||||
<main class="editor-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 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
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
<?php include_once "includes/alertMessages.php"?>
|
||||
|
||||
<input type="text" id="title" name="title"
|
||||
value="<?php
|
||||
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
|
||||
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
||||
if (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
||||
echo htmlspecialchars($_SESSION['old_title']);
|
||||
unset($_SESSION['old_title']);
|
||||
}elseif (isset($title) && !empty($title)){
|
||||
echo htmlspecialchars($title);
|
||||
}
|
||||
|
||||
?>"
|
||||
placeholder="Titel hier eingeben" required>
|
||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
||||
<?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>
|
||||
<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>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- Seitenleiste -->
|
||||
<aside class="editor-sidebar">
|
||||
|
||||
<div class="sidebar-block">
|
||||
<button type="submit" class="btn-publish">Änderungen speichern</button>
|
||||
<button type="submit" id="editor-button" class="button">Änderungen speichern</button>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-block">
|
||||
<label for="category">Kategorie <span class="required">*</span></label>
|
||||
<select id="category" name="category" required>
|
||||
<option disabled selected>Kategorie wählen...</option>
|
||||
<option disabled <?php
|
||||
if ((!isset($_SESSION['old_category']) || empty($_SESSION['old_category'])) && (!isset($category) || empty($category))) {
|
||||
echo 'selected';
|
||||
}
|
||||
?>>Kategorie wählen...</option>
|
||||
|
||||
<optgroup label="Sprachen">
|
||||
<option value="deutsch">Deutsch</option>
|
||||
<option value="englisch">Englisch</option>
|
||||
<option value="franzoesisch">Französisch</option>
|
||||
<option value="latein">Latein</option>
|
||||
<option value="literatur">Literatur</option>
|
||||
<option value="deutsch" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'deutsch') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'deutsch') { echo 'selected'; }
|
||||
}
|
||||
?>>Deutsch</option>
|
||||
<option value="englisch" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'englisch') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'englisch') { echo 'selected'; }
|
||||
}
|
||||
?>>Englisch</option>
|
||||
<option value="franzoesisch" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'franzoesisch') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'franzoesisch') { echo 'selected'; }
|
||||
}
|
||||
?>>Französisch</option>
|
||||
<option value="latein" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'latein') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'latein') { echo 'selected'; }
|
||||
}
|
||||
?>>Latein</option>
|
||||
<option value="literatur" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'literatur') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'literatur') { echo 'selected'; }
|
||||
}
|
||||
?>>Literatur</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="MINT">
|
||||
<option value="mathe">Mathematik</option>
|
||||
<option value="biologie">Biologie</option>
|
||||
<option value="chemie">Chemie</option>
|
||||
<option value="physik">Physik</option>
|
||||
<option value="informatik">Informatik</option>
|
||||
<option value="astronomie">Astronomie</option>
|
||||
<option value="mathe" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'mathe') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'mathe') { echo 'selected'; }
|
||||
}
|
||||
?>>Mathematik</option>
|
||||
<option value="biologie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'biologie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'biologie') { echo 'selected'; }
|
||||
}
|
||||
?>>Biologie</option>
|
||||
<option value="chemie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'chemie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'chemie') { echo 'selected'; }
|
||||
}
|
||||
?>>Chemie</option>
|
||||
<option value="physik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'physik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'physik') { echo 'selected'; }
|
||||
}
|
||||
?>>Physik</option>
|
||||
<option value="informatik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'informatik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'informatik') { echo 'selected'; }
|
||||
}
|
||||
?>>Informatik</option>
|
||||
<option value="astronomie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'astronomie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'astronomie') { echo 'selected'; }
|
||||
}
|
||||
?>>Astronomie</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="Gesellschaft & Werte">
|
||||
<option value="geschichte">Geschichte</option>
|
||||
<option value="erdkunde">Erdkunde</option>
|
||||
<option value="sozialkunde">Sozialkunde</option>
|
||||
<option value="wirtschaft">Wirtschaftskunde</option>
|
||||
<option value="religion">Religion</option>
|
||||
<option value="ethik">Ethikunterricht</option>
|
||||
<option value="philosophie">Philosophie</option>
|
||||
<option value="psychologie">Psychologie</option>
|
||||
<option value="kunst">Kunst</option>
|
||||
<option value="musik">Musik</option>
|
||||
<option value="theater">Theater</option>
|
||||
<option value="geschichte" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'geschichte') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'geschichte') { echo 'selected'; }
|
||||
}
|
||||
?>>Geschichte</option>
|
||||
<option value="erdkunde" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'erdkunde') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'erdkunde') { echo 'selected'; }
|
||||
}
|
||||
?>>Erdkunde</option>
|
||||
<option value="sozialkunde" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'sozialkunde') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'sozialkunde') { echo 'selected'; }
|
||||
}
|
||||
?>>Sozialkunde</option>
|
||||
<option value="wirtschaft" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'wirtschaft') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'wirtschaft') { echo 'selected'; }
|
||||
}
|
||||
?>>Wirtschaftskunde</option>
|
||||
<option value="religion" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'religion') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'religion') { echo 'selected'; }
|
||||
}
|
||||
?>>Religion</option>
|
||||
<option value="ethik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'ethik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'ethik') { echo 'selected'; }
|
||||
}
|
||||
?>>Ethikunterricht</option>
|
||||
<option value="philosophie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'philosophie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'philosophie') { echo 'selected'; }
|
||||
}
|
||||
?>>Philosophie</option>
|
||||
<option value="psychologie" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'psychologie') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'psychologie') { echo 'selected'; }
|
||||
}
|
||||
?>>Psychologie</option>
|
||||
<option value="kunst" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'kunst') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'kunst') { echo 'selected'; }
|
||||
}
|
||||
?>>Kunst</option>
|
||||
<option value="musik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'musik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'musik') { echo 'selected'; }
|
||||
}
|
||||
?>>Musik</option>
|
||||
<option value="theater" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'theater') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'theater') { echo 'selected'; }
|
||||
}
|
||||
?>>Theater</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="Technik & Praxis">
|
||||
<option value="technik">Technik</option>
|
||||
<option value="werken">Werken</option>
|
||||
<option value="hauswirtschaft">Hauswirtschaft</option>
|
||||
<option value="sport">Sport</option>
|
||||
<option value="technik" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'technik') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'technik') { echo 'selected'; }
|
||||
}
|
||||
?>>Technik</option>
|
||||
<option value="werken" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'werken') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'werken') { echo 'selected'; }
|
||||
}
|
||||
?>>Werken</option>
|
||||
<option value="hauswirtschaft" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'hauswirtschaft') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'hauswirtschaft') { echo 'selected'; }
|
||||
}
|
||||
?>>Hauswirtschaft</option>
|
||||
<option value="sport" <?php
|
||||
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||
if ($_SESSION['old_category'] === 'sport') { echo 'selected'; }
|
||||
} elseif (isset($category) && !empty($category)) {
|
||||
if ($category === 'sport') { echo 'selected'; }
|
||||
}
|
||||
?>>Sport</option>
|
||||
</optgroup>
|
||||
|
||||
<?php
|
||||
if (isset($_SESSION['old_category'])) {
|
||||
unset($_SESSION['old_category']);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -128,10 +252,11 @@ include_once 'php/controller/showArticle-controller.php';
|
||||
<label for="tags">Schlagwörter</label>
|
||||
<input type="text" id="tags" name="tags"
|
||||
value="<?php
|
||||
if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);
|
||||
} elseif (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
||||
if (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
||||
echo htmlspecialchars($_SESSION['old_tags']);
|
||||
unset($_SESSION['old_tags']);
|
||||
} elseif (isset($tags) && !empty($tags)){
|
||||
echo htmlspecialchars($tags);
|
||||
}
|
||||
?>"
|
||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||
|
||||
+2
-14
@@ -86,20 +86,8 @@
|
||||
}
|
||||
|
||||
/* Button-Zeugs */
|
||||
.article-editor-scope .btn-publish {
|
||||
background-color: #007cba;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 12px;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.article-editor-scope .btn-publish:hover {
|
||||
background-color: #006ba1;
|
||||
.button#editor-button {
|
||||
padding: 18px 12px;
|
||||
}
|
||||
|
||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||
|
||||
+6
-2
@@ -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;
|
||||
@@ -155,7 +159,7 @@ a, button, input, select, textarea, label, main{
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.login-button {
|
||||
.button {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background-color: #2563eb;
|
||||
@@ -168,7 +172,7 @@ a, button, input, select, textarea, label, main{
|
||||
transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.login-button:hover {
|
||||
.button:hover {
|
||||
background-color: #1d4ed8;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
||||
|
||||
+39
-22
@@ -57,6 +57,10 @@ CSS für die navbar
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.nav__dropdown-menu a:hover {
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
.nav__link {
|
||||
display: inline-block;
|
||||
font-weight: 600;
|
||||
@@ -89,6 +93,12 @@ CSS für die navbar
|
||||
border-radius: 4px; /* Abgerundete Ecken */
|
||||
background: #fff;
|
||||
margin: 0 0.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav__search input {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav__search-button {
|
||||
@@ -115,8 +125,33 @@ CSS für die navbar
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Responsive Anpassung unter 1210px */
|
||||
@media (max-width: 1210px) {
|
||||
.nav__search-form {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav__search {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav__search-button {
|
||||
display: inline-block;
|
||||
background: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
padding: 0.4rem 0.6rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
margin-left: 4px;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Responsive Anpassung unter 1240px */
|
||||
@media (max-width: 1240px) {
|
||||
.nav {
|
||||
flex-wrap: wrap; /* zweite Nav-Zeile*/
|
||||
padding: 0.5rem 1rem;
|
||||
@@ -151,8 +186,8 @@ CSS für die navbar
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||
@media (max-width: 760px) {
|
||||
/* Responsive Anpassungen unter 900px (für z.B. Smartphones) */
|
||||
@media (max-width: 900px) {
|
||||
.nav {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
@@ -189,24 +224,6 @@ CSS für die navbar
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav__search {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav__search-button {
|
||||
display: inline-block;
|
||||
background: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
padding: 0.4rem 0.6rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.nav__search-button:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
[]
|
||||
@@ -1,55 +0,0 @@
|
||||
<!--
|
||||
Artikel: Datenschutz vs Datensicherheit
|
||||
Funktion: Inhalt zum Fach Informatik
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
?>
|
||||
<main>
|
||||
|
||||
<h1>Datenschutz vs Datensicherheit</h1>
|
||||
|
||||
<p>
|
||||
Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig – ob in sozialen Netzwerken, beim
|
||||
Online-Shopping oder dem Einsatz von Bonuskarten, bei der Auswertung von Konsumverhalten und selbstverständlich
|
||||
auch im schulischen Kontext.
|
||||
</p>
|
||||
<h2>
|
||||
Was ist Datenschutz?
|
||||
</h2>
|
||||
<p>
|
||||
Datenschutz bedeutet, dass persönliche Daten nur gesammelt, gespeichert und verwendet werden dürfen, wenn
|
||||
es wirklich nötig ist – und nur für klar festgelegte Zwecke. Es geht darum, die Privatsphäre von Menschen
|
||||
zu schützen.
|
||||
</p>
|
||||
<h2>
|
||||
Was ist Datenschutz?
|
||||
</h2>
|
||||
<p>
|
||||
Datensicherheit umfasst alle technischen und organisatorischen Maßnahmen, die verhindern sollen, dass Daten
|
||||
verloren gehen, beschädigt oder unbemerkt verändert werden. Sie schützt Informationen vor Missbrauch.
|
||||
</p>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
<FilesMatch "\.db">
|
||||
deny from all
|
||||
</FilesMatch>
|
||||
@@ -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"]);
|
||||
?>
|
||||
+113
-68
@@ -1,74 +1,90 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
?>
|
||||
|
||||
<!--
|
||||
Globales Menü, wird via PHP später in alle Seiten eingebunden
|
||||
-->
|
||||
<nav class="nav">
|
||||
<div class="nav__left">
|
||||
<a href="index.php" class="nav__logo">
|
||||
<img src="images/logos/logo_full.png" alt="Logo">
|
||||
</a>
|
||||
<img src="images/logos/logo_full.png" alt="Logo">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Mobile navbar mit Burger-Symbol -->
|
||||
<input type="checkbox" id="nav-toggle" class="nav__checkbox">
|
||||
<label for="nav-toggle" id="mobile-nav">
|
||||
<span>☰</span> <!-- Burger Icon Symbol -->
|
||||
<span>☰</span>
|
||||
</label>
|
||||
|
||||
<ul id="mobile-nav" class="nav__mobile-menu">
|
||||
<li>
|
||||
<label for="nav-toggle" class="nav__close-btn">×</label>
|
||||
</li>
|
||||
<li><a href="index.php?pfad=profile">Profil</a></li>
|
||||
<li><a href="index.php?pfad=login">Anmelden</a></li>
|
||||
<li><a href="index.php?pfad=register">Registrieren</a></li>
|
||||
<li><a href="index.php?pfad=createArticle">Beitrag erstellen</a></li>
|
||||
|
||||
<?php if (isset($_SESSION['user'])): ?>
|
||||
|
||||
<li><a href="index.php?pfad=profile">Profil</a></li>
|
||||
<li><a href="index.php?pfad=logout">Abmelden</a></li>
|
||||
<li><a href="index.php?pfad=createArticle">Beitrag erstellen</a></li>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<li><a href="index.php?pfad=login">Anmelden</a></li>
|
||||
<li><a href="index.php?pfad=register">Registrieren</a></li>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">Sprachen</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=deutsch">Deutsch</a></li>
|
||||
<li><a href="index.php?pfad=englisch">Englisch</a></li>
|
||||
<li><a href="index.php?pfad=franzoesisch">Französisch</a></li>
|
||||
<li><a href="index.php?pfad=latein">Latein</a></li>
|
||||
<li><a href="index.php?pfad=literatur">Literatur</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=englisch">Englisch</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=latein">Latein</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=literatur">Literatur</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">MINT</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=mathe">Mathematik</a></li>
|
||||
<li><a href="index.php?pfad=biologie">Biologie</a></li>
|
||||
<li><a href="index.php?pfad=chemie">Chemie</a></li>
|
||||
<li><a href="index.php?pfad=englisch">Physik</a></li>
|
||||
<li><a href="index.php?pfad=informatik">Informatik</a></li>
|
||||
<li><a href="index.php?pfad=astronomie">Astronomie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=mathe">Mathematik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=biologie">Biologie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=chemie">Chemie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=physik">Physik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=informatik">Informatik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">Gesellschaft & Werte</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=geschichte">Geschichte</a></li>
|
||||
<li><a href="index.php?pfad=erdkunde">Erdkunde</a></li>
|
||||
<li><a href="index.php?pfad=sozialkunde">Sozialkunde</a></li>
|
||||
<li><a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a></li>
|
||||
<li><a href="index.php?pfad=religion">Religion</a></li>
|
||||
<li><a href="index.php?pfad=ethik">Ethikunterricht</a></li>
|
||||
<li><a href="index.php?pfad=philosophie">Philosophie</a></li>
|
||||
<li><a href="index.php?pfad=psychologie">Psychologie</a></li>
|
||||
<li><a href="index.php?pfad=kunst">Kunst</a></li>
|
||||
<li><a href="index.php?pfad=musik">Musik</a></li>
|
||||
<li><a href="index.php?pfad=theater">Theater</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=religion">Religion</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=kunst">Kunst</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=musik">Musik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=theater">Theater</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">Technik & Praxis</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=technik">Technik</a></li>
|
||||
<li><a href="index.php?pfad=werken">Werken</a></li>
|
||||
<li><a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a></li>
|
||||
<li><a href="index.php?pfad=sport">Sport</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=technik">Technik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=werken">Werken</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=sport">Sport</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -78,60 +94,89 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">Sprachen</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=deutsch">Deutsch</a>
|
||||
<a href="index.php?pfad=englisch">Englisch</a>
|
||||
<a href="index.php?pfad=franzoesisch">Französisch</a>
|
||||
<a href="index.php?pfad=latein">Latein</a>
|
||||
<a href="index.php?pfad=literatur">Literatur</a>
|
||||
<a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a>
|
||||
<a href="index.php?pfad=showCategory&category=englisch">Englisch</a>
|
||||
<a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a>
|
||||
<a href="index.php?pfad=showCategory&category=latein">Latein</a>
|
||||
<a href="index.php?pfad=showCategory&category=literatur">Literatur</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">MINT</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=mathe">Mathematik</a>
|
||||
<a href="index.php?pfad=biologie">Biologie</a>
|
||||
<a href="index.php?pfad=chemie">Chemie</a>
|
||||
<a href="index.php?pfad=physik">Physik</a>
|
||||
<a href="index.php?pfad=informatik">Informatik</a>
|
||||
<a href="index.php?pfad=astronomie">Astronomie</a>
|
||||
<a href="index.php?pfad=showCategory&category=mathe">Mathematik</a>
|
||||
<a href="index.php?pfad=showCategory&category=biologie">Biologie</a>
|
||||
<a href="index.php?pfad=showCategory&category=chemie">Chemie</a>
|
||||
<a href="index.php?pfad=showCategory&category=physik">Physik</a>
|
||||
<a href="index.php?pfad=showCategory&category=informatik">Informatik</a>
|
||||
<a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=geschichte">Geschichte</a>
|
||||
<a href="index.php?pfad=erdkunde">Erdkunde</a>
|
||||
<a href="index.php?pfad=sozialkunde">Sozialkunde</a>
|
||||
<a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a>
|
||||
<a href="index.php?pfad=religion">Religion</a>
|
||||
<a href="index.php?pfad=ethik">Ethikunterricht</a>
|
||||
<a href="index.php?pfad=philosophie">Philosophie</a>
|
||||
<a href="index.php?pfad=psychologie">Psychologie</a>
|
||||
<a href="index.php?pfad=kunst">Kunst</a>
|
||||
<a href="index.php?pfad=musik">Musik</a>
|
||||
<a href="index.php?pfad=theater">Theater</a>
|
||||
<a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a>
|
||||
<a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a>
|
||||
<a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a>
|
||||
<a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a>
|
||||
<a href="index.php?pfad=showCategory&category=religion">Religion</a>
|
||||
<a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a>
|
||||
<a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a>
|
||||
<a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a>
|
||||
<a href="index.php?pfad=showCategory&category=kunst">Kunst</a>
|
||||
<a href="index.php?pfad=showCategory&category=musik">Musik</a>
|
||||
<a href="index.php?pfad=showCategory&category=theater">Theater</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">Technik & Praxis</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=technik">Technik</a>
|
||||
<a href="index.php?pfad=werken">Werken</a>
|
||||
<a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a>
|
||||
<a href="index.php?pfad=sport">Sport</a>
|
||||
<a href="index.php?pfad=showCategory&category=technik">Technik</a>
|
||||
<a href="index.php?pfad=showCategory&category=werken">Werken</a>
|
||||
<a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a>
|
||||
<a href="index.php?pfad=showCategory&category=sport">Sport</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__right">
|
||||
<a href="index.php?pfad=profile" class="nav_item nav__link">Profil</a>
|
||||
<div class="nav__search">
|
||||
<?php
|
||||
include_once 'search.php';
|
||||
?>
|
||||
</div>
|
||||
<a href="index.php?pfad=login" class="nav__item nav__button">Anmelden</a>
|
||||
<a href="index.php?pfad=register" class="nav__item nav__button">Registrieren</a>
|
||||
<a href="index.php?pfad=createArticle" class="nav__item nav__button">Beitrag erstellen</a>
|
||||
|
||||
<?php if (isset($_SESSION['user'])): ?>
|
||||
|
||||
<a href="index.php?pfad=profile" class="nav__item nav__link">
|
||||
Profil
|
||||
</a>
|
||||
|
||||
<div class="nav__search">
|
||||
<?php include_once 'search.php'; ?>
|
||||
</div>
|
||||
|
||||
<a href="index.php?pfad=createArticle" class="nav__item nav__button">
|
||||
Beitrag erstellen
|
||||
</a>
|
||||
|
||||
<a href="index.php?pfad=logout" class="nav__item nav__button">
|
||||
Abmelden
|
||||
</a>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<div class="nav__search">
|
||||
<?php include_once 'search.php'; ?>
|
||||
</div>
|
||||
|
||||
<a href="index.php?pfad=login" class="nav__item nav__button">
|
||||
Anmelden
|
||||
</a>
|
||||
|
||||
<a href="index.php?pfad=register" class="nav__item nav__button">
|
||||
Registrieren
|
||||
</a>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
+7
-2
@@ -2,5 +2,10 @@
|
||||
Suchleiste. Wird via PHP später in alle Seiten eingebunden
|
||||
-->
|
||||
<!--<label for="site-search">Suche</label>-->
|
||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
||||
<button type="submit" class="nav__search-button">Suchen</button>
|
||||
<form action="php/controller/search-results-controller.php" method="GET" class="nav__search-form">
|
||||
|
||||
<input type="hidden" name="pfad" value="search-results">
|
||||
|
||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" maxlength="50" required>
|
||||
<button type="submit" class="nav__search-button">Suchen</button>
|
||||
</form>
|
||||
|
||||
@@ -1,52 +1,84 @@
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($abs_path)) {
|
||||
require_once "path.php";
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
ob_start();
|
||||
|
||||
$pfad = $_GET["pfad"] ?? "home";
|
||||
|
||||
/*
|
||||
Controller für Aktionen werden vor der HTML-Ausgabe geladen,
|
||||
damit Weiterleitungen mit header() funktionieren.
|
||||
*/
|
||||
if ($pfad === "login") {
|
||||
include_once "php/controller/login-controller.php";
|
||||
}
|
||||
|
||||
if ($pfad === "register") {
|
||||
include_once "php/controller/register-controller.php";
|
||||
}
|
||||
|
||||
if ($pfad === "logout") {
|
||||
include_once "php/controller/logout-controller.php";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($pfad === "deleteAccount") {
|
||||
include_once "php/controller/deleteAccount-controller.php";
|
||||
exit();
|
||||
}
|
||||
require_once $abs_path . "/php/controller/index-controller.php";
|
||||
?>
|
||||
|
||||
<!--
|
||||
Seite: Index der Lernplattform
|
||||
Funktion: Webseitengerüst, Anzeigen von Content
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<!--
|
||||
Seite: Index der Lernplattform
|
||||
Funktion: Webseitengerüst, Anzeigen von Content
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<link rel="stylesheet" href="css/search-results.css">
|
||||
<link rel="stylesheet" href="css/createArticle.css">
|
||||
<link rel="stylesheet" href="css/profile.css">
|
||||
<link rel="stylesheet" href="css/showArticle.css">
|
||||
<link rel="stylesheet" href="css/message.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<link rel="stylesheet" href="css/search-results.css">
|
||||
<link rel="stylesheet" href="css/createArticle.css">
|
||||
<link rel="stylesheet" href="css/profile.css">
|
||||
<link rel="stylesheet" href="css/showArticle.css">
|
||||
<link rel="stylesheet" href="css/message.css">
|
||||
|
||||
<script src="js/paginator.js" async></script>
|
||||
<script src="js/sorter.js" async></script>
|
||||
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
//Dynamischer Inhalt:
|
||||
if (isset($_GET["pfad"])) {
|
||||
if (file_exists($abs_path . '/content/' . $_GET["pfad"] . '.php')) {
|
||||
include_once $abs_path . '/content/' . $_GET["pfad"] . '.php';
|
||||
} else {
|
||||
include_once $abs_path . '/content/404.php';
|
||||
}
|
||||
} else {
|
||||
include_once $abs_path . '/content/home.php';
|
||||
}
|
||||
include_once $abs_path . '/includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
/*
|
||||
Dynamischer Inhalt:
|
||||
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
||||
*/
|
||||
if (file_exists('content/' . $pfad . '.php')) {
|
||||
include_once 'content/' . $pfad . '.php';
|
||||
} else {
|
||||
include_once 'content/404.php';
|
||||
}
|
||||
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
ob_end_flush();
|
||||
?>
|
||||
@@ -0,0 +1,27 @@
|
||||
function initPaginator() {
|
||||
const form = document.getElementById('search-form-id');
|
||||
const pageInput = document.getElementById('s-res-page-input');
|
||||
const pageButtons = document.querySelectorAll('.s-res-page-navigation .s-res-page-btn');
|
||||
|
||||
pageButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
if (this.disabled) return;
|
||||
|
||||
const targetPage = this.getAttribute('data-page');
|
||||
|
||||
if (targetPage && form && pageInput) {
|
||||
pageInput.value = targetPage;
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ist das DOM bereits vollständig aufgebaut?
|
||||
if (document.readyState === 'loading') {
|
||||
// Falls noch geladen wird, auf das Event warten
|
||||
document.addEventListener('DOMContentLoaded', initPaginator);
|
||||
} else {
|
||||
// Falls das HTML bereits komplett da ist, sofort ausführen
|
||||
initPaginator();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
function initClientSorter() {
|
||||
const listContainer = document.querySelector('.s-res-list');
|
||||
const sortRadios = document.querySelectorAll('.sort-radio');
|
||||
|
||||
// wenn keine liste vorhanden, abbrechen
|
||||
if (!listContainer || sortRadios.length === 0) return;
|
||||
|
||||
sortRadios.forEach(radio => {
|
||||
radio.addEventListener('change', function() {
|
||||
const cards = Array.from(listContainer.querySelectorAll('.s-res-item'));
|
||||
const sortValue = this.value;
|
||||
|
||||
cards.sort((a, b) => {
|
||||
if (sortValue === 'alphabet') {
|
||||
// alphabetische sortierung
|
||||
const titleA = a.querySelector('.s-res-link').textContent.trim().toLowerCase();
|
||||
const titleB = b.querySelector('.s-res-link').textContent.trim().toLowerCase();
|
||||
return titleA.localeCompare(titleB);
|
||||
}
|
||||
else if (sortValue === 'newest' || sortValue === 'oldest') {
|
||||
// hoehere ID wird als neuer gesehen
|
||||
const urlA = a.querySelector('.s-res-link').getAttribute('href');
|
||||
const urlB = b.querySelector('.s-res-link').getAttribute('href');
|
||||
|
||||
const idA = parseInt(urlA.match(/id=(\d+)/)[1], 10);
|
||||
const idB = parseInt(urlB.match(/id=(\d+)/)[1], 10);
|
||||
|
||||
return sortValue === 'newest' ? idB - idA : idA - idB;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
listContainer.innerHTML = '';
|
||||
cards.forEach(card => listContainer.appendChild(card));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ist das DOM bereits vollständig aufgebaut?
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initClientSorter);
|
||||
} else {
|
||||
initClientSorter();
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
// mit $_SERVER['DOCUMENT_ROOT'] später umbauen?
|
||||
$abs_path = __DIR__;
|
||||
?>
|
||||
@@ -1,86 +1,90 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
require_once '../model/LocalArticleManager.php';
|
||||
require_once '../model/ArticleManager.php';
|
||||
require_once '../validator/article-validator.php';
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
||||
|
||||
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||
$_SESSION["message"] = "missing_parameters";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
} else {
|
||||
$title = $_POST["title"];
|
||||
$content = $_POST["content"];
|
||||
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||
$category = $_POST["category"];
|
||||
$tags = $_POST['tags'] ?? '';
|
||||
|
||||
// -------------------------------- Validierung der Daten: -------------------------
|
||||
if (!articleAuthorValidator($author)) {
|
||||
$_SESSION["message"] = "author_not_valid";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleTitleValidator($title)) {
|
||||
$_SESSION["message"] = "invalid_title";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleContentValidator($content)) {
|
||||
$_SESSION["message"] = "invalid_content";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleCategoryValidator($category)) {
|
||||
$_SESSION["message"] = "invalid_category";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleTagValidator($tags)) {
|
||||
$_SESSION["message"] = "invalid_tags";
|
||||
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||
$_SESSION["message"] = "missing_parameters";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
} else {
|
||||
$cleanedTags = [];
|
||||
$rawTags = explode(',', $tags);
|
||||
foreach ($rawTags as $rawTag) {
|
||||
// Leerzeichen am Anfang/Ende des einzelnen Tags entfernen:
|
||||
$tag = trim($rawTag);
|
||||
$cleanedTags[] = $tag;
|
||||
$title = $_POST["title"];
|
||||
$content = $_POST["content"];
|
||||
$author = $_SESSION["user_email"];
|
||||
$category = $_POST["category"];
|
||||
$tags = $_POST['tags'] ?? '';
|
||||
|
||||
// -------------------------------- Validierung der Daten: -------------------------
|
||||
if (!articleAuthorValidator($author)) {
|
||||
$_SESSION["message"] = "author_not_valid";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
// Duplikate entfernen:
|
||||
$cleanedTags = array_unique($cleanedTags);
|
||||
$cleanedTags = implode(',', $cleanedTags);
|
||||
}
|
||||
// ----------------- Übertragung der validierten Daten in ArticleManager: ---------------------------
|
||||
try {
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
$articleManager->addArticle($title, $content, $author, $category, $cleanedTags);
|
||||
|
||||
// Formulardaten nach erfolgreichem Erstellen aus der Session löschen
|
||||
unset($_SESSION["old_title"], $_SESSION["old_content"], $_SESSION["old_category"], $_SESSION["old_tags"]);
|
||||
if (!articleTitleValidator($title)) {
|
||||
$_SESSION["message"] = "invalid_title";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
} catch (Exception $e){
|
||||
$_SESSION["message"] = "internal_error";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
if (!articleContentValidator($content)) {
|
||||
$_SESSION["message"] = "invalid_content";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleCategoryValidator($category)) {
|
||||
$_SESSION["message"] = "invalid_category";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleTagValidator($tags)) {
|
||||
$_SESSION["message"] = "invalid_tags";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
} else {
|
||||
$cleanedTags = [];
|
||||
$rawTags = explode(',', $tags);
|
||||
foreach ($rawTags as $rawTag) {
|
||||
// Leerzeichen am Anfang/Ende des einzelnen Tags entfernen:
|
||||
$tag = trim($rawTag);
|
||||
$cleanedTags[] = $tag;
|
||||
}
|
||||
// Duplikate entfernen:
|
||||
$cleanedTags = array_unique($cleanedTags);
|
||||
$cleanedTags = implode(',', $cleanedTags);
|
||||
}
|
||||
// ----------------- Übertragung der validierten Daten in ArticleManager: ---------------------------
|
||||
try {
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
$articleManager->addArticle($title, $content, $author, $category, $cleanedTags);
|
||||
|
||||
// Formulardaten nach erfolgreichem Erstellen aus der Session löschen
|
||||
unset($_SESSION["old_title"], $_SESSION["old_content"], $_SESSION["old_category"], $_SESSION["old_tags"]);
|
||||
|
||||
} catch (Exception $e){
|
||||
$_SESSION["message"] = "internal_error";
|
||||
header("location: ../../index.php?pfad=createArticle");
|
||||
exit();
|
||||
}
|
||||
|
||||
$_SESSION["message"] = "new_article";
|
||||
// Weiterleitung zur Homepage
|
||||
header("location: ../../index.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
$_SESSION["message"] = "new_article";
|
||||
// Weiterleitung zur Homepage
|
||||
header("location: ../../index.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
require_once __DIR__ . "/../model/UserManager.php";
|
||||
require_once __DIR__ . "/../model/ArticleManager.php";
|
||||
|
||||
/*
|
||||
Deregistrierung
|
||||
Funktion: Entfernt User aus der Datenbank und beendet die Session
|
||||
*/
|
||||
|
||||
try {
|
||||
|
||||
$dao = UserManager::getInstance();
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
|
||||
if (isset($_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_destroy();
|
||||
|
||||
header("Location: ../../index.php");
|
||||
exit();
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
$_SESSION["message"] = "internal_error";
|
||||
|
||||
header("Location: ../../index.php?pfad=profile");
|
||||
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
|
||||
session_start();
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
require_once 'php/model/Article.php';
|
||||
require_once 'php/model/ArticleManager.php';
|
||||
require_once 'php/model/LocalArticleManager.php';
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/UserManager.php";
|
||||
|
||||
$error = null;
|
||||
|
||||
/*
|
||||
Verarbeitung des Login-Formulars
|
||||
Funktion: Prüft Benutzerdaten und erstellt Session für eingeloggten Nutzer
|
||||
*/
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
try {
|
||||
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
$email = $_POST["email"] ?? "";
|
||||
$password = $_POST["password"] ?? "";
|
||||
|
||||
$user = $dao->findUser($email);
|
||||
|
||||
if ($user && password_verify($password, $user["password"])) {
|
||||
|
||||
$_SESSION["user"] = $user["vorname"] . " " . $user["nachname"];
|
||||
$_SESSION["user_email"] = $user["email"];
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
|
||||
} else {
|
||||
$error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben.";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error = "Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$_SESSION = [];
|
||||
session_destroy();
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/UserManager.php";
|
||||
require_once "php/model/Article.php";
|
||||
require_once "php/model/ArticleManager.php";
|
||||
require_once "php/validator/user-validator.php";
|
||||
|
||||
$error = null;
|
||||
|
||||
if (!isset($_SESSION["user"])) {
|
||||
header("Location: index.php?pfad=login");
|
||||
exit();
|
||||
}
|
||||
|
||||
try {
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||
|
||||
if (!$user) {
|
||||
$_SESSION = [];
|
||||
session_destroy();
|
||||
|
||||
header("Location: index.php?pfad=login");
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["saveProfile"])) {
|
||||
$oldEmail = $_SESSION["user_email"];
|
||||
|
||||
$newEmail = trim($_POST["email"] ?? "");
|
||||
$vorname = trim($_POST["vorname"] ?? "");
|
||||
$nachname = trim($_POST["nachname"] ?? "");
|
||||
$password = $_POST["password"] ?? "";
|
||||
|
||||
if (!userEmailValidator($newEmail)) {
|
||||
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} elseif (!userNameValidator($vorname)) {
|
||||
$error = "Der Vorname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} elseif (!userNameValidator($nachname)) {
|
||||
$error = "Der Nachname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} elseif (!userOptionalPasswordValidator($password)) {
|
||||
$error = "Das Passwort muss 5 bis 12 Zeichen lang sein.";
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} else {
|
||||
$updated = $dao->updateUser(
|
||||
$oldEmail,
|
||||
$newEmail,
|
||||
$vorname,
|
||||
$nachname,
|
||||
$password
|
||||
);
|
||||
|
||||
if ($updated) {
|
||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
||||
$_SESSION["user_email"] = $newEmail;
|
||||
|
||||
header("Location: index.php?pfad=profile");
|
||||
exit();
|
||||
} else {
|
||||
$error = "Die Daten konnten nicht gespeichert werden.";
|
||||
$_GET["edit"] = "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
$userArticles = $articleManager->getArticlesByAuthor($_SESSION["user_email"]);
|
||||
|
||||
if (!isset($userArticles)) {
|
||||
$_SESSION["message"] = "user_has_no_articles";
|
||||
}
|
||||
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$error = $e->getMessage();
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error = "Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.";
|
||||
$_SESSION["message"] = "internal_error";
|
||||
$_GET["edit"] = "1";
|
||||
}
|
||||
@@ -3,12 +3,15 @@
|
||||
* Controller für die Liste der eigenen Beiträge eines Nutzers auf der eigenen Profilseite
|
||||
*/
|
||||
|
||||
session_start();
|
||||
require_once 'php/model/Article.php';
|
||||
require_once 'php/model/ArticleManager.php';
|
||||
require_once "php/model/UserManager.php";
|
||||
|
||||
try {
|
||||
$author = "max.mustermann"; // TODO: später Nutzer aus der Session beziehen.
|
||||
$dao = UserManager::getInstance();
|
||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||
|
||||
$author = $user["email"];
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
$userArticles = $articleManager->getArticlesByAuthor($author);
|
||||
if(!isset($userArticles)) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/UserManager.php";
|
||||
require_once "php/validator/user-validator.php";
|
||||
|
||||
$error = null;
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
$email = trim($_POST["email"] ?? "");
|
||||
$vorname = trim($_POST["vorname"] ?? "");
|
||||
$nachname = trim($_POST["nachname"] ?? "");
|
||||
$plainPassword = $_POST["password"] ?? "";
|
||||
|
||||
if (!userEmailValidator($email)) {
|
||||
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||
} elseif (!userNameValidator($vorname)) {
|
||||
$error = "Der Vorname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||
} elseif (!userNameValidator($nachname)) {
|
||||
$error = "Der Nachname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||
} elseif (!userPasswordValidator($plainPassword)) {
|
||||
$error = "Das Passwort muss 5 bis 12 Zeichen lang sein.";
|
||||
} else {
|
||||
try {
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
$password = password_hash($plainPassword, PASSWORD_DEFAULT);
|
||||
|
||||
$dao->addUser($email, $vorname, $nachname, $password);
|
||||
|
||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
||||
$_SESSION["user_email"] = $email;
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$error = $e->getMessage();
|
||||
} catch (Exception $e) {
|
||||
$error = "Die Registrierung konnte nicht gespeichert werden.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,74 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
require_once '../model/LocalArticleManager.php';
|
||||
require_once '../model/ArticleManager.php';
|
||||
require_once '../model/Article.php';
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
if(!isset($_POST["search"])){
|
||||
if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
|
||||
|
||||
$search = trim($_GET["q"]);
|
||||
if (empty($search)) {
|
||||
$_SESSION["search_results"] = [];
|
||||
$_SESSION["search_query"] = "";
|
||||
$_SESSION["message"] = "missing_parameters";
|
||||
header("location: ../../index.php?pfad=search-results");
|
||||
} else {
|
||||
|
||||
$search = $_POST["search"];
|
||||
|
||||
try {
|
||||
|
||||
$articleManager = ArticleManager::getInstance();
|
||||
$articleManager->search($search); // TODO: Methode implementieren.
|
||||
|
||||
$results = $articleManager->search($search);
|
||||
|
||||
$sortStyle = $_GET['sort'] ?? 'alphabet';
|
||||
$_SESSION['search_sort'] = $sortStyle;
|
||||
|
||||
if ($sortStyle === 'alphabet') {
|
||||
// Titel aufsteigend alphabetiisch sortiert
|
||||
usort($results, function($a, $b) {
|
||||
return strcasecmp($a->title, $b->title);
|
||||
});
|
||||
} elseif ($sortStyle === 'newest') {
|
||||
// Datum neu zu alt sortiert
|
||||
usort($results, function($a, $b) {
|
||||
return strcmp($b->creationDate, $a->creationDate);
|
||||
});
|
||||
} elseif ($sortStyle === 'oldest') {
|
||||
// Datum alt zu neu sortiert
|
||||
usort($results, function($a, $b) {
|
||||
return strcmp($a->creationDate, $b->creationDate);
|
||||
});
|
||||
}
|
||||
|
||||
// Ergebnisse werden in ein flaches array umgewandelt, da sont incomplete-PHP error im Ergebnis
|
||||
$safeArrayResults = [];
|
||||
foreach ($results as $obj) {
|
||||
$safeArrayResults[] = [
|
||||
"id" => $obj->id,
|
||||
"title" => $obj->title,
|
||||
"content" => $obj->content,
|
||||
"author" => $obj->author,
|
||||
"category" => $obj->category,
|
||||
"tags" => $obj->tags,
|
||||
"creationDate" => $obj->creationDate
|
||||
];
|
||||
}
|
||||
|
||||
$_SESSION["search_results"] = $safeArrayResults;
|
||||
$_SESSION["search_query"] = $search;
|
||||
$_SESSION["message"] = "new_search_results";
|
||||
|
||||
} catch (Exception $e){
|
||||
$_SESSION["message"] = "internal_error";
|
||||
}
|
||||
$_SESSION["message"] = "new_search_results";
|
||||
// TODO: Liste mit Artikeln in der Suchreihenfolge übertragen.
|
||||
// Weiterleitung zur Suchergebnisanzeige
|
||||
header("location: ../../index.php?pfad=search-results");
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
$sort = $_GET['sort'] ?? 'alphabet';
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10;
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
header("Location: ../../index.php?pfad=search-results&q=" . urlencode($search) . "&sort=" . urlencode($sort) . "&limit=" . $limit . "&page=" . $page);
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
require_once 'php/model/Article.php';
|
||||
require_once 'php/model/ArticleManager.php';
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
?>
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
require_once '../model/LocalArticleManager.php';
|
||||
require_once '../model/ArticleManager.php';
|
||||
require_once '../model/Article.php';
|
||||
@@ -8,7 +11,7 @@ require_once '../validator/article-validator.php';
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
||||
$_SESSION["old_category"] = $_POST["category"] ?? ''; // TODO: die Kategorie im Dropdown setzen, wenn der Editor erneut geöffnet wird.
|
||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
||||
|
||||
if (isset($_GET["id"]) && !empty($_GET["id"])) {
|
||||
@@ -21,43 +24,43 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||
$_SESSION["message"] = "missing_parameters";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
}else{
|
||||
$title = $_POST["title"];
|
||||
$content = $_POST["content"];
|
||||
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||
$author = $_SESSION["user_email"];
|
||||
$category = $_POST["category"];
|
||||
$tags = $_POST['tags'] ?? '';
|
||||
|
||||
// -------------------------------- Validierung der Daten: -------------------------
|
||||
if (!articleAuthorValidator($author)) {
|
||||
$_SESSION["message"] = "author_not_valid";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleTitleValidator($title)) {
|
||||
$_SESSION["message"] = "invalid_title";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleContentValidator($content)) {
|
||||
$_SESSION["message"] = "invalid_content";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleCategoryValidator($category)) {
|
||||
$_SESSION["message"] = "invalid_category";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!articleTagValidator($tags)) {
|
||||
$_SESSION["message"] = "invalid_tags";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
} else {
|
||||
$cleanedTags = [];
|
||||
@@ -82,8 +85,8 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$article->setTags($cleanedTags);
|
||||
$articleManager->updateArticle($id ,$article, $author);
|
||||
} catch (Exception $e){
|
||||
$_SESSION["message"] = "internal_error";
|
||||
header("location: ../../index.php?pfad=updateArticle");
|
||||
$_SESSION["message"] = $e->getMessage();
|
||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||
exit();
|
||||
}
|
||||
$_SESSION["message"] = "article_updated";
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
*/
|
||||
class Article
|
||||
{
|
||||
private $id;
|
||||
private $title;
|
||||
private $content;
|
||||
private $author;
|
||||
private $creationDate;
|
||||
private $category;
|
||||
private $tags;
|
||||
public $id;
|
||||
public $title;
|
||||
public $content;
|
||||
public $author;
|
||||
public $creationDate;
|
||||
public $category;
|
||||
public $tags;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
|
||||
+144
-30
@@ -1,47 +1,161 @@
|
||||
<?php
|
||||
require_once 'LocalArticleManager.php';
|
||||
require_once 'DatabaseArticleManager.php';
|
||||
require_once 'Article.php';
|
||||
|
||||
/**
|
||||
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
||||
* Die Klasse beinhaltet alle Methoden für die Operation mit den Beitrags-Daten.
|
||||
*
|
||||
* @author Niklas Ortmann
|
||||
*/
|
||||
class ArticleManager extends LocalArticleManager
|
||||
class ArticleManager
|
||||
{
|
||||
/**
|
||||
* Diese Methode erstellt, falls noch keine existiert, eine Instanz einer ArticleManager-Implementierung und
|
||||
* erstellt Dummy-Beiträge.
|
||||
*
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
$articleManager = LocalArticleManager::getInstance(); // TODO: später durch DataBaseArticleManager ersetzen.
|
||||
$articleManager = DatabaseArticleManager::getInstance(); // Hier kann zwischen dem lokalen und datenbankbasiertem ArticleManager gewechselt werden.
|
||||
|
||||
// Erstellen von Dummy-Beiträgen:
|
||||
if($articleManager->getArticle(1) == null ){
|
||||
$articleManager->addArticle(
|
||||
"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",
|
||||
"Dreiecke, Dreiecksseiten berechnen"
|
||||
);
|
||||
}
|
||||
if($articleManager->getArticle(2) == null ){
|
||||
$articleManager->addArticle(
|
||||
"Tunneleffekt",
|
||||
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
||||
"max.mustermann",
|
||||
"Physik",
|
||||
"Quantenphysik, Energie"
|
||||
);
|
||||
}
|
||||
if($articleManager->getArticle(3) == null ){
|
||||
$articleManager->addArticle(
|
||||
"Datenschutz vs Datensicherheit",
|
||||
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
|
||||
"max.mustermann",
|
||||
"Informatik",
|
||||
"Daten, DSGVO"
|
||||
);
|
||||
// 100 fiktionale Fachbeiträge:
|
||||
$dummyArticles = [
|
||||
// --- INFORMATIK & MATHE (1-20) ---
|
||||
1 => ["Satz des Pythagoras", "Der Satz des Pythagoras beschreibt das Verhältnis der Seitenlängen in einem rechtwinkligen Dreieck.", "mathe", "Dreiecke, Geometrie"],
|
||||
2 => ["Tunneleffekt", "Der Tunneleffekt beschreibt das quantenmechanische Phänomen, dass Teilchen Barrieren überwinden können.", "physik", "Quantenphysik, Energie"],
|
||||
3 => ["Datenschutz vs Datensicherheit", "Datenschutz schützt Personen, während Datensicherheit Systeme vor unbefugten Zugriffen schützt.", "informatik", "Daten, DSGVO"],
|
||||
4 => ["Einführung in Algorithmen", "Ein Algorithmus ist eine präzise Handlungsanweisung zur Lösung eines vordefinierten Problems.", "informatik", "Code, Logik"],
|
||||
5 => ["Primzahlen im Detail", "Primzahlen sind natürliche Zahlen, die nur durch eins und sich selbst ohne Rest teilbar sind.", "mathe", "Zahlentheorie"],
|
||||
6 => ["Lineare Algebra", "Vektoren und Matrizen bilden das Fundament für moderne Computergrafik und 3D-Engines.", "mathe", "Matrizen, Vektoren"],
|
||||
7 => ["Objektorientierte Programmierung", "Die OOP nutzt Klassen und Objekte, um reale Strukturen im Quellcode abzubilden.", "informatik", "OOP, Klassen"],
|
||||
8 => ["Grundlagen von HTML und CSS", "HTML strukturiert den Inhalt einer Webseite, während CSS für das optische Design zuständig ist.", "informatik", "Web, Frontend"],
|
||||
9 => ["Die Relativitätstheorie", "Einsteins Theorie revolutionierte unser Verständnis von Raum, Zeit und Gravitation massiv.", "physik", "Einstein, Gravitation"],
|
||||
10 => ["Datenbanken und SQL", "Strukturierte Abfragesprachen erlauben das effiziente Speichern und Abrufen großer Datenmengen.", "informatik", "SQL, Datenbank"],
|
||||
11 => ["Wahrscheinlichkeitsrechnung", "Die Stochastik befasst sich mit der mathematischen Analyse von Zufallsexperimenten.", "mathe", "Zufall, Stochastik"],
|
||||
12 => ["Quantencomputing", "Künftige Quantencomputer nutzen Qubits, um komplexe Berechnungen in Rekordzeit zu lösen.", "informatik", "Hardware, Zukunft"],
|
||||
13 => ["Die Fibonacci-Folge", "Diese Zahlenreihe beschreibt mathematische Wachstumsmuster, die oft in der Natur vorkommen.", "mathe", "Zahlen, Natur"],
|
||||
14 => ["Thermodynamik", "Die Hauptsätze der Thermodynamik regeln den Energieaustausch und die Entropie in Systemen.", "physik", "Energie, Wärme"],
|
||||
15 => ["Cybersecurity Grundlagen", "Die Absicherung von Netzwerken erfordert Firewalls, Verschlüsselung und regelmäßige Audits.", "informatik", "Sicherheit, Hacker"],
|
||||
16 => ["Kryptographie", "Asymmetrische Verschlüsselungsverfahren sichern heutzutage den gesamten Datenverkehr im Web.", "informatik", "Krypto, Security"],
|
||||
17 => ["Analysis und Ableitungen", "Die Differentialrechnung untersucht die lokalen Änderungsraten von mathematischen Funktionen.", "mathe", "Analysis, Funktionen"],
|
||||
18 => ["Schwarze Löcher", "Diese Regionen im Raum besitzen eine so starke Gravitation, dass selbst Licht nicht entkommt.", "physik", "Astronomie, Kosmos"],
|
||||
19 => ["Git Versionsverwaltung", "Git erlaubt Entwicklern das parallele Arbeiten an Code-Projekten ohne Datenverlust.", "informatik", "Git, DevOps"],
|
||||
20 => ["Künstliche Intelligenz", "Neuronale Netze versuchen das menschliche Gehirn für maschinelles Lernen nachzubilden.", "informatik", "KI, Software"],
|
||||
|
||||
// --- CHEMIE & BIOLOGIE (21-40) ---
|
||||
21 => ["Das Periodensystem", "Die Elemente sind nach ihrer Ordnungszahl und chemischen Eigenschaften geordnet.", "chemie", "Elemente, Moleküle"],
|
||||
22 => ["Photosynthese", "Pflanzen wandeln mithilfe von Sonnenlicht Kohlendioxid und Wasser in Glukose und Sauerstoff um.", "biologie", "Pflanzen, Energie"],
|
||||
23 => ["Aufbau einer Zelle", "Die Zelle ist die kleinste lebende Einheit aller Organismen mit spezialisierten Organellen.", "biologie", "Zellen, Biologie"],
|
||||
24 => ["Säuren und Basen", "Der pH-Wert misst die Konzentration von Wasserstoff-Ionen in einer wässrigen Lösung.", "chemie", "Labor, pH-Wert"],
|
||||
25 => ["Die DNA-Struktur", "Die Doppelhelix enthält den genetischen Bauplan für die Entwicklung aller Lebewesen.", "biologie", "Genetik, Erbgut"],
|
||||
26 => ["Chemische Bindungen", "Kovalente Bindungen entstehen durch das Teilen von Elektronenpaaren zwischen Atomen.", "chemie", "Atome, Bindung"],
|
||||
27 => ["Das Immunsystem", "Weiße Blutkörperchen und Antikörper schützen den menschlichen Körper vor Krankheitserregern.", "biologie", "Gesundheit, Abwehr"],
|
||||
28 => ["Katalysatoren", "Katalysatoren beschleunigen chemische Reaktionen, ohne dabei selbst verbraucht zu werden.", "chemie", "Reaktion, Chemie"],
|
||||
29 => ["Ökosystem Wald", "Das Zusammenspiel von Flora, Fauna und Klima bildet ein hochsensibles ökologisches System.", "biologie", "Natur, Wald"],
|
||||
30 => ["Die Mendelschen Regeln", "Diese Grundgesetze der Vererbung beschreiben, wie Merkmale an Nachkommen weitergegeben werden.", "biologie", "Genetik, Erbung"],
|
||||
31 => ["Zustandsformen der Materie", "Fest, flüssig und gasförmig sind die klassischen Aggregatzustände von Stoffen.", "chemie", "Physik, Materie"],
|
||||
32 => ["Evolutionstheorie", "Charles Darwin begründete die Theorie der natürlichen Auslese und Anpassung von Arten.", "biologie", "Darwin, Evolution"],
|
||||
33 => ["Organische Chemie", "Die Chemie der Kohlenstoffverbindungen bildet die Basis für alles bekannte Leben.", "chemie", "Kohlenstoff, Chemie"],
|
||||
34 => ["Das menschliche Gehirn", "Milliarden von Neuronen kommunizieren über Synapsen, um Reize und Gedanken zu verarbeiten.", "biologie", "Neurologie, Nerven"],
|
||||
35 => ["Der Wasserkreislauf", "Verdunstung, Kondensation und Niederschlag halten das Wasser auf der Erde in Bewegung.", "geographie", "Wasser, Klima"],
|
||||
36 => ["Aggregatzustände von Wasser", "Wasser zeigt ungewöhnliche Eigenschaften wie die Dichteanomalie beim Gefrieren.", "chemie", "Wasser, Eis"],
|
||||
37 => ["Blutkreislauf des Menschen", "Das Herz pumpt sauerstoffreiches Blut durch Arterien in alle Organe des Körpers.", "biologie", "Herz, Medizin"],
|
||||
38 => ["Das Ohmsche Gesetz", "Es beschreibt den direkten Zusammenhang zwischen Spannung, Stromstärke und Widerstand.", "physik", "Strom, Elektronik"],
|
||||
39 => ["Plattentektonik", "Die Bewegung der Kontinentalplatten führt zu Erdbeben, Vulkanismus und Gebirgsbildung.", "geographie", "Erde, Geologie"],
|
||||
40 => ["Proteine und Enzyme", "Enzyme wirken als Biokatalysatoren und steuern fast alle Stoffwechselprozesse.", "biologie", "Biochemie, Enzyme"],
|
||||
|
||||
// --- GESCHICHTE & WIRTSCHAFT (41-60) ---
|
||||
41 => ["Das Römische Reich", "Vom Stadtstaat zum Weltreich prägte Rom die Rechts- und Kulturgeschichte Europas.", "geschichte", "Antike, Rom"],
|
||||
42 => ["Die Französische Revolution", "Freiheit, Gleichheit, Brüderlichkeit beendeten 1789 die absolute Monarchie in Frankreich.", "geschichte", "Europa, Politik"],
|
||||
43 => ["Inflation erklärt", "Inflation bezeichnet die kontinuierliche Geldentwertung und den Kaufkraftverlust.", "wirtschaft", "Geld, Finanzen"],
|
||||
44 => ["Die Industrielle Revolution", "Die Erfindung der Dampfmaschine veränderte die Produktion und die Gesellschaft tiefgreifend.", "geschichte", "Industrie, Arbeit"],
|
||||
45 => ["Angebot und Nachfrage", "Dieses fundamentale Marktgesetz bestimmt den Preis von Gütern in einer freien Wirtschaft.", "wirtschaft", "Markt, Preise"],
|
||||
46 => ["Der Buchdruck", "Johannes Gutenbergs Erfindung revolutionierte die Verbreitung von Wissen im Mittelalter.", "geschichte", "Medien, Wissen"],
|
||||
47 => ["Die Entdeckung Amerikas", "Kolumbus' Seereise im Jahr 1492 leitete das Zeitalter der Kolonialisierung ein.", "geschichte", "Entdeckung, Seefahrt"],
|
||||
48 => ["Kryptowährungen", "Bitcoin nutzt Blockchain-Technologie, um dezentralen digitalen Werttransfer zu erlauben.", "wirtschaft", "Blockchain, Finanzen"],
|
||||
49 => ["Das antike Griechenland", "Die Wiege der Demokratie und Philosophie brachte Denker wie Sokrates und Platon hervor.", "geschichte", "Antike, Philosophie"],
|
||||
50 => ["Globalisierung", "Die weltweite Verflechtung in Wirtschaft, Kultur und Politik bringt Chancen und Risiken.", "wirtschaft", "Weltwirtschaft, Handel"],
|
||||
51 => ["Der Dreißigjährige Krieg", "Ein religiöser und politischer Konflikt verwüstete zwischen 1618 und 1648 Mitteleuropa.", "geschichte", "Krieg, Europa"],
|
||||
52 => ["Die Weimarer Republik", "Die erste deutsche Demokratie scheiterte an wirtschaftlichen und politischen Krisen.", "geschichte", "Deutschland, Weimar"],
|
||||
53 => ["Aktien und Börse", "Unternehmen beschaffen sich Kapital durch die Ausgabe von Anteilen an Investoren.", "wirtschaft", "Aktien, Investieren"],
|
||||
54 => ["Das alte Ägypten", "Pharaonen, Pyramiden und Hieroglyphen zeugen von einer hochentwickelten Hochkultur am Nil.", "geschichte", "Ägypten, Antike"],
|
||||
55 => ["Der Kalte Krieg", "Das Wettrüsten zwischen USA und UdSSR prägte die globale Politik der Nachkriegszeit.", "geschichte", "Ost-West, Politik"],
|
||||
56 => ["Zentralbanken und Leitzins", "Durch Zinsänderungen steuern Notenbanken die Geldmenge und bekämpfen Inflation.", "wirtschaft", "Zinsen, Geldpolitik"],
|
||||
57 => ["Die Seidenstraße", "Das historische Netzwerk von Handelsrouten verband über Jahrhunderte Asien und Europa.", "geschichte", "Handel, Asien"],
|
||||
58 => ["Das Mittelalter", "Ritter, Burgen und das Feudalsystem prägten diese tausendjährige Epoche Europas.", "geschichte", "Mittelalter, Feudalismus"],
|
||||
59 => ["Planwirtschaft vs Marktwirtschaft", "Zentrale staatliche Steuerung steht dem freien Spiel der Marktkräfte gegenüber.", "wirtschaft", "Systeme, Wirtschaft"],
|
||||
60 => ["Die Berliner Mauer", "Ihr Bau 1961 zementierte die Teilung Deutschlands, ihr Fall 1989 beendete sie.", "geschichte", "DDR, Wiedervereinigung"],
|
||||
|
||||
// --- ANWENDUNGEN & WEITERE THEMEN (61-100) ---
|
||||
61 => ["Cloud Computing", "Das Auslagern von Rechenleistung in das Internet spart lokale IT-Infrastruktur ein.", "informatik", "Cloud, Web"],
|
||||
62 => ["Responsive Webdesign", "Moderne Webseiten passen ihr Layout dynamisch an Smartphones und Desktops an.", "informatik", "Design, CSS"],
|
||||
63 => ["Der Treibhauseffekt", "Gase in der Atmosphäre verhindern das Entweichen von Wärme ins Weltall.", "physik", "Klima, Umwelt"],
|
||||
64 => ["Mechanik und Kräfte", "Die Newtonschen Axiome beschreiben, wie Kräfte auf Körper wirken und sie bewegen.", "physik", "Newton, Kraft"],
|
||||
65 => ["Die Mendelschen Gesetze", "Die Vererbung von Genen folgt klaren statistischen Wahrscheinlichkeiten.", "biologie", "Genetik, Erbsen"],
|
||||
66 => ["Lichtgeschwindigkeit", "Im Vakuum bewegt sich Licht mit knapp 300.000 Kilometern pro Sekunde.", "physik", "Licht, Relativität"],
|
||||
67 => ["Die Funktion von APIs", "Programmierschnittstellen erlauben den Datenaustausch zwischen verschiedenen Systemen.", "informatik", "API, Schnittstelle"],
|
||||
68 => ["Der Goldstandard", "Ein historischen Währungssystem, bei dem Geld durch echtes Gold gedeckt war.", "wirtschaft", "Gold, Währung"],
|
||||
69 => ["Der Wiener Kongress", "1815 ordneten die europäischen Mächte die Landkarte nach den Napoleonischen Kriegen neu.", "geschichte", "Europa, Diplomatie"],
|
||||
70 => ["Integrierte Schaltkreise", "Mikrochips enthalten Millionen Transistoren auf kleinstem Raum für Logikschaltungen.", "informatik", "Hardware, Chips"],
|
||||
71 => ["Die Magellan-Expedition", "Die erste erfolgreiche Weltumsegelung bewies praktisch die Kugelgestalt der Erde.", "geschichte", "Seefahrt, Erde"],
|
||||
72 => ["Das Internet der Dinge", "Alltagsgegenstände werden vernetzt, um smarte Automatisierungen zu ermöglichen.", "informatik", "IoT, SmartHome"],
|
||||
73 => ["Halbwertszeit", "Die Zeitspanne, in der sich die Hälfte der instabilen Atome radioaktiv abbaut.", "physik", "Atomphysik, Strahlung"],
|
||||
74 => ["Elektromagnetismus", "Die Verknüpfung von elektrischen Strömen und magnetischen Feldern treibt Motoren an.", "physik", "Strom, Magnet"],
|
||||
75 => ["Das Ökosystem Meer", "Ozeane regulieren das Weltklima und bieten Lebensraum für unzählige Arten.", "biologie", "Meer, Ökologie"],
|
||||
76 => ["Einführung in Docker", "Containerisierung isoliert Anwendungen samt Abhängigkeiten für stabilen Betrieb.", "informatik", "Docker, DevOps"],
|
||||
77 => ["Das Römische Recht", "Viele moderne europäische Gesetzbücher basieren auf antiken römischen Rechtsprinzipien.", "geschichte", "Recht, Gesetz"],
|
||||
78 => ["Verhaltensbiologie", "Untersuchung von angeborenen und erlernten Verhaltensweisen bei Mensch und Tier.", "biologie", "Verhalten, Tiere"],
|
||||
79 => ["Verschlüsselung im Alltag", "HTTPS schützt Passwörter und Zahlungsdaten beim Surfen vor dem Mitlesen.", "informatik", "Web, HTTPS"],
|
||||
80 => ["Die Magna Carta", "1215 schränkte dieses Dokument die absolute Macht des englischen Königs ein.", "geschichte", "England, Verfassung"],
|
||||
81 => ["Marktversagen", "Wenn der freie Markt Ressourcen unvollständig verteilt, muss der Staat eingreifen.", "wirtschaft", "Markt, Staat"],
|
||||
82 => ["Optische Linsen", "Konvexe und konkave Linsen brechen Licht für Brillen, Mikroskope und Kameras.", "physik", "Optik, Licht"],
|
||||
83 => ["Die Entstehung der Erde", "Vor rund 4,5 Milliarden Jahren ballte sich kosmischer Staub zu unserem Planeten.", "geographie", "Erde, Kosmos"],
|
||||
84 => ["Grundlagen von JavaScript", "Diese Skriptsprache macht statische Webseiten interaktiv und dynamisch nutzbar.", "informatik", "JS, Webentwicklung"],
|
||||
85 => ["Die industrielle Landwirtschaft", "Moderne Techniken sichern Welternährung, belasten jedoch oft die Umwelt.", "biologie", "Landwirtschaft, Umwelt"],
|
||||
86 => ["Das Schwarze Jahr 1929", "Der New Yorker Börsencrash löste die verheerende Weltwirtschaftskrise aus.", "geschichte", "Krise, Finanzen"],
|
||||
87 => ["Die Evolution des Menschen", "Der Stammbaum des Homo Sapiens entwickelte sich über Millionen Jahre in Afrika.", "biologie", "Mensch, Evolution"],
|
||||
88 => ["Einführung in Linux", "Das Open-Source-Betriebssystem bildet das Rückgrat moderner Server-Infrastrukturen.", "informatik", "Linux, OS"],
|
||||
89 => ["Der Urknall", "Die Urknalltheorie beschreibt den Beginn des Universums aus einer Singularität.", "physik", "Astronomie, Urknall"],
|
||||
90 => ["Das Periodensystem der Elemente", "Dmitri Mendelejew ordnete Elemente logisch nach ihren Atommassen.", "chemie", "Periodensystem, Chemie"],
|
||||
91 => ["Die Hanse", "Ein mächtiger mittelalterlicher Bund von Kaufleuten dominierte den Nordseehandel.", "geschichte", "Handel, Mittelalter"],
|
||||
92 => ["Wirtschaftswachstum", "Die Steigerung des Bruttoinlandsprodukts gilt oft als Indikator für Wohlstand.", "wirtschaft", "BIP, Finanzen"],
|
||||
93 => ["Neuronale Netze", "Diese Strukturen lernen durch mathematische Gewichtung aus riesigen Datenmengen.", "informatik", "KI, Mathematik"],
|
||||
94 => ["Der Erste Weltkrieg", "Der globale Konflikt von 1914 bis 1918 zerstörte das alte europäische Machtgefüge.", "geschichte", "Europa, Krieg"],
|
||||
95 => ["Das Gehirn und Hormone", "Botenstoffe steuern Gefühle, Schlafzyklen und Reaktionen des Körpers.", "biologie", "Medizin, Hormone"],
|
||||
96 => ["SQL Joins erklärt", "Joins verknüpfen Daten aus mehreren Tabellen über gemeinsame Schlüssel.", "informatik", "SQL, Datenbanken"],
|
||||
97 => ["Wellen-Teilchen-Dualismus", "Quantenobjekte zeigen je nach Messaufbau Eigenschaften von Wellen oder Teilchen.", "physik", "Quanten, Licht"],
|
||||
98 => ["Der Absolutismus", "Der Sonnenkönig Ludwig XIV. verkörperte die unbeschränkte Herrschaft des Monarchen.", "geschichte", "Frankreich, Monarchie"],
|
||||
99 => ["Die Funktion von Routern", "Netzwerkgeräte leiten Datenpakete über IP-Adressen an den richtigen Empfänger.", "informatik", "Netzwerk, Internet"],
|
||||
100 => ["Die Entstehung des Geldes", "Vom Tauschhandel über Naturalgeld bis hin zu modernen digitalen Fiat-Währungen.", "wirtschaft", "Geld, Geschichte"]
|
||||
];
|
||||
|
||||
// 10 Dummy-User:
|
||||
$authors = [
|
||||
'max.mustermann@web.de', 'erika.mustermann@web.de', 'john.doe@gmail.com',
|
||||
'jane.doe@gmail.com', 'anna.schmidt@gmx.de', 'thomas.mueller@gmx.de',
|
||||
'sabine.fischer@outlook.com', 'michael.weber@outlook.com', 'julia.wagner@t-online.de',
|
||||
'stefan.becker@t-online.de'
|
||||
];
|
||||
|
||||
foreach ($dummyArticles as $id => $data) {
|
||||
// Falls der Artikel mit der ID noch nicht existiert, lege ihn an
|
||||
if ($articleManager->getArticle($id) == null) {
|
||||
// Verteilt die 10 Autoren gleichmäßig (ID 1 -> Autor 1, ID 10 -> Autor 10, ID 11 -> Autor 1)
|
||||
$authorEmail = $authors[($id - 1) % 10];
|
||||
|
||||
$articleManager->addArticle(
|
||||
$data[0], // Titel
|
||||
$data[1], // Inhalt
|
||||
$authorEmail, // Rotierende Autoren-E-Mail
|
||||
$data[2], // Kategorie
|
||||
$data[3] // Tags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $articleManager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
require_once "Article.php";
|
||||
|
||||
class NotFoundException extends Exception {}
|
||||
class UnauthorizedAccessException extends Exception {}
|
||||
class InternalServerErrorException extends Exception {}
|
||||
|
||||
/**
|
||||
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
||||
*
|
||||
@@ -15,8 +20,7 @@ interface ArticleManagerDAO
|
||||
* @param $category string Kategorie des Beitrages
|
||||
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||
*
|
||||
* Mögliche Exceptions:
|
||||
* TODO Fehlerbeschreibung hinzufügen & tags hinzufügen
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function addArticle($title, $content, $author, $category, $tags);
|
||||
|
||||
@@ -29,34 +33,36 @@ interface ArticleManagerDAO
|
||||
* @param $author
|
||||
* @return void
|
||||
*
|
||||
* TODO: Fehlerbeschreibung hinzufügen
|
||||
* @throws InternalServerErrorException
|
||||
* @throws NotFoundException
|
||||
* @throws UnauthorizedAccessException
|
||||
*/
|
||||
public function updateArticle($id, $article, $author);
|
||||
|
||||
/**
|
||||
* Löscht einen Beitrag aus übergebener ID.
|
||||
* Löscht einen Beitrag aus übergebener ID und dem Nutzer, der die Löschung ausführt.
|
||||
* @param $id
|
||||
* @param $author
|
||||
* @return void
|
||||
*
|
||||
* TODO: Fehlerbeschreibung hinzufügen
|
||||
* @throws InternalServerErrorException
|
||||
* @throws NotFoundException
|
||||
* @throws UnauthorizedAccessException
|
||||
*/
|
||||
public function deleteArticle($id);
|
||||
public function deleteArticle($id, $author);
|
||||
|
||||
/**
|
||||
* Beitrag aufrufen.
|
||||
* $id ID des Beitrags
|
||||
*
|
||||
* @return Article
|
||||
* Mögliche Exceptions:
|
||||
* TODO Fehlerbeschreibung hinzufügen
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getArticle($id);
|
||||
|
||||
/**
|
||||
* Alle Beiträge aufrufen.
|
||||
*
|
||||
* Mögliche Exceptions:
|
||||
* TODO Fehlerbeschreibung hinzufügen
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getAllArticles();
|
||||
|
||||
@@ -64,8 +70,28 @@ interface ArticleManagerDAO
|
||||
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
||||
* @param $author
|
||||
* @return Article[]
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getArticlesByAuthor($author);
|
||||
|
||||
/**
|
||||
* Durchsucht die vorhandenen Beiträge nach einem bestimmten Suchbegriff.
|
||||
* Die Suche prüft, ob das übergebene Keyword im Titel oder im Inhalt eines Beitrags vorkommt.
|
||||
* (Unabhängig von Groß-und Kleinschreibung)
|
||||
* @param string $keyword Der eingegebene Suchbegriff.
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Gibt alle Beiträge einer gegebenen Kategorie aus.
|
||||
* @param $category
|
||||
* @return mixed
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getArticlesByCategory($category);
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
require_once 'ArticleManagerDAO.php';
|
||||
require_once 'Article.php';
|
||||
/**
|
||||
* Klasse: Eine SQLLite3 Lösung des ArticleManagerDAO.
|
||||
*
|
||||
* @author Niklas Ortmann
|
||||
*/
|
||||
class DatabaseArticleManager implements ArticleManagerDAO {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
*
|
||||
* Erstellt die Datenbankverbindung und die Tabelle articles.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (!file_exists(__DIR__ . '/../../db/articles.db')) {
|
||||
try {
|
||||
|
||||
$db = $this->getConnection();
|
||||
|
||||
$db->exec("
|
||||
CREATE TABLE articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author TEXT,
|
||||
category TEXT,
|
||||
tags TEXT,
|
||||
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);");
|
||||
unset($db);
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut die Verbindung zur Datenbank auf.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
private function getConnection()
|
||||
{
|
||||
try {
|
||||
$user = 'root';
|
||||
$pw = null;
|
||||
$dsn = 'sqlite:' . __DIR__ . '/../../db/articles.db';
|
||||
return new PDO($dsn, $user, $pw);
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die DatabaseArticleManager-Instanz zurück.
|
||||
* @return DatabaseArticleManager
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new DatabaseArticleManager();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function addArticle($title, $content, $author, $category, $tags)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "INSERT INTO articles (title, content, author, category, tags)
|
||||
VALUES (:title, :content, :author, :category, :tags);";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
// Verknüpft die übergebenen Parameter exakt mit den SQL-Platzhaltern
|
||||
$success = $command->execute([
|
||||
":title" => $title,
|
||||
":content" => $content,
|
||||
":author" => $author,
|
||||
":category" => $category,
|
||||
":tags" => $tags
|
||||
]);
|
||||
|
||||
if (!$success) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
return intval($db->lastInsertId());
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateArticle($id, $article, $author)
|
||||
{
|
||||
if (empty($article)) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung analog zur lokalen Implementierung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "UPDATE articles
|
||||
SET title = :title, content = :content, author = :author, category = :category, tags = :tags
|
||||
WHERE id = :id;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$success = $command->execute([
|
||||
":id" => $id,
|
||||
":title" => $article->getTitle(),
|
||||
":content" => $article->getContent(),
|
||||
":author" => $author,
|
||||
":category" => $article->getCategory(),
|
||||
":tags" => $article->getTags()
|
||||
]);
|
||||
|
||||
// rowCount() prüft, ob eine Zeile mit dieser ID existierte und geändert werden konnte
|
||||
if (!$success || $command->rowCount() === 0) {
|
||||
// Falls die ID nicht existiert, prüfen wir, ob sie überhaupt da ist
|
||||
if (!$this->getArticle($id)) {
|
||||
throw new NotFoundException("missing_id");
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteArticle($id, $author)
|
||||
{
|
||||
$article = $this->getArticle($id);
|
||||
if (empty($article)) {
|
||||
throw new NotFoundException("not_found_article");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "DELETE FROM articles WHERE id = :id;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
if (!$command->execute([":id" => $id])) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
} catch (PDOException $exc) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticle($id)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles WHERE id = :id;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$command->execute([":id" => $id]);
|
||||
$row = $command->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
return new Article(
|
||||
intval($row['id']),
|
||||
$row['title'],
|
||||
$row['content'],
|
||||
$row['author'],
|
||||
$row['category'],
|
||||
$row['tags'],
|
||||
$row['created']
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllArticles()
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles;";
|
||||
|
||||
$command = $db->query($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$rows = $command->fetchAll(PDO::FETCH_ASSOC);
|
||||
$articles = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$articles[] = new Article(
|
||||
intval($row['id']),
|
||||
$row['title'],
|
||||
$row['content'],
|
||||
$row['author'],
|
||||
$row['category'],
|
||||
$row['tags'],
|
||||
$row['created']
|
||||
);
|
||||
}
|
||||
|
||||
return $articles;
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticlesByAuthor($author)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles WHERE author = :author;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$command->execute([":author" => $author]);
|
||||
$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']
|
||||
);
|
||||
}
|
||||
|
||||
return $filteredArticles;
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticlesByCategory($category)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles WHERE category = :category;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$command->execute([":category" => $category]);
|
||||
$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']
|
||||
);
|
||||
}
|
||||
|
||||
return $filteredArticles;
|
||||
} catch (PDOException $exc) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function search(string $keyword): array
|
||||
{
|
||||
$cleankeyword = trim($keyword);
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
require_once "UserManagerDAO.php";
|
||||
|
||||
/**
|
||||
* Klasse für den Zugriff auf Benutzerdaten über eine SQLite-Datenbank.
|
||||
*
|
||||
* Diese Klasse verwendet PDO, Prepared Statements und speichert
|
||||
* Benutzerdaten in der Datei db/users.db.
|
||||
*/
|
||||
class DatabaseUserManager implements UserManagerDAO {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Konstruktor.
|
||||
*
|
||||
* Erstellt die Benutzerdatenbank und die Tabelle users,
|
||||
* falls diese noch nicht existieren.
|
||||
*
|
||||
* @throws RuntimeException wenn die Datenbank nicht erstellt werden kann
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$db->exec("
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
email TEXT PRIMARY KEY,
|
||||
vorname TEXT NOT NULL,
|
||||
nachname TEXT NOT NULL,
|
||||
password TEXT NOT NULL
|
||||
);
|
||||
");
|
||||
|
||||
unset($db);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Benutzerdatenbank konnte nicht erstellt werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut eine Verbindung zur SQLite-Datenbank auf.
|
||||
*
|
||||
* @return PDO Datenbankverbindung
|
||||
*
|
||||
* @throws RuntimeException wenn keine Verbindung hergestellt werden kann
|
||||
*/
|
||||
private function getConnection()
|
||||
{
|
||||
try {
|
||||
$dsn = 'sqlite:' . __DIR__ . '/../../db/users.db';
|
||||
|
||||
$db = new PDO($dsn, null, null);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
return $db;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Verbindung zur Benutzerdatenbank fehlgeschlagen.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die Singleton-Instanz des DatabaseUserManagers zurück.
|
||||
*
|
||||
* @return DatabaseUserManager Instanz des DatabaseUserManagers
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new DatabaseUserManager();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse des Benutzers
|
||||
*
|
||||
* @return array|null Benutzerdaten als Array oder null,
|
||||
* wenn kein Benutzer gefunden wurde
|
||||
*
|
||||
* @throws RuntimeException wenn der Benutzer nicht geladen werden kann
|
||||
*/
|
||||
public function findUser($email)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "SELECT * FROM users WHERE email = :email";
|
||||
$command = $db->prepare($sql);
|
||||
|
||||
$command->execute([
|
||||
":email" => $email
|
||||
]);
|
||||
|
||||
$user = $command->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
return $user ?: null;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Benutzer konnte nicht geladen werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt einen neuen Benutzer in die Datenbank ein.
|
||||
*
|
||||
* Die Speicherung erfolgt innerhalb einer Transaktion.
|
||||
* Doppelte E-Mail-Adressen werden durch den Primary Key verhindert.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse des Benutzers
|
||||
* @param string $vorname Vorname des Benutzers
|
||||
* @param string $nachname Nachname des Benutzers
|
||||
* @param string $password Passwort-Hash des Benutzers
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn der Benutzer nicht gespeichert werden kann
|
||||
*/
|
||||
public function addUser($email, $vorname, $nachname, $password)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$db->beginTransaction();
|
||||
|
||||
$sql = "
|
||||
INSERT INTO users (email, vorname, nachname, password)
|
||||
VALUES (:email, :vorname, :nachname, :password)
|
||||
";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
|
||||
$command->execute([
|
||||
":email" => $email,
|
||||
":vorname" => $vorname,
|
||||
":nachname" => $nachname,
|
||||
":password" => $password
|
||||
]);
|
||||
|
||||
$db->commit();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
if (isset($db) && $db->inTransaction()) {
|
||||
$db->rollBack();
|
||||
}
|
||||
|
||||
if ($e->getCode() === "23000") {
|
||||
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||
}
|
||||
|
||||
throw new RuntimeException("Benutzer konnte nicht gespeichert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert die Daten eines bestehenden Benutzers.
|
||||
*
|
||||
* Optional kann zusätzlich das Passwort geändert werden.
|
||||
* Wenn kein neues Passwort übergeben wird, bleibt das alte Passwort erhalten.
|
||||
*
|
||||
* @param string $oldEmail Aktuelle E-Mail-Adresse des Benutzers
|
||||
* @param string $newEmail Neue E-Mail-Adresse des Benutzers
|
||||
* @param string $vorname Neuer Vorname des Benutzers
|
||||
* @param string $nachname Neuer Nachname des Benutzers
|
||||
* @param string|null $password Neues Passwort oder null
|
||||
*
|
||||
* @return bool true, wenn der Benutzer aktualisiert wurde,
|
||||
* sonst false
|
||||
*
|
||||
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn der Benutzer nicht aktualisiert werden kann
|
||||
*/
|
||||
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
if (!empty($password)) {
|
||||
$sql = "
|
||||
UPDATE users
|
||||
SET email = :newEmail,
|
||||
vorname = :vorname,
|
||||
nachname = :nachname,
|
||||
password = :password
|
||||
WHERE email = :oldEmail
|
||||
";
|
||||
|
||||
$params = [
|
||||
":newEmail" => $newEmail,
|
||||
":vorname" => $vorname,
|
||||
":nachname" => $nachname,
|
||||
":password" => password_hash($password, PASSWORD_DEFAULT),
|
||||
":oldEmail" => $oldEmail
|
||||
];
|
||||
} else {
|
||||
$sql = "
|
||||
UPDATE users
|
||||
SET email = :newEmail,
|
||||
vorname = :vorname,
|
||||
nachname = :nachname
|
||||
WHERE email = :oldEmail
|
||||
";
|
||||
|
||||
$params = [
|
||||
":newEmail" => $newEmail,
|
||||
":vorname" => $vorname,
|
||||
":nachname" => $nachname,
|
||||
":oldEmail" => $oldEmail
|
||||
];
|
||||
}
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
$command->execute($params);
|
||||
|
||||
return $command->rowCount() > 0;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === "23000") {
|
||||
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||
}
|
||||
|
||||
throw new RuntimeException("Benutzer konnte nicht aktualisiert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
||||
*
|
||||
* @return bool true, wenn der Benutzer gelöscht wurde,
|
||||
* sonst false
|
||||
*
|
||||
* @throws RuntimeException wenn der Benutzer nicht gelöscht werden kann
|
||||
*/
|
||||
public function deleteUser($email)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "DELETE FROM users WHERE email = :email";
|
||||
$command = $db->prepare($sql);
|
||||
|
||||
$command->execute([
|
||||
":email" => $email
|
||||
]);
|
||||
|
||||
return $command->rowCount() > 0;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Benutzer konnte nicht gelöscht werden.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,13 +36,19 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
* Speichert alle Artikel/Beiträge in der Datei.
|
||||
* @param $articles
|
||||
* @return void
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function saveArticle($articles)
|
||||
private function saveArticle($articles)
|
||||
{
|
||||
file_put_contents(
|
||||
$this->file,
|
||||
json_encode($articles, JSON_PRETTY_PRINT)
|
||||
);
|
||||
try{
|
||||
file_put_contents(
|
||||
$this->file,
|
||||
json_encode($articles, JSON_PRETTY_PRINT)
|
||||
);
|
||||
}catch (Exception $e){
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function addArticle($title, $content, $author, $category, $tags)
|
||||
@@ -65,14 +71,12 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
public function updateArticle($id, $article, $author)
|
||||
{
|
||||
if (empty($article)) {
|
||||
// TODO: Implement Exception.
|
||||
return;
|
||||
throw new NotFoundException("not_found_article");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
// TODO: Implement Exception.
|
||||
return;
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
// Beitrag aktualisieren:
|
||||
@@ -92,20 +96,29 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
];
|
||||
$updated = true;
|
||||
break;
|
||||
}else{
|
||||
// TODO: Implement Exception.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Nur speichern, wenn Beitrag geändert wurde:
|
||||
if ($updated) {
|
||||
$this->saveArticle($articles);
|
||||
} else {
|
||||
throw new NotFoundException("missing_id");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteArticle($id)
|
||||
public function deleteArticle($id, $author)
|
||||
{
|
||||
$article = getArticle($id);
|
||||
if (empty($article)) {
|
||||
throw new NotFoundException("not_found_article");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
$articles = $this->getAllArticles();
|
||||
$articleFound = false;
|
||||
|
||||
@@ -168,5 +181,61 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
}
|
||||
return $filteredArticles;
|
||||
}
|
||||
|
||||
|
||||
public function search(string $keyword): array
|
||||
{
|
||||
$articles = $this->getAllArticles();
|
||||
$filteredArticles = [];
|
||||
|
||||
if (!is_array($articles)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$cleanKeyword = strtolower(trim($keyword));
|
||||
|
||||
foreach ($articles as $article) {
|
||||
$title = isset($article['title']) ? strtolower((string)$article['title']) : '';
|
||||
$content = isset($article['content']) ? strtolower((string)$article['content']) : '';
|
||||
|
||||
if (($cleanKeyword !== '' && strpos($title, $cleanKeyword) !== false) ||
|
||||
($cleanKeyword !== '' && strpos($content, $cleanKeyword) !== false)) {
|
||||
|
||||
$filteredArticles[] = new Article(
|
||||
intval($article['id'] ?? 0),
|
||||
$article['title'] ?? '',
|
||||
$article['content'] ?? '',
|
||||
$article['author'] ?? '',
|
||||
$article['category'] ?? '',
|
||||
$article['tags'] ?? '',
|
||||
$article['creationDate'] ?? ''
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
require_once "UserManagerDAO.php";
|
||||
|
||||
class LocalUserManager implements UserManagerDAO {
|
||||
|
||||
private string $file = "data/users.json";
|
||||
|
||||
public static function getInstance(){
|
||||
// TODO: implement the getIsntance method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt alle Benutzer aus der JSON-Datei.
|
||||
*
|
||||
* @return array Liste aller Benutzer
|
||||
* @throws RuntimeException wenn die Datei nicht gelesen werden kann
|
||||
* oder fehlerhafte JSON-Daten enthält
|
||||
*/
|
||||
private function loadUsers() {
|
||||
if (!file_exists($this->file)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$json = file_get_contents($this->file);
|
||||
|
||||
if ($json === false) {
|
||||
throw new RuntimeException("Benutzerdaten konnten nicht gelesen werden.");
|
||||
}
|
||||
|
||||
$users = json_decode($json, true);
|
||||
|
||||
if ($users === null && json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new RuntimeException("Benutzerdaten sind fehlerhaft.");
|
||||
}
|
||||
|
||||
return is_array($users) ? $users : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert alle Benutzer in die JSON-Datei.
|
||||
*
|
||||
* @param array $users Liste aller Benutzer
|
||||
* @return void
|
||||
* @throws RuntimeException wenn die Daten nicht gespeichert werden können
|
||||
*/
|
||||
private function saveUsers($users) {
|
||||
$json = json_encode($users, JSON_PRETTY_PRINT);
|
||||
|
||||
if ($json === false) {
|
||||
throw new RuntimeException("Benutzerdaten konnten nicht umgewandelt werden.");
|
||||
}
|
||||
|
||||
$result = file_put_contents($this->file, $json);
|
||||
|
||||
if ($result === false) {
|
||||
throw new RuntimeException("Benutzerdaten konnten nicht gespeichert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
||||
* @return array|null Benutzerdaten oder null, wenn kein Benutzer gefunden wurde
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
||||
*/
|
||||
public function findUser($email) {
|
||||
$users = $this->loadUsers();
|
||||
|
||||
foreach ($users as $user) {
|
||||
if (isset($user["email"]) && $user["email"] === $email) {
|
||||
|
||||
if (!isset($user["vorname"]) && isset($user["username"])) {
|
||||
$nameParts = explode(" ", $user["username"], 2);
|
||||
$user["vorname"] = $nameParts[0] ?? "";
|
||||
$user["nachname"] = $nameParts[1] ?? "";
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt einen neuen Benutzer hinzu.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse
|
||||
* @param string $vorname Vorname
|
||||
* @param string $nachname Nachname
|
||||
* @param string $password Passwort-Hash
|
||||
* @return void
|
||||
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||
*/
|
||||
public function addUser($email, $vorname, $nachname, $password) {
|
||||
$users = $this->loadUsers();
|
||||
|
||||
foreach ($users as $user) {
|
||||
if (isset($user["email"]) && $user["email"] === $email) {
|
||||
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||
}
|
||||
}
|
||||
|
||||
$users[] = [
|
||||
"email" => $email,
|
||||
"vorname" => $vorname,
|
||||
"nachname" => $nachname,
|
||||
"password" => $password
|
||||
];
|
||||
|
||||
$this->saveUsers($users);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert einen bestehenden Benutzer.
|
||||
*
|
||||
* @param string $oldEmail Alte E-Mail-Adresse
|
||||
* @param string $newEmail Neue E-Mail-Adresse
|
||||
* @param string $vorname Neuer Vorname
|
||||
* @param string $nachname Neuer Nachname
|
||||
* @param string|null $password Neues Passwort oder null
|
||||
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
||||
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||
*/
|
||||
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) {
|
||||
$users = $this->loadUsers();
|
||||
|
||||
foreach ($users as $user) {
|
||||
if (
|
||||
isset($user["email"])
|
||||
&& $user["email"] === $newEmail
|
||||
&& $newEmail !== $oldEmail
|
||||
) {
|
||||
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($users as $i => $user) {
|
||||
if (isset($user["email"]) && $user["email"] === $oldEmail) {
|
||||
$users[$i]["email"] = $newEmail;
|
||||
$users[$i]["vorname"] = $vorname;
|
||||
$users[$i]["nachname"] = $nachname;
|
||||
|
||||
unset($users[$i]["username"]);
|
||||
|
||||
if (!empty($password)) {
|
||||
$users[$i]["password"] = password_hash($password, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
$this->saveUsers($users);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||
*/
|
||||
public function deleteUser($email) {
|
||||
$users = $this->loadUsers();
|
||||
|
||||
foreach ($users as $i => $user) {
|
||||
if (isset($user["email"]) && $user["email"] === $email) {
|
||||
unset($users[$i]);
|
||||
$users = array_values($users);
|
||||
$this->saveUsers($users);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
require_once "LocalUserManager.php";
|
||||
require_once "DatabaseUserManager.php";
|
||||
|
||||
/**
|
||||
* Zentrale Klasse für den Zugriff auf Benutzerdaten.
|
||||
*
|
||||
* Hier kann zwischen lokaler Speicherung und Datenbankspeicherung
|
||||
* gewechselt werden.
|
||||
*/
|
||||
class UserManager {
|
||||
|
||||
public static function getInstance() {
|
||||
$userManager = DatabaseUserManager::getInstance();
|
||||
|
||||
/*
|
||||
* Dummy-User anlegen, falls sie noch nicht existieren.
|
||||
* Passwort für alle User: test12345
|
||||
*/
|
||||
$dummyUsers = [
|
||||
['email' => 'max.mustermann@web.de', 'vorname' => 'Max', 'nachname' => 'Mustermann'],
|
||||
['email' => 'erika.mustermann@web.de', 'vorname' => 'Erika', 'nachname' => 'Mustermann'],
|
||||
['email' => 'john.doe@gmail.com', 'vorname' => 'John', 'nachname' => 'Doe'],
|
||||
['email' => 'jane.doe@gmail.com', 'vorname' => 'Jane', 'nachname' => 'Doe'],
|
||||
['email' => 'anna.schmidt@gmx.de', 'vorname' => 'Anna', 'nachname' => 'Schmidt'],
|
||||
['email' => 'thomas.mueller@gmx.de', 'vorname' => 'Thomas', 'nachname' => 'Müller'],
|
||||
['email' => 'sabine.fischer@outlook.com', 'vorname' => 'Sabine', 'nachname' => 'Fischer'],
|
||||
['email' => 'michael.weber@outlook.com', 'vorname' => 'Michael', 'nachname' => 'Weber'],
|
||||
['email' => 'julia.wagner@t-online.de', 'vorname' => 'Julia', 'nachname' => 'Wagner'],
|
||||
['email' => 'stefan.becker@t-online.de', 'vorname' => 'Stefan', 'nachname' => 'Becker']
|
||||
];
|
||||
|
||||
$passwordHash = password_hash("test12345", PASSWORD_DEFAULT);
|
||||
|
||||
foreach ($dummyUsers as $user) {
|
||||
if ($userManager->findUser($user['email']) == null) {
|
||||
$userManager->addUser(
|
||||
$user['email'],
|
||||
$user['vorname'],
|
||||
$user['nachname'],
|
||||
$passwordHash
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $userManager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Interface für den Zugriff auf Benutzerdaten.
|
||||
*
|
||||
* Definiert die Methoden, die jede UserDAO-Implementierung
|
||||
* bereitstellen muss.
|
||||
*/
|
||||
interface UserManagerDAO {
|
||||
|
||||
/**
|
||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
*
|
||||
* Funktion:
|
||||
* Liefert die gespeicherten Benutzerdaten zu einer E-Mail-Adresse.
|
||||
*
|
||||
* Eingabe:
|
||||
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
||||
*
|
||||
* Ausgabe:
|
||||
* @return array|null Benutzerdaten als Array oder null
|
||||
*
|
||||
* Mögliche Fehler:
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
||||
*/
|
||||
public function findUser($email);
|
||||
|
||||
/**
|
||||
* Fügt einen neuen Benutzer hinzu.
|
||||
*
|
||||
* Funktion:
|
||||
* Erstellt einen neuen Benutzereintrag und speichert ihn
|
||||
* in der jeweiligen Datenquelle.
|
||||
*
|
||||
* Eingabe:
|
||||
* @param string $email E-Mail-Adresse des Benutzers
|
||||
* @param string $vorname Vorname des Benutzers
|
||||
* @param string $nachname Nachname des Benutzers
|
||||
* @param string $password Passwort des Benutzers
|
||||
*
|
||||
* Ausgabe:
|
||||
* @return void
|
||||
*
|
||||
* Mögliche Fehler:
|
||||
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||
*/
|
||||
public function addUser($email, $vorname, $nachname, $password);
|
||||
|
||||
/**
|
||||
* Aktualisiert einen bestehenden Benutzer.
|
||||
*
|
||||
* Funktion:
|
||||
* Ändert die E-Mail-Adresse, den Vornamen, den Nachnamen
|
||||
* und optional das Passwort eines bestehenden Benutzers.
|
||||
*
|
||||
* Eingabe:
|
||||
* @param string $oldEmail Alte E-Mail-Adresse
|
||||
* @param string $newEmail Neue E-Mail-Adresse
|
||||
* @param string $vorname Neuer Vorname
|
||||
* @param string $nachname Neuer Nachname
|
||||
* @param string|null $password Neues Passwort oder null
|
||||
*
|
||||
* Ausgabe:
|
||||
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
||||
*
|
||||
* Mögliche Fehler:
|
||||
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||
*/
|
||||
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null);
|
||||
|
||||
/**
|
||||
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
*
|
||||
* Funktion:
|
||||
* Entfernt einen vorhandenen Benutzer aus der Datenquelle.
|
||||
*
|
||||
* Eingabe:
|
||||
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
||||
*
|
||||
* Ausgabe:
|
||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||
*
|
||||
* Mögliche Fehler:
|
||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||
*/
|
||||
public function deleteUser($email);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Prüft, ob der Autor auch der Eigentümer des Beitrags ist.
|
||||
* @param $author
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Prüft, ob ein Vor- oder Nachname gültig ist.
|
||||
*
|
||||
* Erlaubt werden Buchstaben, Umlaute, Leerzeichen und Bindestriche.
|
||||
* Die Länge muss zwischen 2 und 20 Zeichen liegen.
|
||||
*
|
||||
* @param string $name Zu prüfender Name
|
||||
*
|
||||
* @return bool true wenn der Name gültig ist, sonst false
|
||||
*/
|
||||
function userNameValidator($name)
|
||||
{
|
||||
$name = trim($name);
|
||||
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,20}$/u';
|
||||
|
||||
return preg_match($namePattern, $name) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob eine E-Mail-Adresse gültig ist.
|
||||
*
|
||||
* Die E-Mail-Adresse muss dem Standardformat entsprechen
|
||||
* und darf höchstens 100 Zeichen lang sein.
|
||||
*
|
||||
* @param string $email Zu prüfende E-Mail-Adresse
|
||||
*
|
||||
* @return bool true wenn die E-Mail-Adresse gültig ist, sonst false
|
||||
*/
|
||||
function userEmailValidator($email)
|
||||
{
|
||||
$email = trim($email);
|
||||
|
||||
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false
|
||||
&& mb_strlen($email) <= 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob ein Passwort die Längenanforderungen erfüllt.
|
||||
*
|
||||
* Das Passwort muss zwischen 5 und 12 Zeichen lang sein.
|
||||
*
|
||||
* @param string $password Zu prüfendes Passwort
|
||||
*
|
||||
* @return bool true wenn das Passwort gültig ist, sonst false
|
||||
*/
|
||||
function userPasswordValidator($password)
|
||||
{
|
||||
$zeichenAnzahl = mb_strlen($password);
|
||||
|
||||
return $zeichenAnzahl >= 5 && $zeichenAnzahl <= 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ein optionales Passwort.
|
||||
*
|
||||
* Ein leeres Passwort ist erlaubt und bedeutet,
|
||||
* dass das bestehende Passwort unverändert bleibt.
|
||||
* Falls ein Passwort angegeben wurde, wird es
|
||||
* mit den normalen Passwortregeln geprüft.
|
||||
*
|
||||
* @param string|null $password Zu prüfendes Passwort
|
||||
*
|
||||
* @return bool true wenn das Passwort gültig oder leer ist,
|
||||
* sonst false
|
||||
*/
|
||||
function userOptionalPasswordValidator($password)
|
||||
{
|
||||
if (!isset($password) || $password === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return userPasswordValidator($password);
|
||||
}
|
||||
Binary file not shown.
@@ -1,52 +0,0 @@
|
||||
<!--
|
||||
Artikel: Satz des Pythagoras
|
||||
Funktion: Inhalt zum Fach Mathe
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
?>
|
||||
<main>
|
||||
|
||||
<h1>Satz des Pythagoras</h1>
|
||||
|
||||
<p>
|
||||
Der Satz des Pythagoras wurde von dem griechischen Philosophen Pythagoras von Samos formuliert und im
|
||||
dritten Jahrhundert vor Christus veröffentlicht.
|
||||
</p>
|
||||
<figure>
|
||||
<img src="https://cdn8.picryl.com/photo/2016/05/14/pythagoras-e9560b-1024.jpg" alt="Trulli" style="width:10%">
|
||||
<figcaption><a href="https://cdn8.picryl.com/photo/2016/05/14/pythagoras-e9560b-1024.jpg">Quelle</a></figcaption>
|
||||
</figure>
|
||||
<p>
|
||||
In der beigefügten Abbildung sehen wir ein rechtwinkliges Dreieck, dessen drei Seiten die Längen a, b und c
|
||||
besitzen. Auf jeder Seite ist ein Quadrat konstruiert. Das Quadrat auf der Seite a hat die Fläche a2, das
|
||||
Quadrat auf der Seite b hat die Fläche b2 und das Quadrat auf der Seite c hat die Fläche c2. Der Satz des
|
||||
Pythagoras besagt, dass die Summe der Flächen der beiden kleineren Quadrate gleich der Fläche des größten
|
||||
Quadrats ist. Das bedeutet, dass a^2+b^2=c^2 (Satz des Pythagoras).
|
||||
</p>
|
||||
<a href="docs/Uebungsaufgaben_Pythagoras.pdf">Lernzettel-Download</a>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,46 +0,0 @@
|
||||
<!--
|
||||
Artikel: Tunneleffekt
|
||||
Funktion: Inhalt zum Fach Physik
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
?>
|
||||
<main>
|
||||
|
||||
<h1>Tunneleffekt</h1>
|
||||
|
||||
<p>
|
||||
Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen – vor allem Elektronen – eine
|
||||
Energiebarriere überwinden können, obwohl sie nach den Regeln der klassischen Physik nicht genügend Energie
|
||||
dafür besitzen. In der klassischen Vorstellung müsste ein Elektron entweder genügend Energie haben, um über
|
||||
eine Barriere zu „springen“, oder es würde vollständig zurückgeworfen. In der Quantenphysik wird ein Elektron
|
||||
jedoch nicht als punktförmiges Teilchen beschrieben, sondern als Wellenfunktion, die sich räumlich ausdehnt.
|
||||
Dadurch besteht eine endliche Wahrscheinlichkeit, dass sich das Elektron auf der anderen Seite einer Barriere
|
||||
befindet (Griffiths & Schroeter, 2018).
|
||||
</p>
|
||||
|
||||
</main>
|
||||
|
||||
<?php
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user