Compare commits
3 Commits
| 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">
|
<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">
|
<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">
|
<p class="alert-message is-error">
|
||||||
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
||||||
</p>
|
</p>
|
||||||
@@ -34,7 +34,7 @@ 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 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">
|
<optgroup label="Sprachen">
|
||||||
<option value="deutsch">Deutsch</option>
|
<option value="deutsch">Deutsch</option>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ require_once 'php/model/ArticleManager.php';
|
|||||||
|
|
||||||
if (isset($_GET["id"])){
|
if (isset($_GET["id"])){
|
||||||
try {
|
try {
|
||||||
|
$id = (int)$_GET["id"];
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
$article = $articleManager->getArticle($_GET["id"]);
|
$article = $articleManager->getArticle($_GET["id"]);
|
||||||
if($article != null){
|
if($article != null){
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle");
|
||||||
exit();
|
exit();
|
||||||
|
} elseif(!isset($id)) {
|
||||||
|
$_SESSION["message"] = "missing_id";
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$newTitle = $_POST["title"];
|
$newTitle = $_POST["title"];
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ interface ArticleManagerDAO
|
|||||||
* Ändert den gespeicherten Beitrag eines übergebenen Beitrags und eines Autors.
|
* Ä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
|
* Es wird geprüft, ob der zu änderne Beitrag existiert und ob der übergebene Autor der Autor des originalen
|
||||||
* Beitrages ist.
|
* Beitrages ist.
|
||||||
|
* @param $id
|
||||||
* @param $article
|
* @param $article
|
||||||
* @param $author
|
* @param $author
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* TODO: Fehlerbeschreibung hinzufügen
|
* TODO: Fehlerbeschreibung hinzufügen
|
||||||
*/
|
*/
|
||||||
public function updateArticle($article, $author);
|
public function updateArticle($id, $article, $author);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Löscht einen Beitrag aus übergebener ID.
|
* Löscht einen Beitrag aus übergebener ID.
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
$this->saveArticle($articles);
|
$this->saveArticle($articles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateArticle($article, $author)
|
public function updateArticle($id, $article, $author)
|
||||||
{
|
{
|
||||||
if (empty($article)) {
|
if (empty($article)) {
|
||||||
return;
|
return;
|
||||||
@@ -79,9 +79,9 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
|
|
||||||
// Beitrag aktualisieren:
|
// Beitrag aktualisieren:
|
||||||
foreach ($articles as $index => $storedArticle) {
|
foreach ($articles as $index => $storedArticle) {
|
||||||
if (isset($storedArticle['id']) && $storedArticle['id'] == $article->getId()) {
|
if (isset($storedArticle['id']) && $storedArticle['id'] == $id) {
|
||||||
$articles[$index] = [
|
$articles[$index] = [
|
||||||
"id" => $article->getId(),
|
"id" => $id,
|
||||||
"title" => $article->getTitle(),
|
"title" => $article->getTitle(),
|
||||||
"content" => $article->getContent(),
|
"content" => $article->getContent(),
|
||||||
"author" => $article->getAuthor(),
|
"author" => $article->getAuthor(),
|
||||||
|
|||||||
Reference in New Issue
Block a user