Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87e595b13d | |||
| aae78bf479 | |||
| 1f7a2a77f6 | |||
| 9269465f6b | |||
| 883adfd242 | |||
| 1e890f9a28 | |||
| 2bb13d2e8c | |||
| cb02e05d55 | |||
| 05777f6109 | |||
| f3f042b3b9 | |||
| dfb13b1f96 | |||
| 6fa5038589 | |||
| 55f53e3346 | |||
| f36037d36d | |||
| 500bca80c1 | |||
| fc0361ed3a | |||
| df1485ce49 | |||
| b8bceb31c6 | |||
| f0308c3505 | |||
| e7ece1ed13 | |||
| 8ed7f7ec8f | |||
| feaef4a624 | |||
| 7d9aae2a59 | |||
| a88f8ca638 | |||
| be6a5f9add | |||
| ed4498578d |
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
## Login-Informationen für Dummy-User
|
## Login-Informationen für Dummy-User
|
||||||
`Anmeldename, Passwort, Mailadresse`:
|
`Anmeldename, Passwort, Mailadresse`:
|
||||||
- `max.mustermann, test12345, mustermann@web.de`
|
- `max.mustermann, test12345, max.mustermann@web.de`
|
||||||
|
|
||||||
## Weitere Voraussetzungen zur Nutzung
|
## Weitere Voraussetzungen zur Nutzung
|
||||||
- Per Klick auf das Logo gelangt man auf die Home-Seite.
|
- Per Klick auf das Logo gelangt man auf die Home-Seite.
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
||||||
- Die Suchseite und Kategorieseite packen momentan alle passenden Beiträge untereinander. Später sollen zunächst 10
|
- Die Suchseite und Kategorieseite packen momentan alle passenden Beiträge untereinander. Später sollen zunächst 10
|
||||||
Ergebnisse auf einer Seite angezeigt werden.
|
Ergebnisse auf einer Seite angezeigt werden.
|
||||||
|
- Wenn ein Bild aus einem Beitrag entfernt wird, dann wird noch nicht die Datei im Pfad /uploads gelöscht.
|
||||||
|
|
||||||
## Besonderheiten des Projektes
|
## Besonderheiten des Projektes
|
||||||
- Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden.
|
- Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden.
|
||||||
|
|||||||
+197
-28
@@ -10,7 +10,7 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
Seite: Beitrag erstellen
|
Seite: Beitrag erstellen
|
||||||
Inhalt: Formular für die Erstellung eines neuen Beitrags
|
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">
|
<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" enctype="multipart/form-data" class="article-editor-scope.editor-container article-editor-scope editor-container">
|
||||||
|
|
||||||
<main class="editor-main">
|
<main class="editor-main">
|
||||||
<?php include_once "includes/alertMessages.php"?>
|
<?php include_once "includes/alertMessages.php"?>
|
||||||
@@ -50,6 +50,9 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
echo '[]';
|
echo '[]';
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
|
|
||||||
|
<!-- unsichtbares Input, um die zu löschenden Bilder zu übergeben-->
|
||||||
|
<input type="hidden" id="deleted-images" name="deleted_images" value="[]">
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
@@ -62,45 +65,211 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<label for="category">Kategorie <span class="required">*</span></label>
|
<label for="category">Kategorie <span class="required">*</span></label>
|
||||||
<select id="category" name="category" required>
|
<select id="category" name="category" required>
|
||||||
<option disabled selected>Kategorie wählen...</option>
|
<option disabled <?php
|
||||||
|
if ((!isset($_SESSION['old_category']) || empty($_SESSION['old_category'])) && (!isset($category) || empty($category))) {
|
||||||
|
echo 'selected';
|
||||||
|
}
|
||||||
|
?>>Kategorie wählen...</option>
|
||||||
|
|
||||||
<optgroup label="Sprachen">
|
<optgroup label="Sprachen">
|
||||||
<option value="deutsch">Deutsch</option>
|
<option value="deutsch" <?php
|
||||||
<option value="englisch">Englisch</option>
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
<option value="franzoesisch">Französisch</option>
|
if ($_SESSION['old_category'] === 'deutsch') { echo 'selected'; }
|
||||||
<option value="latein">Latein</option>
|
} elseif (isset($category) && !empty($category)) {
|
||||||
<option value="literatur">Literatur</option>
|
if ($category === 'deutsch') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Deutsch</option>
|
||||||
|
<option value="englisch" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'englisch') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'englisch') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Englisch</option>
|
||||||
|
<option value="franzoesisch" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'franzoesisch') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'franzoesisch') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Französisch</option>
|
||||||
|
<option value="latein" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'latein') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'latein') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Latein</option>
|
||||||
|
<option value="literatur" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'literatur') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'literatur') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Literatur</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
||||||
<optgroup label="MINT">
|
<optgroup label="MINT">
|
||||||
<option value="mathe">Mathematik</option>
|
<option value="mathe" <?php
|
||||||
<option value="biologie">Biologie</option>
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
<option value="chemie">Chemie</option>
|
if ($_SESSION['old_category'] === 'mathe') { echo 'selected'; }
|
||||||
<option value="physik">Physik</option>
|
} elseif (isset($category) && !empty($category)) {
|
||||||
<option value="informatik">Informatik</option>
|
if ($category === 'mathe') { echo 'selected'; }
|
||||||
<option value="astronomie">Astronomie</option>
|
}
|
||||||
|
?>>Mathematik</option>
|
||||||
|
<option value="biologie" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'biologie') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'biologie') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Biologie</option>
|
||||||
|
<option value="chemie" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'chemie') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'chemie') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Chemie</option>
|
||||||
|
<option value="physik" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'physik') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'physik') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Physik</option>
|
||||||
|
<option value="informatik" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'informatik') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'informatik') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Informatik</option>
|
||||||
|
<option value="astronomie" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'astronomie') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'astronomie') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Astronomie</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
||||||
<optgroup label="Gesellschaft & Werte">
|
<optgroup label="Gesellschaft & Werte">
|
||||||
<option value="geschichte">Geschichte</option>
|
<option value="geschichte" <?php
|
||||||
<option value="erdkunde">Erdkunde</option>
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
<option value="sozialkunde">Sozialkunde</option>
|
if ($_SESSION['old_category'] === 'geschichte') { echo 'selected'; }
|
||||||
<option value="wirtschaft">Wirtschaftskunde</option>
|
} elseif (isset($category) && !empty($category)) {
|
||||||
<option value="religion">Religion</option>
|
if ($category === 'geschichte') { echo 'selected'; }
|
||||||
<option value="ethik">Ethikunterricht</option>
|
}
|
||||||
<option value="philosophie">Philosophie</option>
|
?>>Geschichte</option>
|
||||||
<option value="psychologie">Psychologie</option>
|
<option value="erdkunde" <?php
|
||||||
<option value="kunst">Kunst</option>
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
<option value="musik">Musik</option>
|
if ($_SESSION['old_category'] === 'erdkunde') { echo 'selected'; }
|
||||||
<option value="theater">Theater</option>
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'erdkunde') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Erdkunde</option>
|
||||||
|
<option value="sozialkunde" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'sozialkunde') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'sozialkunde') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Sozialkunde</option>
|
||||||
|
<option value="wirtschaft" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'wirtschaft') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'wirtschaft') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Wirtschaftskunde</option>
|
||||||
|
<option value="religion" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'religion') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'religion') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Religion</option>
|
||||||
|
<option value="ethik" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'ethik') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'ethik') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Ethikunterricht</option>
|
||||||
|
<option value="philosophie" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'philosophie') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'philosophie') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Philosophie</option>
|
||||||
|
<option value="psychologie" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'psychologie') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'psychologie') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Psychologie</option>
|
||||||
|
<option value="kunst" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'kunst') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'kunst') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Kunst</option>
|
||||||
|
<option value="musik" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'musik') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'musik') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Musik</option>
|
||||||
|
<option value="theater" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'theater') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'theater') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Theater</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
||||||
<optgroup label="Technik & Praxis">
|
<optgroup label="Technik & Praxis">
|
||||||
<option value="technik">Technik</option>
|
<option value="technik" <?php
|
||||||
<option value="werken">Werken</option>
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
<option value="hauswirtschaft">Hauswirtschaft</option>
|
if ($_SESSION['old_category'] === 'technik') { echo 'selected'; }
|
||||||
<option value="sport">Sport</option>
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'technik') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Technik</option>
|
||||||
|
<option value="werken" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'werken') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'werken') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Werken</option>
|
||||||
|
<option value="hauswirtschaft" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'hauswirtschaft') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'hauswirtschaft') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Hauswirtschaft</option>
|
||||||
|
<option value="sport" <?php
|
||||||
|
if (isset($_SESSION['old_category']) && !empty($_SESSION['old_category'])) {
|
||||||
|
if ($_SESSION['old_category'] === 'sport') { echo 'selected'; }
|
||||||
|
} elseif (isset($category) && !empty($category)) {
|
||||||
|
if ($category === 'sport') { echo 'selected'; }
|
||||||
|
}
|
||||||
|
?>>Sport</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['old_category'])) {
|
||||||
|
unset($_SESSION['old_category']);
|
||||||
|
}
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
||||||
<p class="alert-message is-error">
|
<p class="alert-message is-error">
|
||||||
Der Text- und Bildblock dürfen nicht leer sein!
|
Ein Beitrag muss Inhalt besitzen. Text- und Bildelemente dürfen nicht leer sein!
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
||||||
|
|||||||
+58
-5
@@ -15,6 +15,8 @@ function initEditor() {
|
|||||||
const popup = document.getElementById("block-popup");
|
const popup = document.getElementById("block-popup");
|
||||||
const hiddenContentInput = document.getElementById("content");
|
const hiddenContentInput = document.getElementById("content");
|
||||||
|
|
||||||
|
const initialImages = [];
|
||||||
|
|
||||||
// Pop-up umschalten bei Klick auf das Plus
|
// Pop-up umschalten bei Klick auf das Plus
|
||||||
plusButton.addEventListener("click", () => {
|
plusButton.addEventListener("click", () => {
|
||||||
popup.classList.toggle("hidden");
|
popup.classList.toggle("hidden");
|
||||||
@@ -35,12 +37,19 @@ function initEditor() {
|
|||||||
blockDiv.classList.add("editor-block");
|
blockDiv.classList.add("editor-block");
|
||||||
blockDiv.setAttribute("data-type", type);
|
blockDiv.setAttribute("data-type", type);
|
||||||
|
|
||||||
// Löschen-Button für den Block
|
// Wenn es ein existierendes Server-Bild beim Laden ist, Pfad im globalen Array sichern
|
||||||
|
if (type === "image" && value && typeof value === 'string' && value.startsWith('uploads/')) {
|
||||||
|
initialImages.push(value);
|
||||||
|
blockDiv.setAttribute("data-value", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Löschen-Button
|
||||||
const deleteBtn = document.createElement("button");
|
const deleteBtn = document.createElement("button");
|
||||||
deleteBtn.type = "button";
|
deleteBtn.type = "button";
|
||||||
deleteBtn.innerHTML = "✕";
|
deleteBtn.innerHTML = "✕";
|
||||||
deleteBtn.classList.add("delete-block-btn");
|
deleteBtn.classList.add("delete-block-btn");
|
||||||
deleteBtn.addEventListener("click", () => {
|
deleteBtn.addEventListener("click", () => {
|
||||||
|
// ANPASSUNG 2B: Logik hier komplett geleert. Das '✕' entfernt den Block jetzt nur noch sicher aus dem HTML.
|
||||||
blockDiv.remove();
|
blockDiv.remove();
|
||||||
});
|
});
|
||||||
blockDiv.appendChild(deleteBtn);
|
blockDiv.appendChild(deleteBtn);
|
||||||
@@ -85,9 +94,12 @@ function initEditor() {
|
|||||||
container.appendChild(blockDiv);
|
container.appendChild(blockDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beim Abschicken: HTML-Blöcke auslesen und als JSON-String serialisieren
|
// beim Abschicken verbleibende Blöcke auslesen UND gelöschte Bilder ermitteln
|
||||||
form.addEventListener("submit", function(e) {
|
form.addEventListener("submit", function(e) {
|
||||||
const blocks = [];
|
const blocks = [];
|
||||||
|
const currentImages = [];
|
||||||
|
|
||||||
|
// alle aktuell im Formular verbliebenen Blöcke scannen
|
||||||
container.querySelectorAll(".editor-block").forEach(blockDiv => {
|
container.querySelectorAll(".editor-block").forEach(blockDiv => {
|
||||||
const type = blockDiv.getAttribute("data-type");
|
const type = blockDiv.getAttribute("data-type");
|
||||||
let value = "";
|
let value = "";
|
||||||
@@ -95,20 +107,61 @@ function initEditor() {
|
|||||||
if (type === "text") {
|
if (type === "text") {
|
||||||
value = blockDiv.querySelector("textarea").value;
|
value = blockDiv.querySelector("textarea").value;
|
||||||
} else if (type === "image") {
|
} else if (type === "image") {
|
||||||
value = blockDiv.getAttribute("data-value") || "";
|
|
||||||
|
const imgTag = blockDiv.querySelector("img");
|
||||||
|
if (imgTag) {
|
||||||
|
const srcValue = imgTag.getAttribute("src") || "";
|
||||||
|
// Wenn es ein neues Bild ist, nutzen wir das data-value (Base64)
|
||||||
|
if (srcValue.startsWith('data:image/')) {
|
||||||
|
value = blockDiv.getAttribute("data-value") || "";
|
||||||
|
} else {
|
||||||
|
value = srcValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pfade sammeln, die der Nutzer NICHT gelöscht hat (für den Abgleich)
|
||||||
|
if (value && value.startsWith('uploads/')) {
|
||||||
|
currentImages.push(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks.push({ type: type, value: value });
|
blocks.push({ type: type, value: value });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// das reguläre unsichtbare Content-Feld befüllen
|
||||||
hiddenContentInput.value = JSON.stringify(blocks);
|
hiddenContentInput.value = JSON.stringify(blocks);
|
||||||
|
|
||||||
|
// Differenz berechnen: Welche Bilder aus 'initialImages' fehlen in 'currentImages' ?
|
||||||
|
const deletedImages = initialImages.filter(img => !currentImages.includes(img));
|
||||||
|
|
||||||
|
// das 'deleted_images'-Feld dynamisch befüllen und an den Controller senden
|
||||||
|
let deletedInput = document.getElementById("deleted-images");
|
||||||
|
if (!deletedInput) {
|
||||||
|
deletedInput = document.createElement("input");
|
||||||
|
deletedInput.type = "hidden";
|
||||||
|
deletedInput.id = "deleted-images";
|
||||||
|
deletedInput.name = "deleted_images";
|
||||||
|
form.appendChild(deletedInput);
|
||||||
|
}
|
||||||
|
deletedInput.value = JSON.stringify(deletedImages);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Existierende Blöcke laden (stellt alte Daten aus der Session wieder her)
|
// Existierende Blöcke laden (stellt alte Daten aus der Session wieder her)
|
||||||
try {
|
try {
|
||||||
const initialBlocks = JSON.parse(hiddenContentInput.value);
|
const initialBlocks = JSON.parse(hiddenContentInput.value.trim());
|
||||||
if (Array.isArray(initialBlocks)) {
|
if (Array.isArray(initialBlocks)) {
|
||||||
initialBlocks.forEach(b => addBlockElement(b.type, b.value));
|
initialBlocks.forEach(b => {
|
||||||
|
if (b.type === "image" && b.value && typeof b.value === 'string' && !b.value.startsWith('data:image/')) {
|
||||||
|
let cleanPath = b.value.trim().replace(/\\\//g, '/'); // Verwandelt \/ in /
|
||||||
|
|
||||||
|
initialImages.push(cleanPath);
|
||||||
|
addBlockElement(b.type, cleanPath);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
addBlockElement(b.type, b.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("Erfolgreich registrierte Start-Bilder:", initialImages);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if (hiddenContentInput.value.trim() !== "") {
|
if (hiddenContentInput.value.trim() !== "") {
|
||||||
|
|||||||
@@ -24,12 +24,6 @@ require_once '../validator/article-validator.php';
|
|||||||
$tags = $_POST['tags'] ?? '';
|
$tags = $_POST['tags'] ?? '';
|
||||||
|
|
||||||
// -------------------------------- Validierung der Daten: -------------------------
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
if (!articleAuthorValidator($author)) {
|
|
||||||
$_SESSION["message"] = "author_not_valid";
|
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
if (!articleTitleValidator($title)) {
|
||||||
$_SESSION["message"] = "invalid_title";
|
$_SESSION["message"] = "invalid_title";
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$tags = $_POST['tags'] ?? '';
|
$tags = $_POST['tags'] ?? '';
|
||||||
|
|
||||||
// -------------------------------- Validierung der Daten: -------------------------
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
if (!articleAuthorValidator($author)) {
|
|
||||||
$_SESSION["message"] = "author_not_valid";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
if (!articleTitleValidator($title)) {
|
||||||
$_SESSION["message"] = "invalid_title";
|
$_SESSION["message"] = "invalid_title";
|
||||||
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
@@ -75,7 +69,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$cleanedTags = implode(',', $cleanedTags);
|
$cleanedTags = implode(',', $cleanedTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- Base64-Bilder speichern -----------------
|
// --------------------------------------- Base64-Bilder speichern ---------------------------------------------
|
||||||
$blocks = json_decode($content, true);
|
$blocks = json_decode($content, true);
|
||||||
$uploadDir = __DIR__ . '/../../uploads/';
|
$uploadDir = __DIR__ . '/../../uploads/';
|
||||||
|
|
||||||
@@ -83,6 +77,35 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
mkdir($uploadDir, 0755, true);
|
mkdir($uploadDir, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------- Gelöschte Bilder über die JS-Löschliste entfernen ----------------- TODO: Gelöschte Bilder über die JS-Löschliste entfernen
|
||||||
|
/*if (isset($_POST['deleted_images'])) {
|
||||||
|
$deletedImages = json_decode($_POST['deleted_images'], true);
|
||||||
|
|
||||||
|
// Wir ermitteln den physisch echten, absoluten Pfad zum uploads-Ordner auf der Festplatte
|
||||||
|
$uploadDir = realpath(__DIR__ . '/../../uploads') . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
if (is_array($deletedImages)) {
|
||||||
|
foreach ($deletedImages as $imagePath) {
|
||||||
|
// Nur den reinen Dateinamen heraustrennen (z.B. img_65a123.jpg)
|
||||||
|
$filename = basename($imagePath);
|
||||||
|
$fullDeletePath = $uploadDir . $filename;
|
||||||
|
|
||||||
|
// Debugging & Löschen:
|
||||||
|
if (file_exists($fullDeletePath)) {
|
||||||
|
// Versuchen zu löschen. Wenn es fehlschlägt, Fehlermeldung erzwingen
|
||||||
|
if (!@unlink($fullDeletePath)) {
|
||||||
|
$error = error_get_last();
|
||||||
|
die("Datei existiert, aber PHP darf sie nicht löschen! Grund: " . $error['message']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Wenn PHP die Datei an diesem Pfad nicht findet, brechen wir zum Debuggen ab
|
||||||
|
// die("PHP findet die Datei nicht unter dem Pfad: " . $fullDeletePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// ----------------------- NEU hinzugefügte Base64-Bilder: --------------------------
|
||||||
if (is_array($blocks)) {
|
if (is_array($blocks)) {
|
||||||
foreach ($blocks as &$block) {
|
foreach ($blocks as &$block) {
|
||||||
// Prüfen, ob der Block ein Bild ist und ein NEUES Bild (Base64-Format) enthält
|
// Prüfen, ob der Block ein Bild ist und ein NEUES Bild (Base64-Format) enthält
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ArticleManager
|
|||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
$articleManager = DatabaseArticleManager::getInstance(); // Hier kann zwischen dem lokalen und datenbankbasiertem ArticleManager gewechselt werden.
|
$articleManager = DatabaseArticleManager::getInstance(); // Hier kann zwischen dem lokalen und datenbankbasiertem ArticleManager gewechselt werden.
|
||||||
/*
|
|
||||||
// 100 fiktionale Fachbeiträge:
|
// 100 fiktionale Fachbeiträge:
|
||||||
$dummyArticles = [
|
$dummyArticles = [
|
||||||
// --- INFORMATIK & MATHE (1-20) ---
|
// --- INFORMATIK & MATHE (1-20) ---
|
||||||
@@ -145,16 +145,24 @@ class ArticleManager
|
|||||||
// Verteilt die 10 Autoren gleichmäßig (ID 1 -> Autor 1, ID 10 -> Autor 10, ID 11 -> Autor 1)
|
// Verteilt die 10 Autoren gleichmäßig (ID 1 -> Autor 1, ID 10 -> Autor 10, ID 11 -> Autor 1)
|
||||||
$authorEmail = $authors[($id - 1) % 10];
|
$authorEmail = $authors[($id - 1) % 10];
|
||||||
|
|
||||||
|
$blockStructure = [
|
||||||
|
[
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => $data[1] // Der originale Text aus dem Dummy-Array
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$jsonContent = json_encode($blockStructure, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
$articleManager->addArticle(
|
$articleManager->addArticle(
|
||||||
$data[0], // Titel
|
$data[0], // Titel
|
||||||
$data[1], // Inhalt
|
$jsonContent, // Inhalt
|
||||||
$authorEmail, // Rotierende Autoren-E-Mail
|
$authorEmail, // Rotierende Autoren-E-Mail
|
||||||
$data[2], // Kategorie
|
$data[2], // Kategorie
|
||||||
$data[3] // Tags
|
$data[3] // Tags
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return $articleManager;
|
return $articleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,5 @@
|
|||||||
<?php
|
<?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:
|
* Prüft, ob der Titel die folgenden Bedingungen erfüllt:
|
||||||
* Buchstaben von a-z; A-Z
|
* Buchstaben von a-z; A-Z
|
||||||
|
|||||||
Reference in New Issue
Block a user