getArticle($_GET["id"]); if($article != null){ $title = $article->getTitle(); $content = $article->getContent(); $category = $article->getCategory(); $author = $article->getAuthor(); $tags = $article->getTags(); }else{ $_SESSION["message"] = "article_not_found"; echo "article_not_found"; } } catch (Exception $e){ $_SESSION["message"] = "internal_error"; echo "Fehler aufgetreten: " . $e->getMessage(); } }else{ $_SESSION["message"] = "article_not_found"; } // Wenn "speichern" gedrückt wurde: if ($_SERVER["REQUEST_METHOD"] === "POST") { if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){ $_SESSION["message"] = "missing_parameters"; header("location: ../../index.php?pfad=updateArticle"); exit(); } else { $newTitle = $_POST["title"]; $newContent = $_POST["content"]; $newCategory = $_POST["category"]; $author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen. $newTags = $_POST["tags"]; try { $articleManager = ArticleManager::getInstance(); $articleManager->updateArticle(new Article($newTitle, $newContent, $newCategory, $author, $newTags), $author); } catch (Exception $e){ $_SESSION["message"] = "internal_error"; } $_SESSION["message"] = "new_article"; // Weiterleitung zur Homepage header("location: ../../index.php"); exit(); } } ?>