first test
This commit is contained in:
@@ -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();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user