45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
require_once '../model/LocalArticleManager.php';
|
|
require_once '../model/ArticleManager.php';
|
|
|
|
try {
|
|
//$articleManager = new LocalArticleManager(); // TODO: später durch DB-Implementation von ArticleManger ersetzen.
|
|
$articleManager = ArticleManager::getInstance();
|
|
}catch (Exception $e){
|
|
die("Fehler bei der Initialisierung des Artikel-Managers: " . $e->getMessage());
|
|
}
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
|
$_SESSION["message"] = "missing_parameters";
|
|
header("location: ../../index.php?pfad=createArticle");
|
|
} else {
|
|
|
|
$title = $_POST["title"];
|
|
$content = $_POST["content"];
|
|
$category = $_POST["category"];
|
|
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
|
$tags = $_POST["tags"];
|
|
|
|
//$articleManager->addArticle($title, $content, $author, $category, $tags);
|
|
$articles[] = [
|
|
//"id" => count($articles)+1,
|
|
"title" => $title,
|
|
"content" => $content,
|
|
"author" => $author,
|
|
"category" => $category,
|
|
"tags" => $tags,
|
|
//"creationDate" => date("Y-m-d H:i:s")
|
|
];
|
|
$articleManager->saveArticle($articles);
|
|
|
|
foreach ($articleManager->getAllArticles() as $article) {
|
|
echo htmlspecialchars($article['title'])."<br>";
|
|
}
|
|
// Weiterleitung zur Homepage
|
|
//header("location: ../../index.php");
|
|
exit();
|
|
|
|
}
|
|
}
|
|
|
|
?>
|