Compare commits
3 Commits
1a6403963a
...
c785363384
| Author | SHA1 | Date | |
|---|---|---|---|
| c785363384 | |||
| 32cb8a9d9e | |||
| 29e23a8d3b |
@@ -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){
|
||||
|
||||
@@ -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"];
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user