first test

This commit is contained in:
NOrtmann1
2026-05-27 16:52:06 +02:00
parent 7d9bef932f
commit 0686e98384
7 changed files with 145 additions and 110 deletions
+22 -8
View File
@@ -1,18 +1,32 @@
<?php
if (!isset($abs_path)) {
require_once "../../path.php";
}
require_once $abs_path . '/php/model/ArticleManager.php';
require_once $abs_path . '/php/model/Article.php';
require_once $abs_path . '/php/model/LocalArticleManager.php';
try {
$articleManager = new ArticleManager();
$articleManager = ArticleManager::getInstance();
}catch (Exception $e){
die("Fehler bei der Initialisierung des Artikel-Managers: " . $e->getMessage());
}
try {
$author = "max.mustermann@web.de"; // wird später aus session bezogen.
$articleManager->addArticle($_Post['title'], $_POST['post-content'], $author);
} catch (Exception $e) {
echo "Fehler beim Erstellen des Beitrags: " . $e->getMessage();
if ($_SERVER["REQUEST_METHOD"] === "POST") {
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
$_SESSION["message"] = "missing_parameters";
header("location:" . $abs_path . "/index.php?pfad=createArticle");
}
$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, $category, $author, $tags);
// Weiterleitung zur Homepage
header("location:". $abs_path . "/index.php");
exit();
}
?>