Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87d78b749b | |||
| 604dbeca93 | |||
| 8e9e7d65d0 | |||
| e2c317e507 | |||
| 5a7fa35465 | |||
| 2601a1c1ca | |||
| 0e26679f24 | |||
| d5ab659217 | |||
| 2d5919d572 | |||
| f56a074a3c | |||
| 24dc432f01 | |||
| 016193de07 | |||
| f04d8fecd3 | |||
| 36276c7c88 | |||
| 4a2cf0b55b | |||
| 400436a73f | |||
| 4c378dfba6 | |||
| c3a9de71f4 | |||
| ecf2e9ef57 | |||
| 45ac70eba2 | |||
| 3b66c6aa3a | |||
| e37b882481 | |||
| b328c2613c |
Generated
+3
-1
@@ -10,7 +10,9 @@
|
|||||||
<option name="highlightLevel" value="WARNING" />
|
<option name="highlightLevel" value="WARNING" />
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.5" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.0">
|
||||||
|
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||||
|
</component>
|
||||||
<component name="PhpStanOptionsConfiguration">
|
<component name="PhpStanOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -1,25 +1,13 @@
|
|||||||
# Webprogrammierung: Gruppe DI-14-C
|
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
|
||||||
|
|
||||||
## Beteiligte
|
Hinweise:
|
||||||
- Caroline Schulte
|
index.html wurde zu einer index.php umbenannt.
|
||||||
- Jacques Eilers
|
webhook.php bitte ignorieren. Diese dient nur als zukünftige Automatisierung des Repo-Pulls (s. https://docs.gitea.com/usage/webhooks)
|
||||||
- Niklas Ortmann
|
|
||||||
|
|
||||||
## Login-Informationen für Dummy-User
|
Beim Verwenden der Navbar-Links bitte Folgendes beachten: nur die Kategorien Physik, Mathe, Informatik führen exemplarisch auf eine Beispiel-Seite.
|
||||||
Jeweils im Format `Anmeldename, Passwort, Mailadresse`:
|
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.
|
||||||
- `max.mustermann, test123, mustermann@web.de`
|
|
||||||
|
|
||||||
## Weitere Voraussetzungen zur Nutzung
|
|
||||||
|
|
||||||
## Ausgelassene Teilaufgaben
|
|
||||||
|
|
||||||
## Bekannte Fehler und Mängel
|
|
||||||
- Der Beitragseditor fügt beim Laden von Inhalten leere Zeichen ein.
|
|
||||||
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
- 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 und führen auf eine 404-Seite.
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$user = $user ?? null;
|
session_start();
|
||||||
if (!isset($_SESSION["user"])) {
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Seite: Beitrag erstellen
|
Seite: Beitrag erstellen
|
||||||
@@ -14,7 +10,7 @@ if (!isset($_SESSION["user"])) {
|
|||||||
<main class="editor-main">
|
<main class="editor-main">
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||||
<p class="alert-message is-error">
|
<p class="alert-message is-error">
|
||||||
Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||||
@@ -22,47 +18,15 @@ if (!isset($_SESSION["user"])) {
|
|||||||
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
<input type="text" id="title" name="title" placeholder="Titel hier eingeben" required>
|
||||||
<p class="alert-message is-error">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."></textarea>
|
||||||
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Die ausgewählte Kategorie ist ungültig.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-50 Zeichen).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
<input type="text" id="title" name="title"
|
|
||||||
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>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
<aside class="editor-sidebar">
|
<aside class="editor-sidebar">
|
||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<button type="submit" id="editor-button" class="button">Veröffentlichen</button>
|
<button type="submit" class="btn-publish">Veröffentlichen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
@@ -112,9 +76,7 @@ if (!isset($_SESSION["user"])) {
|
|||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<label for="tags">Schlagwörter</label>
|
<label for="tags">Schlagwörter</label>
|
||||||
<input type="text" id="tags" name="tags"
|
<input type="text" id="tags" name="tags" placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
value="<?php echo htmlspecialchars($_SESSION['old_tags'] ?? ''); unset($_SESSION['old_tags']); ?>"
|
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
|
|
||||||
/*
|
|
||||||
Deregistrierung
|
|
||||||
Funktion: Entfernt User aus Dummy-Daten und beendet Session
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (isset($_SESSION["user_email"])) {
|
|
||||||
$dao->deleteUser($_SESSION["user_email"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SESSION = [];
|
|
||||||
session_destroy();
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
+14
-35
@@ -1,53 +1,32 @@
|
|||||||
<?php
|
|
||||||
$error = $error ?? null;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Form: Login-Bereich
|
Form: Login-Bereich
|
||||||
Funktion: Benutzerauthentifizierung und Zugang zum eigenen Profil, Erstellen von Beiträgen, etc.
|
Funktion: Benutzerauthentifizierung und Zugang zum eigenen Profil, Erstellen von Beiträgen, etc.
|
||||||
-->
|
-->
|
||||||
<main class="login-page">
|
<main class="login-page">
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
|
|
||||||
<h1>Bitte anmelden</h1>
|
<h1>Bitte anmelden</h1>
|
||||||
|
|
||||||
<?php if ($error): ?>
|
<form>
|
||||||
<p style="color:red;">
|
<label id ="inputEmail" class="screenreader-only">E-Mail Adresse / </label>
|
||||||
<?php echo htmlspecialchars($error); ?>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form method="post" action="index.php?pfad=login">
|
|
||||||
|
|
||||||
<p class="input-label">Benutzername/E-Mail-Adresse:</p>
|
<p class="input-label">Benutzername/E-Mail-Adresse:</p>
|
||||||
<input type="email"
|
<input type="email" name="email" class="login-input" placeholder="E-Mail-Adresse" required autofocus>
|
||||||
name="email"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="E-Mail-Adresse"
|
|
||||||
required
|
|
||||||
autofocus>
|
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
<input type="password"
|
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
||||||
name="password"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Passwort"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<button type="submit"
|
<div class="checkbox-wrapper">
|
||||||
value="anmelden"
|
<label>
|
||||||
name="loginSubmit"
|
<input type="checkbox" name="remember-me" value="1"> angemeldet bleiben
|
||||||
class="button">
|
</label>
|
||||||
anmelden
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="register-link">
|
|
||||||
<a href="index.php?pfad=register">
|
|
||||||
Noch keinen Account? Jetzt hier registrieren!
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">anmelden</button>
|
||||||
|
|
||||||
|
<div class="register-link">
|
||||||
|
<a href="register.php">Noch keinen Account? Jetzt hier registrieren!</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
$_SESSION = [];
|
|
||||||
session_destroy();
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
+28
-156
@@ -1,174 +1,46 @@
|
|||||||
<?php
|
<!--
|
||||||
include_once 'php/controller/profile-controller.php';
|
Content: Profil
|
||||||
|
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
||||||
$user = $user ?? null;
|
-->
|
||||||
$isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<main class="form-page">
|
<main class="form-page">
|
||||||
<div class="flexbox">
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="form-container">
|
||||||
|
<form>
|
||||||
|
|
||||||
<?php if (!empty($error)): ?>
|
<label class="input-label">Vorname</label>
|
||||||
<p class="alert-message is-error">
|
|
||||||
<?php echo htmlspecialchars($error); ?>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form method="post" action="index.php?pfad=profile">
|
<input type="text" name="Vorname" class="login-input" required
|
||||||
|
placeholder="Vorname"
|
||||||
|
value="<?php //DB-Daten ?>">
|
||||||
|
|
||||||
<label class="input-label">Vorname</label>
|
<label class="input-label">Nachname</label>
|
||||||
<input type="text"
|
<input type="text" name="Nachname" class="login-input" required
|
||||||
name="vorname"
|
placeholder="Nachname"
|
||||||
class="login-input"
|
value="<?php //DB-Daten ?>">
|
||||||
value="<?php echo htmlspecialchars($_POST["vorname"] ?? $user["vorname"] ?? ""); ?>"
|
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
|
||||||
required>
|
|
||||||
|
|
||||||
<label class="input-label">Nachname</label>
|
<label class="input-label">Email-Adresse</label>
|
||||||
<input type="text"
|
<input type="email" name="Email" class="login-input" required
|
||||||
name="nachname"
|
placeholder="mustermann@web.de"
|
||||||
class="login-input"
|
value="<?php //DB-Daten ?>">
|
||||||
value="<?php echo htmlspecialchars($_POST["nachname"] ?? $user["nachname"] ?? ""); ?>"
|
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
|
||||||
required>
|
|
||||||
|
|
||||||
<label class="input-label">Email-Adresse</label>
|
<label class="input-label">Passwort</label>
|
||||||
<input type="email"
|
<input type="password" name="Passwort" class="login-input"
|
||||||
name="email"
|
required placeholder="Passwort">
|
||||||
class="login-input"
|
|
||||||
value="<?php echo htmlspecialchars($_POST["email"] ?? $user["email"] ?? ""); ?>"
|
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
|
||||||
required>
|
|
||||||
|
|
||||||
<label class="input-label">
|
|
||||||
<?php echo $isEditMode ? "Neues Passwort" : "Passwort"; ?>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<?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; ?>
|
|
||||||
|
|
||||||
<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>
|
<br>
|
||||||
|
|
||||||
<a href="index.php?pfad=deleteAccount" class="button">
|
<button type="submit" class="login-button">
|
||||||
Account löschen
|
Speichern
|
||||||
</a>
|
</button>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<a href="index.php?pfad=logout" class="button">
|
<button type="button" class="login-button">
|
||||||
Abmelden
|
Account löschen
|
||||||
</a>
|
</button>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
</form>
|
||||||
<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): ?>
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3 class="article-title">
|
|
||||||
<?php echo htmlspecialchars($userArticle->getTitle()); ?>
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$tags = $userArticle->getTags();
|
|
||||||
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>
|
|
||||||
<?php
|
|
||||||
endif;
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=updateArticle&id=<?php echo $userArticle->getID(); ?>"
|
|
||||||
class="edit-link-button">
|
|
||||||
Bearbeiten
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php else: ?>
|
|
||||||
|
|
||||||
<p>Du hast noch keine Beiträge erstellt.</p>
|
|
||||||
|
|
||||||
<button type="button"
|
|
||||||
class="button"
|
|
||||||
onclick="window.location.href='index.php?pfad=createArticle';">
|
|
||||||
Beitrag erstellen!
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php unset($_SESSION["message"]); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
+11
-42
@@ -1,7 +1,3 @@
|
|||||||
<?php
|
|
||||||
$error = $error ?? null;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Form: Registrierung
|
Form: Registrierung
|
||||||
Funktion: Erstellung neuer Benutzerkonten
|
Funktion: Erstellung neuer Benutzerkonten
|
||||||
@@ -11,53 +7,26 @@ $error = $error ?? null;
|
|||||||
|
|
||||||
<h1>Jetzt Registrieren!</h1>
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
<?php if (!empty($error)): ?>
|
<form>
|
||||||
<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>
|
<p class="input-label">Email:</p>
|
||||||
<input type="email"
|
<input type="email" name="email" class="login-input" placeholder="mustermann@web.de" required>
|
||||||
name="email"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="mustermann@web.de"
|
|
||||||
value="<?php echo htmlspecialchars($_POST["email"] ?? ""); ?>"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<p class="input-label">Vorname:</p>
|
<p class="input-label">Vorname:</p>
|
||||||
<input type="text"
|
<input type="text" name="vorname" class="login-input" placeholder="Max" required>
|
||||||
name="vorname"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Max"
|
|
||||||
value="<?php echo htmlspecialchars($_POST["vorname"] ?? ""); ?>"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<p class="input-label">Nachname:</p>
|
<p class="input-label">Nachname:</p>
|
||||||
<input type="text"
|
<input type="text" name="nachname" class="login-input" placeholder="Mustermann" required>
|
||||||
name="nachname"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Mustermann"
|
|
||||||
value="<?php echo htmlspecialchars($_POST["nachname"] ?? ""); ?>"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
<input type="password"
|
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
||||||
name="password"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Passwort"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<button type="submit"
|
<div class="checkbox-wrapper">
|
||||||
value="register"
|
<label>
|
||||||
name="registerSubmit"
|
<input type="checkbox" value="remember-me"> angemeldet bleiben
|
||||||
class="button">
|
</label>
|
||||||
kostenlos registrieren
|
</div>
|
||||||
</button>
|
|
||||||
|
|
||||||
|
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">kostenlos registrieren</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
+30
-34
@@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
//debugging
|
||||||
|
echo "<pre style='background:#fff; color:#000; padding:10px; border:2px solid red; position:relative; z-index:9999;'>";
|
||||||
|
echo "Aktuelle URL-Parameter (GET): "; print_r($_GET);
|
||||||
|
echo "Aktueller Session-Inhalt (SESSION): "; print_r($_SESSION);
|
||||||
|
echo "</pre>";
|
||||||
|
// debugging
|
||||||
|
|
||||||
|
$results = $_SESSION["search_results"] ?? [];
|
||||||
|
$query = $_SESSION["search_query"] ?? "";
|
||||||
|
$resultCount = count($results);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Seite: Suchergebnisse
|
Seite: Suchergebnisse
|
||||||
@@ -48,7 +60,7 @@ session_start();
|
|||||||
|
|
||||||
<div class="s-res-header">
|
<div class="s-res-header">
|
||||||
<h1 class="s-res-main-title">Suchergebnisse</h1>
|
<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 $resultCount; ?> Treffer für Ihre Suchanfrage "<?php echo htmlspecialchars($query); ?>"</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Ergebnisliste -->
|
<!-- Ergebnisliste -->
|
||||||
@@ -56,7 +68,23 @@ session_start();
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
if(isset($_SESSION['message']) && $_SESSION['message'] == "new_search_results"): ?>
|
if(isset($_SESSION['message']) && $_SESSION['message'] == "new_search_results"): ?>
|
||||||
<!-- TODO: Hier die Beiträge ausgeben. -->
|
|
||||||
|
<?php if ($resultCount === 0): ?>
|
||||||
|
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($results as $item): ?>
|
||||||
|
<div class="s-res-item">
|
||||||
|
<div class="s-res-content">
|
||||||
|
<h2 class="s-res-item-title">
|
||||||
|
<a href="<?php echo $item['link']; ?>" class="s-res-link"><?php echo $item['title']; ?></a>
|
||||||
|
</h2>
|
||||||
|
<p class="s-res-author">Kategorie: <span class="s-res-author-name">Beitrag</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="s-res-arrow">→</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||||
<p>
|
<p>
|
||||||
Bitte überprüfe deine Sucheingabe und versuche es erneut!
|
Bitte überprüfe deine Sucheingabe und versuche es erneut!
|
||||||
@@ -66,38 +94,6 @@ session_start();
|
|||||||
unset($_SESSION["message"]);
|
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>
|
||||||
<div class="s-res-pagination-footer">
|
<div class="s-res-pagination-footer">
|
||||||
|
|||||||
+7
-30
@@ -1,44 +1,21 @@
|
|||||||
<?php
|
|
||||||
include_once 'php/controller/showArticle-controller.php';
|
|
||||||
?>
|
|
||||||
<!--
|
<!--
|
||||||
Seite: Anzeige für Beiträge
|
Seite: Anzeige für Beiträge
|
||||||
Funktion: Stellt einen übergebenen Beitrag dar.
|
Funktion: Stellt einen übergebenen Beitrag dar.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
include_once 'php/controller/showArticle-controller.php';
|
||||||
|
?>
|
||||||
|
|
||||||
<!-- Hauptcontainer für die Beitragsansicht (Ausschließlich der Content-Bereich) -->
|
<!-- Hauptcontainer für die Beitragsansicht (Ausschließlich der Content-Bereich) -->
|
||||||
<main class="article-view-container">
|
<main class="article-view-container">
|
||||||
<?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 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"] == "article_updated"): ?>
|
|
||||||
<p class="alert-message is-success">
|
|
||||||
Dein Beitrag wurde erfolgreich bearbeitet!
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Metadaten & Titel -->
|
<!-- Metadaten & Titel -->
|
||||||
<div class="article-view-top-section">
|
<div class="article-view-top-section">
|
||||||
|
|
||||||
<?php if (isset($category) && !empty($category)): ?>
|
<?php if (isset($category) && !empty($category)): ?>
|
||||||
<span class="article-view-category"><?php echo htmlspecialchars($category); ?></span>
|
<span class="article-view-category"><?php echo htmlspecialchars($category); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<h1 class="article-view-title">
|
<h1 class="article-view-title">
|
||||||
<?php if (isset($title)) { echo htmlspecialchars($title); } ?>
|
<?php if (isset($title)) { echo htmlspecialchars($title); } ?>
|
||||||
</h1>
|
</h1>
|
||||||
@@ -51,7 +28,7 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Beitrags-Inhalt -->
|
<!-- articleikel-Inhalt -->
|
||||||
<div class="article-view-content">
|
<div class="article-view-content">
|
||||||
<?php if (isset($content)): ?>
|
<?php if (isset($content)): ?>
|
||||||
<!-- nl2br für Zeilenumbrüche -->
|
<!-- nl2br für Zeilenumbrüche -->
|
||||||
@@ -59,7 +36,7 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Beitrags-Endbereich (Tags) -->
|
<!-- articleikel-Endbereich (Tags) -->
|
||||||
<?php if (isset($tags) && !empty($tags)): ?>
|
<?php if (isset($tags) && !empty($tags)): ?>
|
||||||
<div class="article-view-bottom-section">
|
<div class="article-view-bottom-section">
|
||||||
<div class="article-view-tags-label">Tags:</div>
|
<div class="article-view-tags-label">Tags:</div>
|
||||||
|
|||||||
@@ -1,152 +0,0 @@
|
|||||||
<?php
|
|
||||||
$user = $user ?? null;
|
|
||||||
if (!isset($_SESSION["user"])) {
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
include_once 'php/controller/showArticle-controller.php';
|
|
||||||
?>
|
|
||||||
<!--
|
|
||||||
Seite: Beitrag erstellen
|
|
||||||
Inhalt: Formular für die Erstellung eines neuen Beitrags
|
|
||||||
-->
|
|
||||||
<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 if (isset($_SESSION["message"]) && $_SESSION["message"] == "unauthorized_access"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
<input type="text" id="title" name="title"
|
|
||||||
value="<?php
|
|
||||||
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
|
|
||||||
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_title']);
|
|
||||||
unset($_SESSION['old_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>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
|
||||||
<aside class="editor-sidebar">
|
|
||||||
|
|
||||||
<div class="sidebar-block">
|
|
||||||
<button type="submit" 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>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
</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>
|
|
||||||
</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>
|
|
||||||
</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>
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="sidebar-block">
|
|
||||||
<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'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_tags']);
|
|
||||||
unset($_SESSION['old_tags']);
|
|
||||||
}
|
|
||||||
?>"
|
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
+14
-2
@@ -86,8 +86,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Button-Zeugs */
|
/* Button-Zeugs */
|
||||||
.button#editor-button {
|
.article-editor-scope .btn-publish {
|
||||||
padding: 18px 12px;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
|
|||||||
+2
-12
@@ -155,7 +155,7 @@ a, button, input, select, textarea, label, main{
|
|||||||
color: #1f2937;
|
color: #1f2937;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.login-button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
background-color: #2563eb;
|
background-color: #2563eb;
|
||||||
@@ -168,7 +168,7 @@ a, button, input, select, textarea, label, main{
|
|||||||
transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
|
transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.login-button:hover {
|
||||||
background-color: #1d4ed8;
|
background-color: #1d4ed8;
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
||||||
@@ -212,13 +212,3 @@ a, button, input, select, textarea, label, main{
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 6px 20px rgba(0,0,0,0.1);
|
box-shadow: 0 6px 20px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-container {
|
|
||||||
flex: 1 1 450px;
|
|
||||||
padding: 30px;
|
|
||||||
background-color: white;
|
|
||||||
border: 1px solid #dbe3ec;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 6px 20px rgba(0,0,0,0.1);
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
+1
-1
@@ -152,7 +152,7 @@ CSS für die navbar
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
@media (max-width: 800px) {
|
@media (max-width: 760px) {
|
||||||
.nav {
|
.nav {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
CSS für die Profilseite
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Roter Button für Account löschen */
|
|
||||||
.delete-account-button {
|
|
||||||
background-color: #dc2626;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-account-button:hover {
|
|
||||||
background-color: #b91c1c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Beitragsliste Styling */
|
|
||||||
.section-title {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 25px;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
color: #1f2937;
|
|
||||||
border-bottom: 2px solid #eef2f7;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.articles-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-item {
|
|
||||||
padding: 15px;
|
|
||||||
border: 1px solid #e5e7eb;
|
|
||||||
border-radius: 8px;
|
|
||||||
background-color: #f9fafb;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-meta {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
color: #6b7280;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-category {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #2563eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-title {
|
|
||||||
margin: 0 0 10px 0;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
color: #1f2937;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-tags {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag {
|
|
||||||
font-size: 0.75rem;
|
|
||||||
background-color: #e5e7eb;
|
|
||||||
color: #374151;
|
|
||||||
padding: 3px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bearbeiten-Button als Link deklariert */
|
|
||||||
.edit-link-button {
|
|
||||||
display: inline-block;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #2563eb;
|
|
||||||
border: 1px solid #2563eb;
|
|
||||||
padding: 6px 12px;
|
|
||||||
border-radius: 6px;
|
|
||||||
transition: background-color 0.2s, color 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-link-button:hover {
|
|
||||||
background-color: #2563eb;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
@@ -69,12 +69,12 @@ CSS für die Suchergebnis-Seite
|
|||||||
|
|
||||||
.s-res-filter-option input[type="radio"] {
|
.s-res-filter-option input[type="radio"] {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
accent-color: #3182ce;
|
accent-color: #3182ce; /* Moderne Färbung des Radio-Buttons */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- HAUPTINHALT (ERGEBNISSE) --- */
|
/* --- HAUPTINHALT (ERGEBNISSE) --- */
|
||||||
.s-res-main-content {
|
.s-res-main-content {
|
||||||
min-width: 0;
|
min-width: 0; /* Verhindert das Ausbrechen von Flex-Elementen */
|
||||||
}
|
}
|
||||||
|
|
||||||
.s-res-header {
|
.s-res-header {
|
||||||
@@ -164,7 +164,7 @@ CSS für die Suchergebnis-Seite
|
|||||||
transform: translateX(3px);
|
transform: translateX(3px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ERGEBNISSE PRO SEITE & PAGINIERUNG */
|
/* --- ERGEBNISSE PRO SEITE & PAGINIERUNG --- */
|
||||||
.s-res-pagination-footer {
|
.s-res-pagination-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -247,7 +247,7 @@ CSS für die Suchergebnis-Seite
|
|||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
/* --- RESPONSIVE DESIGN (MOBILGERÄTE) --- */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.s-res-layout-grid {
|
.s-res-layout-grid {
|
||||||
grid-template-columns: 1fr; /* Stapelt Seitenleiste und Inhalt untereinander */
|
grid-template-columns: 1fr; /* Stapelt Seitenleiste und Inhalt untereinander */
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
[]
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
Artikel: Datenschutz vs Datensicherheit
|
Artikel: Datenschutz vs Datensicherheit
|
||||||
Funktion: Inhalt zum Fach Informatik
|
Funktion: Inhalt zum Fach Informatik
|
||||||
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|||||||
+17
-60
@@ -1,41 +1,27 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Globales Menü, wird via PHP später in alle Seiten eingebunden
|
Globales Menü, wird via PHP später in alle Seiten eingebunden
|
||||||
-->
|
-->
|
||||||
<nav class="nav">
|
<nav class="nav">
|
||||||
<div class="nav__left">
|
<div class="nav__left">
|
||||||
<a href="index.php" class="nav__logo">
|
<a href="index.php" class="nav__logo">
|
||||||
<img src="images/logos/logo_full.png" alt="Logo">
|
<img src="images/logos/logo_full.png" alt="Logo">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Mobile navbar mit Burger-Symbol -->
|
<!-- Mobile navbar mit Burger-Symbol -->
|
||||||
<input type="checkbox" id="nav-toggle" class="nav__checkbox">
|
<input type="checkbox" id="nav-toggle" class="nav__checkbox">
|
||||||
<label for="nav-toggle" id="mobile-nav">
|
<label for="nav-toggle" id="mobile-nav">
|
||||||
<span>☰</span>
|
<span>☰</span> <!-- Burger Icon Symbol -->
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<ul id="mobile-nav" class="nav__mobile-menu">
|
<ul id="mobile-nav" class="nav__mobile-menu">
|
||||||
<li>
|
<li>
|
||||||
<label for="nav-toggle" class="nav__close-btn">×</label>
|
<label for="nav-toggle" class="nav__close-btn">×</label>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a href="index.php?pfad=profile">Profil</a></li>
|
||||||
<?php if (isset($_SESSION['user'])): ?>
|
<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=profile">Profil</a></li>
|
<li><a href="index.php?pfad=createArticle">Beitrag erstellen</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>
|
<li>
|
||||||
<label class="nav__mobile-label">Sprachen</label>
|
<label class="nav__mobile-label">Sprachen</label>
|
||||||
<ul class="nav__mobile-submenu">
|
<ul class="nav__mobile-submenu">
|
||||||
@@ -53,7 +39,7 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<li><a href="index.php?pfad=mathe">Mathematik</a></li>
|
<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=biologie">Biologie</a></li>
|
||||||
<li><a href="index.php?pfad=chemie">Chemie</a></li>
|
<li><a href="index.php?pfad=chemie">Chemie</a></li>
|
||||||
<li><a href="index.php?pfad=physik">Physik</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=informatik">Informatik</a></li>
|
||||||
<li><a href="index.php?pfad=astronomie">Astronomie</a></li>
|
<li><a href="index.php?pfad=astronomie">Astronomie</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -99,7 +85,6 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<a href="index.php?pfad=literatur">Literatur</a>
|
<a href="index.php?pfad=literatur">Literatur</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">MINT</button>
|
<button class="nav__dropdown-toggle">MINT</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
@@ -111,7 +96,6 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<a href="index.php?pfad=astronomie">Astronomie</a>
|
<a href="index.php?pfad=astronomie">Astronomie</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
|
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
@@ -128,7 +112,6 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<a href="index.php?pfad=theater">Theater</a>
|
<a href="index.php?pfad=theater">Theater</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">Technik & Praxis</button>
|
<button class="nav__dropdown-toggle">Technik & Praxis</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
@@ -141,40 +124,14 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__right">
|
<div class="nav__right">
|
||||||
|
<a href="index.php?pfad=profile" class="nav_item nav__link">Profil</a>
|
||||||
<?php if (isset($_SESSION['user'])): ?>
|
<div class="nav__search">
|
||||||
|
<?php
|
||||||
<a href="index.php?pfad=profile" class="nav__item nav__link">
|
include_once 'search.php';
|
||||||
Profil
|
?>
|
||||||
</a>
|
</div>
|
||||||
|
<a href="index.php?pfad=login" class="nav__item nav__button">Anmelden</a>
|
||||||
<div class="nav__search">
|
<a href="index.php?pfad=register" class="nav__item nav__button">Registrieren</a>
|
||||||
<?php include_once 'search.php'; ?>
|
<a href="index.php?pfad=createArticle" class="nav__item nav__button">Beitrag erstellen</a>
|
||||||
</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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
+7
-2
@@ -2,5 +2,10 @@
|
|||||||
Suchleiste. Wird via PHP später in alle Seiten eingebunden
|
Suchleiste. Wird via PHP später in alle Seiten eingebunden
|
||||||
-->
|
-->
|
||||||
<!--<label for="site-search">Suche</label>-->
|
<!--<label for="site-search">Suche</label>-->
|
||||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
<form action="index.php" method="GET" class="search-form">
|
||||||
<button type="submit" class="nav__search-button">Suchen</button>
|
|
||||||
|
<input type="hidden" name="pfad" value="search-results">
|
||||||
|
|
||||||
|
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" required>
|
||||||
|
<button type="submit" class="nav__search-button">Suchen</button>
|
||||||
|
</form>
|
||||||
@@ -1,77 +1,53 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
ob_start();
|
if (!isset($abs_path)) {
|
||||||
|
require_once "path.php";
|
||||||
$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";
|
|
||||||
}
|
}
|
||||||
|
require_once $abs_path . "/php/controller/index-controller.php";
|
||||||
|
|
||||||
if ($pfad === "register") {
|
|
||||||
include_once "php/controller/register-controller.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($pfad === "logout") {
|
|
||||||
include_once "content/logout.php";
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($pfad === "deleteAccount") {
|
|
||||||
include_once "content/deleteAccount.php";
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Seite: Index der Lernplattform
|
Seite: Index der Lernplattform
|
||||||
Funktion: Webseitengerüst, Anzeigen von Content
|
Funktion: Webseitengerüst, Anzeigen von Content
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="description" content="EduForge">
|
<meta name="description" content="EduForge">
|
||||||
<meta name="author" content="Niklas Ortmann">
|
<meta name="author" content="Niklas Ortmann">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||||
<link rel="stylesheet" href="css/main.css">
|
<link rel="stylesheet" href="css/main.css">
|
||||||
<link rel="stylesheet" href="css/navbar.css">
|
<link rel="stylesheet" href="css/navbar.css">
|
||||||
<link rel="stylesheet" href="css/footer.css">
|
<link rel="stylesheet" href="css/footer.css">
|
||||||
<link rel="stylesheet" href="css/search-results.css">
|
<link rel="stylesheet" href="css/search-results.css">
|
||||||
<link rel="stylesheet" href="css/createArticle.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/showArticle.css">
|
<link rel="stylesheet" href="css/message.css">
|
||||||
<link rel="stylesheet" href="css/message.css">
|
<title>EduForge</title>
|
||||||
<title>EduForge</title>
|
</head>
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once 'includes/navbar.php';
|
include_once 'includes/navbar.php';
|
||||||
|
//Dynamischer Inhalt:
|
||||||
|
if (isset($_GET["pfad"])) {
|
||||||
|
|
||||||
/*
|
if (file_exists($abs_path . '/content/' . $_GET["pfad"] . '.php')) {
|
||||||
Dynamischer Inhalt:
|
include_once $abs_path . '/content/' . $_GET["pfad"] . '.php';
|
||||||
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
} else {
|
||||||
*/
|
include_once $abs_path . '/content/404.php';
|
||||||
if (file_exists('content/' . $pfad . '.php')) {
|
}
|
||||||
include_once 'content/' . $pfad . '.php';
|
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/404.php';
|
include_once $abs_path . '/content/home.php';
|
||||||
}
|
}
|
||||||
|
include_once $abs_path . '/includes/footer.php';
|
||||||
include_once 'includes/footer.php';
|
|
||||||
?>
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
ob_end_flush();
|
|
||||||
?>
|
|
||||||
@@ -1,89 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
SESSION_START();
|
session_start();
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../validator/article-validator.php';
|
|
||||||
require_once "../model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
$_SESSION["message"] = "missing_parameters";
|
||||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
} else {
|
||||||
|
|
||||||
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
$title = $_POST["title"];
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$content = $_POST["content"];
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
$category = $_POST["category"];
|
||||||
exit();
|
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||||
} else {
|
$tags = $_POST["tags"];
|
||||||
$title = $_POST["title"];
|
|
||||||
$content = $_POST["content"];
|
|
||||||
$author = $_SESSION["user_email"];
|
|
||||||
$category = $_POST["category"];
|
|
||||||
$tags = $_POST['tags'] ?? '';
|
|
||||||
|
|
||||||
// -------------------------------- Validierung der Daten: -------------------------
|
try {
|
||||||
if (!articleAuthorValidator($author)) {
|
$articleManager = ArticleManager::getInstance();
|
||||||
$_SESSION["message"] = "author_not_valid";
|
$articleManager->addArticle($title, $content, $author, $category, $tags);
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
} catch (Exception $e){
|
||||||
exit();
|
$_SESSION["message"] = "internal_error";
|
||||||
}
|
|
||||||
|
|
||||||
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";
|
|
||||||
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$error = null;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Verarbeitung des Login-Formulars
|
|
||||||
Funktion: Prüft Benutzerdaten und erstellt Session für eingeloggten Nutzer
|
|
||||||
*/
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
|
|
||||||
$email = $_POST["email"] ?? "";
|
|
||||||
$password = $_POST["password"] ?? "";
|
|
||||||
|
|
||||||
$user = $dao->findUser($email);
|
|
||||||
|
|
||||||
if ($user && password_verify($password, $user["password"])) {
|
|
||||||
|
|
||||||
if (isset($user["vorname"]) && isset($user["nachname"])) {
|
|
||||||
$_SESSION["user"] = $user["vorname"] . " " . $user["nachname"];
|
|
||||||
} else {
|
|
||||||
$_SESSION["user"] = $user["username"] ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SESSION["user_email"] = $user["email"];
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.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 = new LocalUserDAO();
|
|
||||||
|
|
||||||
$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 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
|
||||||
$_GET["edit"] = "1";
|
|
||||||
|
|
||||||
} elseif (!userNameValidator($nachname)) {
|
|
||||||
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
|
||||||
$_GET["edit"] = "1";
|
|
||||||
|
|
||||||
} elseif (!userOptionalPasswordValidator($password)) {
|
|
||||||
$error = "Das Passwort muss 8 bis 72 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";
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* Controller für die Liste der eigenen Beiträge eines Nutzers auf der eigenen Profilseite
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once 'php/model/Article.php';
|
|
||||||
require_once 'php/model/ArticleManager.php';
|
|
||||||
require_once "../model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
try {
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
|
||||||
|
|
||||||
$author = $user["email"];
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
|
||||||
$userArticles = $articleManager->getArticlesByAuthor($author);
|
|
||||||
if(!isset($userArticles)) {
|
|
||||||
$_SESSION["message"] = "user_has_no_articles";
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$_SESSION["message"] = "internal_error";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.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 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
|
||||||
} elseif (!userNameValidator($nachname)) {
|
|
||||||
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
|
||||||
} elseif (!userPasswordValidator($plainPassword)) {
|
|
||||||
$error = "Das Passwort muss 8 bis 72 Zeichen lang sein.";
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
|
|
||||||
$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,30 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '/../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '/../model/ArticleManager.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";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=search-results");
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$search = $_POST["search"];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
$articleManager->search($search); // TODO: Methode implementieren.
|
|
||||||
|
$results = $articleManager->search($search);
|
||||||
|
$_SESSION["search_results"] = $results;
|
||||||
|
$_SESSION["search_query"] = $search;
|
||||||
|
$_SESSION["message"] = "new_search_results";
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -3,11 +3,10 @@ session_start();
|
|||||||
require_once 'php/model/Article.php';
|
require_once 'php/model/Article.php';
|
||||||
require_once 'php/model/ArticleManager.php';
|
require_once 'php/model/ArticleManager.php';
|
||||||
|
|
||||||
if (isset($_GET["id"]) && !empty($_GET["id"])){
|
if (isset($_GET["id"])){
|
||||||
try {
|
try {
|
||||||
$id = $_GET["id"];
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
$article = $articleManager->getArticle($id);
|
$article = $articleManager->getArticle($_GET["id"]);
|
||||||
if($article != null){
|
if($article != null){
|
||||||
$title = $article->getTitle();
|
$title = $article->getTitle();
|
||||||
$content = $article->getContent();
|
$content = $article->getContent();
|
||||||
@@ -15,15 +14,15 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){
|
|||||||
$author = $article->getAuthor();
|
$author = $article->getAuthor();
|
||||||
$tags = $article->getTags();
|
$tags = $article->getTags();
|
||||||
}else{
|
}else{
|
||||||
//header("location: index.php?pfad=404");
|
$_SESSION["message"] = "article_not_found";
|
||||||
include_once "content/404.php";
|
echo "article_not_found";
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
exit();
|
echo "Fehler aufgetreten: " . $e->getMessage();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$_SESSION["message"] = "missing_id";
|
$_SESSION["message"] = "article_not_found";
|
||||||
|
echo "article_not_found";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
<?php
|
|
||||||
SESSION_START();
|
|
||||||
require_once '../model/LocalArticleManager.php';
|
|
||||||
require_once '../model/ArticleManager.php';
|
|
||||||
require_once '../model/Article.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"] ?? ''; // 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"])) {
|
|
||||||
$id = $_GET["id"];
|
|
||||||
} else {
|
|
||||||
$_SESSION["message"] = "missing_id";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
|
||||||
$_SESSION["message"] = "missing_parameters";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}else{
|
|
||||||
$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=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
|
||||||
$_SESSION["message"] = "invalid_title";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleContentValidator($content)) {
|
|
||||||
$_SESSION["message"] = "invalid_content";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleCategoryValidator($category)) {
|
|
||||||
$_SESSION["message"] = "invalid_category";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTagValidator($tags)) {
|
|
||||||
$_SESSION["message"] = "invalid_tags";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
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();
|
|
||||||
$article = $articleManager->getArticle($id);
|
|
||||||
$article->setTitle($title);
|
|
||||||
$article->setContent($content);
|
|
||||||
$article->setCategory($category);
|
|
||||||
$article->setTags($cleanedTags);
|
|
||||||
$articleManager->updateArticle($id ,$article, $author);
|
|
||||||
} catch (Exception $e){
|
|
||||||
$_SESSION["message"] = $e->getMessage();
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
$_SESSION["message"] = "article_updated";
|
|
||||||
// Weiterleitung zur Homepage
|
|
||||||
header("location: ../../index.php?pfad=showArticle&id=$id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
+11
-21
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Klasse: Artikel
|
* Klasse: Artikel
|
||||||
* Diese Klasse stellt alle Daten eines Beitrags (Beitrag) bereit
|
* Diese Klasse stellt alle Daten eines Artikels (Beitrag) bereit
|
||||||
*
|
*
|
||||||
* @author Niklas Ortmann
|
* @author Niklas Ortmann
|
||||||
*/
|
*/
|
||||||
@@ -38,7 +38,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt die ID eines Beitrags zurück.
|
* Gibt die ID eines Artikels zurück.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId(): int
|
public function getId(): int
|
||||||
@@ -47,7 +47,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt den Titel eines Beitrags zurück.
|
* Gibt den Titel eines Artikels zurück.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
@@ -56,7 +56,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setzt den Titel eines Beitrags
|
* Setzt den Titel eines Artikels
|
||||||
* @param $title
|
* @param $title
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -66,7 +66,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt den Content eines Beitrags zurück.
|
* Gibt den Content eines Artikels zurück.
|
||||||
* TODO: Content muss noch definiert werden.
|
* TODO: Content muss noch definiert werden.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +76,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setzt den Content eines Beitrags.
|
* Setzt den Content eines Artikels.
|
||||||
* TODO: Content muss noch definiert werden.
|
* TODO: Content muss noch definiert werden.
|
||||||
* @param $content
|
* @param $content
|
||||||
* @return void
|
* @return void
|
||||||
@@ -87,7 +87,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt den Autor eines Beitrags zurück.
|
* Gibt den Autor eines Artikels zurück.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAuthor(): string
|
public function getAuthor(): string
|
||||||
@@ -96,7 +96,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt das Veröffentlichungsdatum des Beitrags zurück.
|
* Gibt das Veröffentlichungsdatum des Artikels zurück.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreationDate(): string
|
public function getCreationDate(): string
|
||||||
@@ -105,7 +105,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt die Kategorie eines Beitrags zurück.
|
* Gibt die Kategorie eines Artikels zurück.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCategory(): string
|
public function getCategory(): string
|
||||||
@@ -114,17 +114,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setzt die Kategorie eines Beitrags.
|
* Gibt die Schlagworte eines Artikels zurück.
|
||||||
* @param string $category
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setCategory(string $category)
|
|
||||||
{
|
|
||||||
$this->category = $category;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gibt die Schlagworte eines Beitrags zurück.
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTags(): string
|
public function getTags(): string
|
||||||
@@ -133,7 +123,7 @@ class Article
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setzt die Schlagworte eines Beitrags.
|
* Setzt die Schlagworte eines Artikels.
|
||||||
* @param string $tags
|
* @param string $tags
|
||||||
*/
|
*/
|
||||||
public function setTags(string $tags)
|
public function setTags(string $tags)
|
||||||
|
|||||||
@@ -44,4 +44,5 @@ class ArticleManager extends LocalArticleManager
|
|||||||
|
|
||||||
return $articleManager;
|
return $articleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "Article.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.
|
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
||||||
*
|
*
|
||||||
@@ -21,32 +16,31 @@ interface ArticleManagerDAO
|
|||||||
* @param $tags string optionale Schlagworte für eine bessere Suche
|
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||||
*
|
*
|
||||||
* Mögliche Exceptions:
|
* Mögliche Exceptions:
|
||||||
* TODO: Exceptions implementieren.
|
* TODO Fehlerbeschreibung hinzufügen & tags hinzufügen
|
||||||
*/
|
*/
|
||||||
public function addArticle($title, $content, $author, $category, $tags);
|
public function addArticle($title, $content, $author, $category, $tags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ändert den gespeicherten Beitrag eines übergebenen Beitrags und eines Autors.
|
* Ein angemeldeter Nutzer bearbeitet einen Beitrag.
|
||||||
* Es wird geprüft, ob der zu änderne Beitrag existiert und ob der übergebene Autor der Autor des originalen
|
* $id ID des Beitrags
|
||||||
* Beitrages ist.
|
* $title Titel des Beitrags
|
||||||
* @param $id
|
* $content Der Inhalt des Beitrags
|
||||||
* @param $article
|
* $author dem Author des des Beitrags (NID oder email)
|
||||||
* @param $author
|
|
||||||
* @return void
|
|
||||||
*
|
*
|
||||||
* @throws InternalServerErrorException
|
* Mögliche Exceptions:
|
||||||
* @throws NotFoundException
|
* TODO Fehlerbeschreibung hinzufügen
|
||||||
* @throws UnauthorizedAccessException
|
|
||||||
* /
|
|
||||||
*/
|
*/
|
||||||
public function updateArticle($id, $article, $author);
|
public function updateArticle($id, $title, $content, $author);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Löscht einen Beitrag aus übergebener ID.
|
* Ein angemeldeter Nutzer löscht einen seiner Beiträge.
|
||||||
* @param $id
|
* $id ID des Beitrags
|
||||||
* @return void
|
* $title Titel des Beitrags
|
||||||
|
* $content Der Inhalt des Beitrags
|
||||||
|
* $author dem Author des des Beitrags (NID oder email)
|
||||||
*
|
*
|
||||||
* TODO: Exceptions implementieren.
|
* Mögliche Exceptions:
|
||||||
|
* TODO Fehlerbeschreibung hinzufügen
|
||||||
*/
|
*/
|
||||||
public function deleteArticle($id);
|
public function deleteArticle($id);
|
||||||
|
|
||||||
@@ -56,7 +50,7 @@ interface ArticleManagerDAO
|
|||||||
*
|
*
|
||||||
* @return Article
|
* @return Article
|
||||||
* Mögliche Exceptions:
|
* Mögliche Exceptions:
|
||||||
* TODO: Exceptions implementieren.
|
* TODO Fehlerbeschreibung hinzufügen
|
||||||
*/
|
*/
|
||||||
public function getArticle($id);
|
public function getArticle($id);
|
||||||
|
|
||||||
@@ -64,17 +58,17 @@ interface ArticleManagerDAO
|
|||||||
* Alle Beiträge aufrufen.
|
* Alle Beiträge aufrufen.
|
||||||
*
|
*
|
||||||
* Mögliche Exceptions:
|
* Mögliche Exceptions:
|
||||||
* TODO: Exceptions implementieren.
|
* TODO Fehlerbeschreibung hinzufügen
|
||||||
*/
|
*/
|
||||||
public function getAllArticles();
|
public function getAllArticles();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
* Such-Funktion
|
||||||
* @param $author
|
*
|
||||||
* @return Article[]
|
* $keyword Wort, nach dem gesucht wird als string
|
||||||
* TODO: Exceptions implementieren.
|
|
||||||
*/
|
*/
|
||||||
public function getArticlesByAuthor($author);
|
public function search(string $keyword): array;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -36,7 +36,6 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
* Speichert alle Artikel/Beiträge in der Datei.
|
* Speichert alle Artikel/Beiträge in der Datei.
|
||||||
* @param $articles
|
* @param $articles
|
||||||
* @return void
|
* @return void
|
||||||
* TODO: Exceptions implementieren.
|
|
||||||
*/
|
*/
|
||||||
public function saveArticle($articles)
|
public function saveArticle($articles)
|
||||||
{
|
{
|
||||||
@@ -63,62 +62,14 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
$this->saveArticle($articles);
|
$this->saveArticle($articles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateArticle($id, $article, $author)
|
public function updateArticle($id, $title, $content, $author)
|
||||||
{
|
{
|
||||||
if (empty($article)) {
|
// TODO: Implement updateArticle() method.
|
||||||
throw new InternalServerErrorException("internal_error");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Berechtigungsprüfung:
|
|
||||||
if ($article->getAuthor() !== $author) {
|
|
||||||
throw new UnauthorizedAccessException("unauthorized_access");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beitrag aktualisieren:
|
|
||||||
$articles = $this->getAllArticles();
|
|
||||||
$updated = false;
|
|
||||||
|
|
||||||
foreach ($articles as $index => $storedArticle) {
|
|
||||||
if (isset($storedArticle['id']) && $storedArticle['id'] == $id) {
|
|
||||||
$articles[$index] = [
|
|
||||||
"id" => $id,
|
|
||||||
"title" => $article->getTitle(),
|
|
||||||
"content" => $article->getContent(),
|
|
||||||
"author" => $author,
|
|
||||||
"category" => $article->getCategory(),
|
|
||||||
"tags" => $article->getTags(),
|
|
||||||
"creationDate" => $article->getCreationDate()
|
|
||||||
];
|
|
||||||
$updated = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
$articles = $this->getAllArticles();
|
// TODO: Implement deleteArticle() method.
|
||||||
$articleFound = false;
|
|
||||||
|
|
||||||
foreach ($articles as $index => $article) {
|
|
||||||
if (isset($article['id']) && $article['id'] == $id) {
|
|
||||||
unset($articles[$index]);
|
|
||||||
$articleFound = true;
|
|
||||||
break; // Schleife abbrechen, da die ID eindeutig ist
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($articleFound) {
|
|
||||||
// array_values stellt sicher, dass die Array-Keys wieder fortlaufend bei 0 beginnen
|
|
||||||
$this->saveArticle(array_values($articles));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArticle($id)
|
public function getArticle($id)
|
||||||
@@ -146,25 +97,25 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
return is_array($articles) ? $articles : [];
|
return is_array($articles) ? $articles : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArticlesByAuthor($author)
|
public function search(string $keyword): array
|
||||||
{
|
{
|
||||||
$articles = $this->getAllArticles();
|
$results = [];
|
||||||
$filteredArticles = [];
|
$contentFolder = __DIR__ . '/../content/';
|
||||||
|
$files = glob($contentFolder . "*.php");
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($files as $file) {
|
||||||
if (isset($article['author']) && $article['author'] == $author) {
|
$content = file_get_contents($file);
|
||||||
$filteredArticles[] = new Article(
|
if (stripos($content, $keyword) !== false) {
|
||||||
intval($article['id']),
|
$filename = basename($file, ".php");
|
||||||
$article['title'],
|
$results[] = [
|
||||||
$article['content'],
|
'title' => ucfirst($filename),
|
||||||
$article['author'],
|
'link' => "index.php?pfad=" . $filename
|
||||||
$article['category'],
|
];
|
||||||
$article['tags'],
|
|
||||||
$article['creationDate']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $filteredArticles;
|
return $results;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "UserDAOInterface.php";
|
|
||||||
|
|
||||||
class LocalUserDAO implements UserDAOInterface {
|
|
||||||
|
|
||||||
private string $file = "data/users.json";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface für den Zugriff auf Benutzerdaten.
|
|
||||||
*
|
|
||||||
* Definiert die Methoden, die jede UserDAO-Implementierung
|
|
||||||
* bereitstellen muss.
|
|
||||||
*/
|
|
||||||
interface UserDAOInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,107 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Prüft, ob der Autor auch der Eigentümer des Beitrags ist.
|
|
||||||
* @param $author
|
|
||||||
* @return true
|
|
||||||
* TODO: Implement this.
|
|
||||||
*/
|
|
||||||
function articleAuthorValidator($author)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob der Titel die folgenden Bedingungen erfüllt:
|
|
||||||
* Buchstaben von a-z; A-Z
|
|
||||||
* Zahlen von 0-9
|
|
||||||
* Umlaute äöüÄÖÜß
|
|
||||||
* Satzeichen .,!?:;()"„“«»_+-
|
|
||||||
* 5-120 Zeichen
|
|
||||||
* @param $title
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleTitleValidator($title)
|
|
||||||
{
|
|
||||||
$title = trim($title);
|
|
||||||
$titlePattern = '/^[a-zA-Z0-9äöüÄÖÜß\s.,!?:;()\'"„“«»_+-]{5,120}$/u';
|
|
||||||
if (preg_match($titlePattern, $title)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob der Contenttext 10-7000 Zeichen enthält.
|
|
||||||
* @param $content
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleContentValidator($content)
|
|
||||||
{
|
|
||||||
$content = trim($content);
|
|
||||||
$zeichenAnzahl = mb_strlen($content);
|
|
||||||
if ($zeichenAnzahl <= 7000 && $zeichenAnzahl >= 10) {
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob die Kategorie eine erlaubt Kategorie ist.
|
|
||||||
* @param $category
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleCategoryValidator($category)
|
|
||||||
{
|
|
||||||
$allowedCategories = [
|
|
||||||
'deutsch', 'englisch', 'franzoesisch', 'latein', 'literatur',
|
|
||||||
'mathe', 'biologie', 'chemie', 'physik', 'informatik', 'astronomie',
|
|
||||||
'geschichte', 'erdkunde', 'sozialkunde', 'wirtschaft', 'religion',
|
|
||||||
'ethik', 'philosophie', 'psychologie', 'kunst', 'musik', 'theater',
|
|
||||||
'technik', 'werken', 'hauswirtschaft', 'sport'
|
|
||||||
];
|
|
||||||
if (in_array($category, $allowedCategories, true)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob die Tags die folgenden Bedingungen erfüllen:
|
|
||||||
* Buchstaben von a-z; A-Z
|
|
||||||
* Zahlen von 0-9
|
|
||||||
* Umlaute äöüÄÖÜß
|
|
||||||
* Satzeichen -
|
|
||||||
* 2-50 Zeichen
|
|
||||||
* @param $tags
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleTagValidator($tags)
|
|
||||||
{
|
|
||||||
if (!isset($tags)) {
|
|
||||||
$tags = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$rawTags = explode(',', $tags);
|
|
||||||
|
|
||||||
foreach ($rawTags as $rawTag) {
|
|
||||||
// Leerzeichen am Anfang/Ende des einzelnen Tags entfernen:
|
|
||||||
$tag = trim($rawTag);
|
|
||||||
|
|
||||||
// leere Elemente überspringen:
|
|
||||||
if ($tag === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tag mit Regex prüfen:
|
|
||||||
$tagPattern = '/^[a-zA-Z0-9äöüÄÖÜß\s-]{2,50}$/u';
|
|
||||||
if (!preg_match($tagPattern, $tag)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
function userNameValidator($name)
|
|
||||||
{
|
|
||||||
$name = trim($name);
|
|
||||||
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,50}$/u';
|
|
||||||
|
|
||||||
return preg_match($namePattern, $name) === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function userEmailValidator($email)
|
|
||||||
{
|
|
||||||
$email = trim($email);
|
|
||||||
|
|
||||||
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false
|
|
||||||
&& mb_strlen($email) <= 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
function userPasswordValidator($password)
|
|
||||||
{
|
|
||||||
$zeichenAnzahl = mb_strlen($password);
|
|
||||||
|
|
||||||
return $zeichenAnzahl >= 8 && $zeichenAnzahl <= 72;
|
|
||||||
}
|
|
||||||
|
|
||||||
function userOptionalPasswordValidator($password)
|
|
||||||
{
|
|
||||||
if (!isset($password) || $password === '') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPasswordValidator($password);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
Artikel: Satz des Pythagoras
|
Artikel: Satz des Pythagoras
|
||||||
Funktion: Inhalt zum Fach Mathe
|
Funktion: Inhalt zum Fach Mathe
|
||||||
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
Artikel: Tunneleffekt
|
Artikel: Tunneleffekt
|
||||||
Funktion: Inhalt zum Fach Physik
|
Funktion: Inhalt zum Fach Physik
|
||||||
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|||||||
Reference in New Issue
Block a user