Compare commits
273 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62a7b6773c | |||
| 625dd35b9e | |||
| f99b7bc8ab | |||
| e779162ec2 | |||
| 17345345b5 | |||
| 3df526d5b5 | |||
| d5f30176c4 | |||
| 308e5af6ff | |||
| 268fe6a6b9 | |||
| a24914126f | |||
| 1ca27bc072 | |||
| c96d93c2ce | |||
| cd38af22db | |||
| c440c25e41 | |||
| e105ab61b7 | |||
| 10b058afa0 | |||
| d18f33a87a | |||
| 62190fa821 | |||
| a6210c9d6e | |||
| fdece531af | |||
| 8073235466 | |||
| 7dc3c3b988 | |||
| 21793dffd7 | |||
| ca337c4fac | |||
| 76beb8d62e | |||
| c5bfd02f09 | |||
| 9f4ca058bd | |||
| 603c208ae4 | |||
| 754777d69e | |||
| 829a0e49d8 | |||
| f12babf2b1 | |||
| d6249169c6 | |||
| 6aa1cd9a63 | |||
| 09795c30dd | |||
| 59268dc102 | |||
| 979378d142 | |||
| 6ce7f0ef22 | |||
| 71a8dd5f17 | |||
| e86fef1766 | |||
| 3cb63f791a | |||
| f96415bfe6 | |||
| 365f70af98 | |||
| c1ddbfdf48 | |||
| e575e3dfa8 | |||
| 560f53cfb6 | |||
| d8c350c20f | |||
| 5b718f24ed | |||
| 6634bee77b | |||
| 2a3e73d409 | |||
| 2cd68873de | |||
| d987ca271f | |||
| 0a37dd4b8b | |||
| b4ca25db3d | |||
| 738b36c406 | |||
| c785363384 | |||
| 32cb8a9d9e | |||
| 29e23a8d3b | |||
| 1a6403963a | |||
| e096774233 | |||
| 222759a1bc | |||
| 7a3043f644 | |||
| f1986bc3f7 | |||
| 75d2f17a3f | |||
| 317f4c0ce9 | |||
| 4a7bfa9567 | |||
| fec3cbb550 | |||
| 497ce5bdb4 | |||
| 53b593b380 | |||
| 2d03b1f051 | |||
| d3c190096a | |||
| 2998a7bf22 | |||
| 43bd452a30 | |||
| dfdcc99111 | |||
| ea409dae07 | |||
| 2810bfdce2 | |||
| ff23e6c9a2 | |||
| 88c369de32 | |||
| 52a34cd9b4 | |||
| 46eb99b534 | |||
| 0eba5f875a | |||
| b93692c160 | |||
| 00f9f9cd91 | |||
| 2c0d52a3d5 | |||
| 4a67932002 | |||
| 339e3025b8 | |||
| 4d88605192 | |||
| bd3d81e80c | |||
| 98683197e0 | |||
| 2ded6300ab | |||
| 79efee0979 | |||
| 9db31d4b8c | |||
| d7c7ef1041 | |||
| 483dd4182e | |||
| f63a2be01a | |||
| 838b13e39f | |||
| 7b4abe32a7 | |||
| 26889a8b59 | |||
| 60302e02b6 | |||
| 72023a6634 | |||
| dd1194a1c7 | |||
| d5fbfc950f | |||
| d4fa588c8f | |||
| 2a5ff14cb5 | |||
| df17478d72 | |||
| 38fba55798 | |||
| 5b3e7bf426 | |||
| cb07a4c80f | |||
| 85512e61a2 | |||
| 380736ce26 | |||
| 9eb6feb589 | |||
| 23eee02208 | |||
| ca4dfd03e4 | |||
| 5c613a82c0 | |||
| 34ffad38a6 | |||
| b131523bf3 | |||
| db2bd7e195 | |||
| 51ccad038d | |||
| 18810dcfe2 | |||
| ed1815b78e | |||
| 246a2a856c | |||
| 77b3916985 | |||
| 298a9b406a | |||
| e5d6291aac | |||
| 667d009cf8 | |||
| 3edc689e5f | |||
| 938cca55fe | |||
| d5e177654f | |||
| 59bbbc6bf4 | |||
| ec814c9026 | |||
| b390437790 | |||
| d08e56bb5a | |||
| ccff6ab4cb | |||
| 04c1cb00c5 | |||
| 1f2be8b8ee | |||
| f2c0b4e4b5 | |||
| 77fd9af112 | |||
| 7ea3ce66ce | |||
| a91869bf47 | |||
| 9ae1cd4c34 | |||
| 475fb00001 | |||
| 168cf68a70 | |||
| 36d4ac0681 | |||
| 1afc7b480a | |||
| b88046e228 | |||
| 4f00859d1b | |||
| 1b68f037ae | |||
| 7067303758 | |||
| e499ffba22 | |||
| c4e7ca3ac2 | |||
| 55367963fb | |||
| 5522f4fc04 | |||
| 332507d433 | |||
| fe703d4e89 | |||
| ef6d6d9a91 | |||
| 128b191af5 | |||
| 5612bfe0b7 | |||
| d0f9a97394 | |||
| 67ecf6e870 | |||
| fd27577407 | |||
| 83ccf84da3 | |||
| 968534d28e | |||
| cd60423f1a | |||
| 9bb2587c49 | |||
| ef94a5873c | |||
| 8dbbe9eaf9 | |||
| 3afac85222 | |||
| 9eae4985d3 | |||
| 63c7bb8848 | |||
| 28ef21aa52 | |||
| 6a6ab16e09 | |||
| 5130a638b9 | |||
| bc9b5effb2 | |||
| 5ee412b050 | |||
| 65412e6df9 | |||
| 22ca680f3c | |||
| 83268d3a67 | |||
| d24bd0aa8b | |||
| c52834aa0d | |||
| 306b9e8152 | |||
| 30bb0d4657 | |||
| fdd7408f53 | |||
| 086596f68c | |||
| 7a206674ab | |||
| 9698512ccf | |||
| f4d144980d | |||
| 1513cbda7f | |||
| 1becb82b1b | |||
| 91880b163d | |||
| 81dd452f81 | |||
| 24642ad83e | |||
| 9b8f4036a9 | |||
| 86395f0727 | |||
| e5b617dcba | |||
| 581c012a72 | |||
| e5eaaf857e | |||
| e0835b70df | |||
| ed471cdf94 | |||
| f825537b52 | |||
| 485e08e6c6 | |||
| 7ff02a6a94 | |||
| ec0148bb86 | |||
| 9aa0793ab4 | |||
| 54220682cf | |||
| b13cff14dc | |||
| f86bdfd2ea | |||
| 3933b9b55c | |||
| 7a784c8243 | |||
| 10ddf8bf7f | |||
| 0779a2c7d4 | |||
| 053ae0b52f | |||
| be8b6372db | |||
| 6068417fc5 | |||
| 14d0b23d06 | |||
| 1f6ddcd1fd | |||
| 701fda5ab5 | |||
| 47731a8d46 | |||
| 0ade795415 | |||
| 2a9a60ae84 | |||
| efdc9b4175 | |||
| 6076903b42 | |||
| d43218fdb2 | |||
| 554dbd677a | |||
| 6a7e961cf6 | |||
| e49e614958 | |||
| 70fe6ff807 | |||
| f6932afcb8 | |||
| e3901265d8 | |||
| 368a4948ec | |||
| 6c07502866 | |||
| c1c8bc47d7 | |||
| 8466a857c3 | |||
| 68d9224ea3 | |||
| aac26b0e50 | |||
| a1a9fa9d3e | |||
| 5625326f38 | |||
| 8841cffb25 | |||
| d72bf8c3e2 | |||
| 04195f5d92 | |||
| 24a3ad0639 | |||
| 72097f891d | |||
| 0686e98384 | |||
| 7d9bef932f | |||
| e69cb50a9c | |||
| 890187cff2 | |||
| f2a9d8d1b3 | |||
| e128a31a34 | |||
| d7acca36fd | |||
| d28560b77e | |||
| ee6dd0ddae | |||
| feb64eb769 | |||
| ecc76e453e | |||
| 949ca542ab | |||
| b090195d9f | |||
| 1f1e7dc814 | |||
| 3606a750be | |||
| 8762bc1b07 | |||
| c7f279b7e9 | |||
| 92f1f077d2 | |||
| 50120f974d | |||
| 713a258d48 | |||
| 0a7e6df734 | |||
| 8c769ba280 | |||
| 5bcb64f7f8 | |||
| 944f40d89f | |||
| b15421efee | |||
| 2044853f94 | |||
| 9a3e4cc7dc | |||
| f508a222c6 | |||
| 365f37dcea | |||
| 2472143146 | |||
| a1184299b1 | |||
| c41302d046 | |||
| aaefd2917e |
Generated
+3
@@ -10,6 +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="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>
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
?>
|
||||||
|
<!--
|
||||||
|
Seite: Beitrag erstellen
|
||||||
|
Inhalt: Formular für die Erstellung eines neuen Beitrags
|
||||||
|
-->
|
||||||
|
<form method="post" action="php/controller/createArticle-controller.php" id="editor-form" class="article-editor-scope.editor-container article-editor-scope editor-container">
|
||||||
|
|
||||||
|
<main class="editor-main">
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Die ausgewählte Kategorie ist ungültig.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-50 Zeichen).
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
unset($_SESSION["message"]);
|
||||||
|
?>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<!-- Seitenleiste -->
|
||||||
|
<aside class="editor-sidebar">
|
||||||
|
|
||||||
|
<div class="sidebar-block">
|
||||||
|
<button type="submit" class="btn-publish">Veröffentlichen</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sidebar-block">
|
||||||
|
<label for="category">Kategorie <span class="required">*</span></label>
|
||||||
|
<select id="category" name="category" required>
|
||||||
|
<option value="" disabled selected>Kategorie wählen...</option>
|
||||||
|
|
||||||
|
<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 echo htmlspecialchars($_SESSION['old_tags'] ?? ''); unset($_SESSION['old_tags']); ?>"
|
||||||
|
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
</form>
|
||||||
+21
-3
@@ -1,8 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
include_once 'php/controller/home-controller.php';
|
||||||
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Seite: Home
|
Seite: Home
|
||||||
Inhalt: Beinhaltet den Inhalt der Startseite
|
Inhalt: Beinhaltet den Inhalt der Startseite
|
||||||
-->
|
-->
|
||||||
<main>
|
<main>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "new_article"): ?>
|
||||||
|
<p class="alert-message is-success">
|
||||||
|
Dein Beitrag wurde erfolgreich veröffentlicht!
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
unset($_SESSION["message"]);
|
||||||
|
?>
|
||||||
|
|
||||||
<h1>Home</h1>
|
<h1>Home</h1>
|
||||||
<p>
|
<p>
|
||||||
@@ -19,22 +36,23 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="index.php?pfad=informatik" class="category-link">Informatik</a>
|
<a href="index.php?pfad=informatik" class="category-link">Informatik</a>
|
||||||
<div class="article-link">
|
<div class="article-link">
|
||||||
<a href="datenschutzVSdatensicherheit.php">Datenschutz vs. Datensicherheit</a>
|
<a href="index.php?pfad=showArticle&id=<?php echo $dummy3->getId()?>"><?php if(isset($dummy3)){echo $dummy3->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="index.php?pfad=mathe" class="category-link">Mathe</a>
|
<a href="index.php?pfad=mathe" class="category-link">Mathe</a>
|
||||||
<div class="article-link">
|
<div class="article-link">
|
||||||
<a href="pythagoras.php">Satz des Pythagoras</a>
|
<a href="index.php?pfad=showArticle&id=<?php echo $dummy1->getId()?>"><?php if(isset($dummy1)){echo $dummy1->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="index.php?pfad=physik" class="category-link">Physik</a>
|
<a href="index.php?pfad=physik" class="category-link">Physik</a>
|
||||||
<div class="article-link">
|
<div class="article-link">
|
||||||
<a href="tunneleffekt.php">Der Tunneleffekt</a>
|
<a href="index.php?pfad=showArticle&id=<?php echo $dummy2->getId()?>"><?php if(isset($dummy2)){echo $dummy2->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
+81
-32
@@ -2,45 +2,94 @@
|
|||||||
Content: Profil
|
Content: Profil
|
||||||
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
||||||
-->
|
-->
|
||||||
|
<?php
|
||||||
|
include_once 'php/controller/profileArticles-controller.php';
|
||||||
|
?>
|
||||||
<main class="form-page">
|
<main class="form-page">
|
||||||
|
<div class="flexbox">
|
||||||
|
<!-- Linke Spalte: Profildaten -->
|
||||||
|
<div class="container">
|
||||||
|
<form>
|
||||||
|
<label class="input-label">Vorname</label>
|
||||||
|
<input type="text" name="Vorname" class="login-input" required
|
||||||
|
placeholder="Vorname"
|
||||||
|
value="<?php //DB-Daten ?>">
|
||||||
|
|
||||||
<div class="form-container">
|
<label class="input-label">Nachname</label>
|
||||||
<form>
|
<input type="text" name="Nachname" class="login-input" required
|
||||||
|
placeholder="Nachname"
|
||||||
|
value="<?php //DB-Daten ?>">
|
||||||
|
|
||||||
<label class="input-label">Vorname</label>
|
<label class="input-label">Email-Adresse</label>
|
||||||
|
<input type="email" name="Email" class="login-input" required
|
||||||
|
placeholder="mustermann@web.de"
|
||||||
|
value="<?php //DB-Daten ?>">
|
||||||
|
|
||||||
<input type="text" name="Vorname" class="login-input" required
|
<label class="input-label">Passwort</label>
|
||||||
placeholder="Vorname"
|
<input type="password" name="Passwort" class="login-input"
|
||||||
value="<?php //DB-Daten ?>">
|
required placeholder="Passwort">
|
||||||
|
|
||||||
<label class="input-label">Nachname</label>
|
<button type="submit" class="login-button">
|
||||||
<input type="text" name="Nachname" class="login-input" required
|
Speichern
|
||||||
placeholder="Nachname"
|
</button>
|
||||||
value="<?php //DB-Daten ?>">
|
|
||||||
|
|
||||||
<label class="input-label">Email-Adresse</label>
|
<button type="button" class="login-button delete-account-button">
|
||||||
<input type="email" name="Email" class="login-input" required
|
Account löschen
|
||||||
placeholder="mustermann@web.de"
|
</button>
|
||||||
value="<?php //DB-Daten ?>">
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label class="input-label">Passwort</label>
|
<!-- Rechte Spalte: Eigene Beiträge -->
|
||||||
<input type="password" name="Passwort" class="login-input"
|
<div class="container">
|
||||||
required placeholder="Passwort">
|
<h2 class="section-title">Meine Beiträge</h2>
|
||||||
|
<div class="articles-list">
|
||||||
<br>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
<button type="submit" class="login-button">
|
Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.
|
||||||
Speichern
|
</p>
|
||||||
</button>
|
<?php elseif (isset($userArticles) && count($userArticles) > 0): ?>
|
||||||
|
<?php foreach ($userArticles as $userArticle): ?>
|
||||||
<br><br>
|
<!-- Ein einzelner Artikel-Eintrag -->
|
||||||
|
<div class="article-item">
|
||||||
<button type="button" class="login-button">
|
<div class="article-meta">
|
||||||
Account löschen
|
<span class="article-date"><?php echo htmlspecialchars($userArticle->getCreationDate()); ?></span>
|
||||||
</button>
|
<span class="article-category"><?php echo htmlspecialchars($userArticle->getCategory()); ?></span>
|
||||||
|
</div>
|
||||||
</form>
|
<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="login-button" onclick="window.location.href='index.php?pfad=createArticle';">
|
||||||
|
Beitrag erstellen!
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
unset($_SESSION["message"]);
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
include_once 'php/controller/showArticle-controller.php';
|
||||||
|
?>
|
||||||
|
<!--
|
||||||
|
Seite: Anzeige für Beiträge
|
||||||
|
Funktion: Stellt einen übergebenen Beitrag dar.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Hauptcontainer für die Beitragsansicht (Ausschließlich der Content-Bereich) -->
|
||||||
|
<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 -->
|
||||||
|
<div class="article-view-top-section">
|
||||||
|
|
||||||
|
<?php if (isset($category) && !empty($category)): ?>
|
||||||
|
<span class="article-view-category"><?php echo htmlspecialchars($category); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
<h1 class="article-view-title">
|
||||||
|
<?php if (isset($title)) { echo htmlspecialchars($title); } ?>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div class="article-view-meta">
|
||||||
|
<?php if (isset($author) && !empty($author)): ?>
|
||||||
|
<span class="article-view-author">Von: <strong><?php echo htmlspecialchars($author); ?></strong></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Beitrags-Inhalt -->
|
||||||
|
<div class="article-view-content">
|
||||||
|
<?php if (isset($content)): ?>
|
||||||
|
<!-- nl2br für Zeilenumbrüche -->
|
||||||
|
<div class="article-view-body"><?php echo nl2br(htmlspecialchars($content)); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Beitrags-Endbereich (Tags) -->
|
||||||
|
<?php 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
|
||||||
|
// Falls $tags ein String ist (z.B. "Web, CSS"), in ein Array umwandeln
|
||||||
|
$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; ?>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
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
|
||||||
|
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="btn-publish">Ä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>
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
/* editor in Flexbox */
|
||||||
|
.article-editor-scope.editor-container {
|
||||||
|
display: flex;
|
||||||
|
min-height: 100vh;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||||
|
color: #1e1e1e;
|
||||||
|
background-color: #f0f2f5;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto; /* Zentriert den gesamten Container horizontal */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope * {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hauptbereich */
|
||||||
|
.article-editor-scope .editor-main {
|
||||||
|
flex: 1;
|
||||||
|
padding: 40px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope #title {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
width: 100%;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope #content {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
resize: none;
|
||||||
|
width: 100%;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Seitenleiste */
|
||||||
|
.article-editor-scope .editor-sidebar {
|
||||||
|
width: 300px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-left: 1px solid #e0e0e0;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope .sidebar-block {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope .sidebar-block label {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope .required {
|
||||||
|
color: #d94f4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Formularelemente innerhalb der Editor-Sidebar */
|
||||||
|
.article-editor-scope .editor-sidebar select,
|
||||||
|
.article-editor-scope .editor-sidebar input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button-Zeugs */
|
||||||
|
.article-editor-scope .btn-publish {
|
||||||
|
background-color: #007cba;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope .btn-publish:hover {
|
||||||
|
background-color: #006ba1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
|
@media (max-width: 760px) {
|
||||||
|
.article-editor-scope.editor-container {
|
||||||
|
/* Sidebar nach unten */
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope .editor-main {
|
||||||
|
/* weniger Innenabstand */
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope #content {
|
||||||
|
/* Verhindert, dass das Textfeld auf kleinen Displays kollabiert */
|
||||||
|
min-height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-editor-scope .editor-sidebar {
|
||||||
|
width: 100%;
|
||||||
|
/* Entfernt den linken Rand und setzt ihn nach oben als Trenner */
|
||||||
|
border-left: none;
|
||||||
|
border-top: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -212,3 +212,13 @@ 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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
.alert-message {
|
||||||
|
padding: 12px 16px;
|
||||||
|
margin: 12px 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.5;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rote Fehlermeldung */
|
||||||
|
.alert-message.is-error {
|
||||||
|
color: #ba1a1a;
|
||||||
|
background-color: #ffeede;
|
||||||
|
border-color: #ffb4ab;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grüne Erfolgsmeldung */
|
||||||
|
.alert-message.is-success {
|
||||||
|
color: #006e2c;
|
||||||
|
background-color: #e8f5e9;
|
||||||
|
border-color: #b2dfdb;
|
||||||
|
}
|
||||||
@@ -79,6 +79,8 @@ CSS für die navbar
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
|
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav__search {
|
.nav__search {
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
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; /* Moderne Färbung des Radio-Buttons */
|
accent-color: #3182ce;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- HAUPTINHALT (ERGEBNISSE) --- */
|
/* --- HAUPTINHALT (ERGEBNISSE) --- */
|
||||||
.s-res-main-content {
|
.s-res-main-content {
|
||||||
min-width: 0; /* Verhindert das Ausbrechen von Flex-Elementen */
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.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 DESIGN (MOBILGERÄTE) --- */
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
@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 */
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/* Container für den gesamten articleikel */
|
||||||
|
.article-view-container {
|
||||||
|
box-sizing: border-box;
|
||||||
|
max-width: 900px; /* Angenehme Lesebreite für längere Texte */
|
||||||
|
margin: 3rem auto;
|
||||||
|
padding: 0 2rem;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
color: #212529;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-container * {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- KOPFDATEN-BEREICH --- */
|
||||||
|
.article-view-top-section {
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
border-bottom: 1px solid #e2e8f0;
|
||||||
|
padding-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Kategorie-Badge */
|
||||||
|
.article-view-category {
|
||||||
|
display: inline-block;
|
||||||
|
background-color: #ebf8ff;
|
||||||
|
color: #2b6cb0;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hauptüberschrift */
|
||||||
|
.article-view-title {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
color: #1a202c;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin: 0 0 0.75rem 0;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Autoren-Zeile */
|
||||||
|
.article-view-meta {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #4a5568;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-author strong {
|
||||||
|
color: #2d3748;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- INHALT --- */
|
||||||
|
.article-view-content {
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-body {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
color: #2d3748;
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- TAG-BEREICH --- */
|
||||||
|
.article-view-bottom-section {
|
||||||
|
border-top: 1px solid #e2e8f0;
|
||||||
|
padding-top: 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-tags-label {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #718096;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-tags-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Einzelner Tag */
|
||||||
|
.article-view-tag-item {
|
||||||
|
background-color: #f1f5f9;
|
||||||
|
color: #475569;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 0.35rem 0.75rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
|
transition: background-color 0.2s, color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-tag-item:hover {
|
||||||
|
background-color: #e2e8f0;
|
||||||
|
color: #1e293b;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive Anpassungen unter 760px (für z.B. Smarticlephones) */
|
||||||
|
@media (max-width: 760px) {
|
||||||
|
.article-view-container {
|
||||||
|
margin: 1.5rem auto;
|
||||||
|
padding: 0 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-view-title {
|
||||||
|
font-size: 1.85rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -21,6 +21,7 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<li><a href="index.php?pfad=profile">Profil</a></li>
|
<li><a href="index.php?pfad=profile">Profil</a></li>
|
||||||
<li><a href="index.php?pfad=login">Anmelden</a></li>
|
<li><a href="index.php?pfad=login">Anmelden</a></li>
|
||||||
<li><a href="index.php?pfad=register">Registrieren</a></li>
|
<li><a href="index.php?pfad=register">Registrieren</a></li>
|
||||||
|
<li><a href="index.php?pfad=createArticle">Beitrag erstellen</a></li>
|
||||||
<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">
|
||||||
@@ -129,7 +130,8 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
include_once 'search.php';
|
include_once 'search.php';
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<a href = "index.php?pfad=login" class="nav__item nav__button">Anmelden</a>
|
<a href="index.php?pfad=login" class="nav__item nav__button">Anmelden</a>
|
||||||
<a href = "index.php?pfad=register" class="nav__item nav__button">Registrieren</a>
|
<a href="index.php?pfad=register" class="nav__item nav__button">Registrieren</a>
|
||||||
|
<a href="index.php?pfad=createArticle" class="nav__item nav__button">Beitrag erstellen</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
|
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
if (!isset($abs_path)) {
|
||||||
|
require_once "path.php";
|
||||||
|
}
|
||||||
|
require_once $abs_path . "/php/controller/index-controller.php";
|
||||||
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Seite: Index der Lernplattform
|
Seite: Index der Lernplattform
|
||||||
Funktion: Webseitengerüst, Anzeigen von Content
|
Funktion: Webseitengerüst, Anzeigen von Content
|
||||||
@@ -15,25 +24,28 @@
|
|||||||
<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/profile.css">
|
||||||
|
<link rel="stylesheet" href="css/showArticle.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:
|
//Dynamischer Inhalt:
|
||||||
if (isset($_GET["pfad"])) {
|
if (isset($_GET["pfad"])) {
|
||||||
if (file_exists('content/' . $_GET["pfad"] . '.php')) {
|
if (file_exists($abs_path . '/content/' . $_GET["pfad"] . '.php')) {
|
||||||
include_once 'content/' . $_GET["pfad"] . '.php';
|
include_once $abs_path . '/content/' . $_GET["pfad"] . '.php';
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/404.php';
|
include_once $abs_path . '/content/404.php';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/home.php';
|
include_once $abs_path . '/content/home.php';
|
||||||
}
|
}
|
||||||
include_once 'includes/footer.php';
|
include_once $abs_path . '/includes/footer.php';
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
// mit $_SERVER['DOCUMENT_ROOT'] später umbauen?
|
||||||
|
$abs_path = __DIR__;
|
||||||
|
?>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once '../model/LocalArticleManager.php';
|
||||||
|
require_once '../model/ArticleManager.php';
|
||||||
|
require_once '../validator/article-validator.php';
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||||
|
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
||||||
|
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
||||||
|
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
||||||
|
|
||||||
|
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
|
$_SESSION["message"] = "missing_parameters";
|
||||||
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$title = $_POST["title"];
|
||||||
|
$content = $_POST["content"];
|
||||||
|
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||||
|
$category = $_POST["category"];
|
||||||
|
$tags = $_POST['tags'] ?? '';
|
||||||
|
|
||||||
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
|
if (!articleAuthorValidator($author)) {
|
||||||
|
$_SESSION["message"] = "author_not_valid";
|
||||||
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!articleTitleValidator($title)) {
|
||||||
|
$_SESSION["message"] = "invalid_title";
|
||||||
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!articleContentValidator($content)) {
|
||||||
|
$_SESSION["message"] = "invalid_content";
|
||||||
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!articleCategoryValidator($category)) {
|
||||||
|
$_SESSION["message"] = "invalid_category";
|
||||||
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!articleTagValidator($tags)) {
|
||||||
|
$_SESSION["message"] = "invalid_tags";
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'php/model/Article.php';
|
||||||
|
require_once 'php/model/ArticleManager.php';
|
||||||
|
require_once 'php/model/LocalArticleManager.php';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$articleManager = ArticleManager::getInstance();
|
||||||
|
// Beziehen der Dummy-Beiträge aus dem ArticleManager:
|
||||||
|
$dummy1 = $articleManager->getArticle(1);
|
||||||
|
$dummy2 = $articleManager->getArticle(2);
|
||||||
|
$dummy3 = $articleManager->getArticle(3);
|
||||||
|
} catch (Exception $e){
|
||||||
|
$_SESSION["message"] = "internal_error";
|
||||||
|
echo "Fehler aufgetreten: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Controller für die Liste der eigenen Beiträge eines Nutzers auf der eigenen Profilseite
|
||||||
|
*/
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
require_once 'php/model/Article.php';
|
||||||
|
require_once 'php/model/ArticleManager.php';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$author = "max.mustermann"; // TODO: später Nutzer aus der Session beziehen.
|
||||||
|
$articleManager = ArticleManager::getInstance();
|
||||||
|
$userArticles = $articleManager->getArticlesByAuthor($author);
|
||||||
|
if(!isset($userArticles)) {
|
||||||
|
$_SESSION["message"] = "user_has_no_articles";
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$_SESSION["message"] = "internal_error";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'php/model/Article.php';
|
||||||
|
require_once 'php/model/ArticleManager.php';
|
||||||
|
|
||||||
|
if (isset($_GET["id"]) && !empty($_GET["id"])){
|
||||||
|
try {
|
||||||
|
$id = $_GET["id"];
|
||||||
|
$articleManager = ArticleManager::getInstance();
|
||||||
|
$article = $articleManager->getArticle($id);
|
||||||
|
if($article != null){
|
||||||
|
$title = $article->getTitle();
|
||||||
|
$content = $article->getContent();
|
||||||
|
$category = $article->getCategory();
|
||||||
|
$author = $article->getAuthor();
|
||||||
|
$tags = $article->getTags();
|
||||||
|
}else{
|
||||||
|
//header("location: index.php?pfad=404");
|
||||||
|
include_once "content/404.php";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
} catch (Exception $e){
|
||||||
|
$_SESSION["message"] = "internal_error";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$_SESSION["message"] = "missing_id";
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?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"] ?? '';
|
||||||
|
$_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 = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||||
|
$category = $_POST["category"];
|
||||||
|
$tags = $_POST['tags'] ?? '';
|
||||||
|
|
||||||
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
|
if (!articleAuthorValidator($author)) {
|
||||||
|
$_SESSION["message"] = "author_not_valid";
|
||||||
|
header("location: ../../index.php?pfad=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"] = "internal_error";
|
||||||
|
header("location: ../../index.php?pfad=updateArticle");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
$_SESSION["message"] = "article_updated";
|
||||||
|
// Weiterleitung zur Homepage
|
||||||
|
header("location: ../../index.php?pfad=showArticle&id=$id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Klasse: Artikel
|
||||||
|
* Diese Klasse stellt alle Daten eines Beitrags (Beitrag) bereit
|
||||||
|
*
|
||||||
|
* @author Niklas Ortmann
|
||||||
|
*/
|
||||||
|
class Article
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $title;
|
||||||
|
private $content;
|
||||||
|
private $author;
|
||||||
|
private $creationDate;
|
||||||
|
private $category;
|
||||||
|
private $tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konstruktor
|
||||||
|
*
|
||||||
|
* @param $id integer ID des Beitrages
|
||||||
|
* @param $title string Titel des Beitrags
|
||||||
|
* @param $content string Inhalt des Beitrags
|
||||||
|
* @param $author string der Autor des des Beitrages NID
|
||||||
|
* @param $category string Kategorie des Beitrages
|
||||||
|
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||||
|
* @param $creationDate string Datum der Beitragserstellung
|
||||||
|
*/
|
||||||
|
public function __construct(int $id, string $title, string $content, string $author, string $category, string $tags, string $creationDate)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->title = $title;
|
||||||
|
$this->content = $content;
|
||||||
|
$this->author = $author;
|
||||||
|
$this->creationDate = $creationDate;
|
||||||
|
$this->category = $category;
|
||||||
|
$this->tags = $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die ID eines Beitrags zurück.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den Titel eines Beitrags zurück.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt den Titel eines Beitrags
|
||||||
|
* @param $title
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setTitle($title)
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den Content eines Beitrags zurück.
|
||||||
|
* TODO: Content muss noch definiert werden.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getContent(): string
|
||||||
|
{
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt den Content eines Beitrags.
|
||||||
|
* TODO: Content muss noch definiert werden.
|
||||||
|
* @param $content
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setContent($content)
|
||||||
|
{
|
||||||
|
$this->content = $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den Autor eines Beitrags zurück.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAuthor(): string
|
||||||
|
{
|
||||||
|
return $this->author;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt das Veröffentlichungsdatum des Beitrags zurück.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCreationDate(): string
|
||||||
|
{
|
||||||
|
return $this->creationDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Kategorie eines Beitrags zurück.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCategory(): string
|
||||||
|
{
|
||||||
|
return $this->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt die Kategorie eines Beitrags.
|
||||||
|
* @param string $category
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setCategory(string $category)
|
||||||
|
{
|
||||||
|
$this->category = $category;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Schlagworte eines Beitrags zurück.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTags(): string
|
||||||
|
{
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt die Schlagworte eines Beitrags.
|
||||||
|
* @param string $tags
|
||||||
|
*/
|
||||||
|
public function setTags(string $tags)
|
||||||
|
{
|
||||||
|
$this->tags = $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'LocalArticleManager.php';
|
||||||
|
require_once 'Article.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
||||||
|
*
|
||||||
|
* @author Niklas Ortmann
|
||||||
|
*/
|
||||||
|
class ArticleManager extends LocalArticleManager
|
||||||
|
{
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
$articleManager = LocalArticleManager::getInstance(); // TODO: später durch DataBaseArticleManager ersetzen.
|
||||||
|
|
||||||
|
// Erstellen von Dummy-Beiträgen:
|
||||||
|
if($articleManager->getArticle(1) == null ){
|
||||||
|
$articleManager->addArticle(
|
||||||
|
"Satz des Pythagoras",
|
||||||
|
"Der Satz des Pythagoras wurde von dem griechischen Philosophen Pythagoras von Samos formuliert und im dritten Jahrhundert vor Christus veröffentlicht. In der beigefügten Abbildung sehen wir ein rechtwinkliges Dreieck...",
|
||||||
|
"max.mustermann",
|
||||||
|
"Mathe",
|
||||||
|
"Dreiecke, Dreiecksseiten berechnen"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if($articleManager->getArticle(2) == null ){
|
||||||
|
$articleManager->addArticle(
|
||||||
|
"Tunneleffekt",
|
||||||
|
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
||||||
|
"max.mustermann",
|
||||||
|
"Physik",
|
||||||
|
"Quantenphysik, Energie"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if($articleManager->getArticle(3) == null ){
|
||||||
|
$articleManager->addArticle(
|
||||||
|
"Datenschutz vs Datensicherheit",
|
||||||
|
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
|
||||||
|
"max.mustermann",
|
||||||
|
"Informatik",
|
||||||
|
"Daten, DSGVO"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $articleManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
require_once "Article.php";
|
||||||
|
/**
|
||||||
|
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
||||||
|
*
|
||||||
|
* @author Niklas Ortmann
|
||||||
|
*/
|
||||||
|
interface ArticleManagerDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Ein angemeldeter Nutzer erstellt einen neuen Beitrag.
|
||||||
|
* @param $title string Titel des Beitrags
|
||||||
|
* @param $content string Inhalt des Beitrags
|
||||||
|
* @param $author string der Autor des des Beitrages NID
|
||||||
|
* @param $category string Kategorie des Beitrages
|
||||||
|
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||||
|
*
|
||||||
|
* Mögliche Exceptions:
|
||||||
|
* TODO Fehlerbeschreibung hinzufügen & tags hinzufügen
|
||||||
|
*/
|
||||||
|
public function addArticle($title, $content, $author, $category, $tags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ändert den gespeicherten Beitrag eines übergebenen Beitrags und eines Autors.
|
||||||
|
* Es wird geprüft, ob der zu änderne Beitrag existiert und ob der übergebene Autor der Autor des originalen
|
||||||
|
* Beitrages ist.
|
||||||
|
* @param $id
|
||||||
|
* @param $article
|
||||||
|
* @param $author
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* TODO: Fehlerbeschreibung hinzufügen
|
||||||
|
*/
|
||||||
|
public function updateArticle($id, $article, $author);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Löscht einen Beitrag aus übergebener ID.
|
||||||
|
* @param $id
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* TODO: Fehlerbeschreibung hinzufügen
|
||||||
|
*/
|
||||||
|
public function deleteArticle($id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beitrag aufrufen.
|
||||||
|
* $id ID des Beitrags
|
||||||
|
*
|
||||||
|
* @return Article
|
||||||
|
* Mögliche Exceptions:
|
||||||
|
* TODO Fehlerbeschreibung hinzufügen
|
||||||
|
*/
|
||||||
|
public function getArticle($id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alle Beiträge aufrufen.
|
||||||
|
*
|
||||||
|
* Mögliche Exceptions:
|
||||||
|
* TODO Fehlerbeschreibung hinzufügen
|
||||||
|
*/
|
||||||
|
public function getAllArticles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
||||||
|
* @param $author
|
||||||
|
* @return Article[]
|
||||||
|
*/
|
||||||
|
public function getArticlesByAuthor($author);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'ArticleManagerDAO.php';
|
||||||
|
require_once 'Article.php';
|
||||||
|
/**
|
||||||
|
* Klasse: Eine lokale Lösung des ArticleManagerDAO.
|
||||||
|
* Schreibt zunächst Daten lokal in das Verzeichnis und kann diese wieder auslesen.
|
||||||
|
*
|
||||||
|
* @author Niklas Ortmann
|
||||||
|
*/
|
||||||
|
class LocalArticleManager implements ArticleManagerDAO {
|
||||||
|
|
||||||
|
private $file;
|
||||||
|
private static $instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konstruktor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->file = __DIR__ . '/../../data/articles.json';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die LocalArticleManager-Instanz zurück.
|
||||||
|
* @return LocalArticleManager
|
||||||
|
*/
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (self::$instance == null) {
|
||||||
|
self::$instance = new LocalArticleManager();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichert alle Artikel/Beiträge in der Datei.
|
||||||
|
* @param $articles
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function saveArticle($articles)
|
||||||
|
{
|
||||||
|
file_put_contents(
|
||||||
|
$this->file,
|
||||||
|
json_encode($articles, JSON_PRETTY_PRINT)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addArticle($title, $content, $author, $category, $tags)
|
||||||
|
{
|
||||||
|
$articles = $this->getAllArticles();
|
||||||
|
|
||||||
|
$articles[] = [
|
||||||
|
"id" => count($articles)+1,
|
||||||
|
"title" => $title,
|
||||||
|
"content" => $content,
|
||||||
|
"author" => $author,
|
||||||
|
"category" => $category,
|
||||||
|
"tags" => $tags,
|
||||||
|
"creationDate" => date("Y-m-d H:i:s")
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->saveArticle($articles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateArticle($id, $article, $author)
|
||||||
|
{
|
||||||
|
if (empty($article)) {
|
||||||
|
// TODO: Implement Exception.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Berechtigungsprüfung:
|
||||||
|
if ($article->getAuthor() !== $author) {
|
||||||
|
// TODO: Implement Exception.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}else{
|
||||||
|
// TODO: Implement Exception.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nur speichern, wenn Beitrag geändert wurde:
|
||||||
|
if ($updated) {
|
||||||
|
$this->saveArticle($articles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteArticle($id)
|
||||||
|
{
|
||||||
|
$articles = $this->getAllArticles();
|
||||||
|
$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)
|
||||||
|
{
|
||||||
|
$articles = $this->getAllArticles();
|
||||||
|
|
||||||
|
foreach ($articles as $article) {
|
||||||
|
if (isset($article['id']) && $article['id'] == $id) {
|
||||||
|
return new Article(intval($article['id']), $article['title'], $article['content'], $article['author'], $article['category'], $article['tags'], $article['creationDate']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllArticles(): array
|
||||||
|
{
|
||||||
|
if (!file_exists($this->file)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = file_get_contents($this->file);
|
||||||
|
$articles = json_decode($json, true);
|
||||||
|
|
||||||
|
return is_array($articles) ? $articles : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getArticlesByAuthor($author)
|
||||||
|
{
|
||||||
|
$articles = $this->getAllArticles();
|
||||||
|
$filteredArticles = [];
|
||||||
|
|
||||||
|
foreach ($articles as $article) {
|
||||||
|
if (isset($article['author']) && $article['author'] == $author) {
|
||||||
|
$filteredArticles[] = new Article(
|
||||||
|
intval($article['id']),
|
||||||
|
$article['title'],
|
||||||
|
$article['content'],
|
||||||
|
$article['author'],
|
||||||
|
$article['category'],
|
||||||
|
$article['tags'],
|
||||||
|
$article['creationDate']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $filteredArticles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user