profileArticle-controller.php Implementierung

This commit is contained in:
NOrtmann1
2026-05-29 17:00:32 +02:00
parent 88c369de32
commit ff23e6c9a2
4 changed files with 19 additions and 23 deletions
+8 -21
View File
@@ -7,28 +7,15 @@ session_start();
require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php';
if (isset($_GET["id"])){
try {
$articleManager = ArticleManager::getInstance();
$article = $articleManager->getArticle($_GET["id"]);
if($article != null){
$title = $article->getTitle();
$content = $article->getContent();
$category = $article->getCategory();
$author = $article->getAuthor();
$tags = $article->getTags();
$creationDate = $article->getCreationDate();
}else{
$_SESSION["message"] = "article_not_found";
echo "article_not_found";
}
} catch (Exception $e){
$_SESSION["message"] = "internal_error";
echo "Fehler aufgetreten: " . $e->getMessage();
try {
$author = "max.mustermann"; // TODO: später Nutzer aus der Session beziehen.
$articleManager = ArticleManager::getInstance();
$userArticles = $articleManager->getArticlesByAuthor($author);
if(!isset($userArticles)) {
$_SESSION["message"] = "user_has_no_articles";
}
}else{
$_SESSION["message"] = "article_not_found";
echo "article_not_found";
} catch (Exception $e) {
$_SESSION["message"] = "internal_error";
}
?>
@@ -23,6 +23,5 @@ if (isset($_GET["id"])){
}
}else{
$_SESSION["message"] = "article_not_found";
echo "article_not_found";
}
?>