Compare commits

..

3 Commits

Author SHA1 Message Date
NOrtmann1 c785363384 missing_id 2026-05-29 17:40:56 +01:00
NOrtmann1 32cb8a9d9e updateArticle Anpassungen 2026-05-29 17:36:29 +01:00
NOrtmann1 29e23a8d3b Update updateArticle.php 2026-05-29 17:32:57 +01:00
5 changed files with 11 additions and 7 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ include_once 'php/controller/showArticle-controller.php';
<form method="post" action="php/controller/updateArticle-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"): ?>
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error" || $_SESSION["message"] == "missing_id"): ?>
<p class="alert-message is-error">
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
</p>
@@ -34,7 +34,7 @@ include_once 'php/controller/showArticle-controller.php';
<div class="sidebar-block">
<label for="category">Kategorie <span class="required">*</span></label>
<select id="category" name="category" required>
<option value="<?php if (isset($category) && !empty($category)){echo htmlspecialchars($category);} ?>" disabled selected>Kategorie wählen...</option>
<option disabled selected>Kategorie wählen...</option>
<optgroup label="Sprachen">
<option value="deutsch">Deutsch</option>
@@ -5,6 +5,7 @@ require_once 'php/model/ArticleManager.php';
if (isset($_GET["id"])){
try {
$id = (int)$_GET["id"];
$articleManager = ArticleManager::getInstance();
$article = $articleManager->getArticle($_GET["id"]);
if($article != null){
+3 -1
View File
@@ -9,7 +9,9 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$_SESSION["message"] = "missing_parameters";
header("location: ../../index.php?pfad=updateArticle");
exit();
} else {
} elseif(!isset($id)) {
$_SESSION["message"] = "missing_id";
}else{
$newTitle = $_POST["title"];
$newContent = $_POST["content"];
+2 -1
View File
@@ -24,13 +24,14 @@ interface ArticleManagerDAO
* Ä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($article, $author);
public function updateArticle($id, $article, $author);
/**
* Löscht einen Beitrag aus übergebener ID.
+3 -3
View File
@@ -62,7 +62,7 @@ class LocalArticleManager implements ArticleManagerDAO {
$this->saveArticle($articles);
}
public function updateArticle($article, $author)
public function updateArticle($id, $article, $author)
{
if (empty($article)) {
return;
@@ -79,9 +79,9 @@ class LocalArticleManager implements ArticleManagerDAO {
// Beitrag aktualisieren:
foreach ($articles as $index => $storedArticle) {
if (isset($storedArticle['id']) && $storedArticle['id'] == $article->getId()) {
if (isset($storedArticle['id']) && $storedArticle['id'] == $id) {
$articles[$index] = [
"id" => $article->getId(),
"id" => $id,
"title" => $article->getTitle(),
"content" => $article->getContent(),
"author" => $article->getAuthor(),