profileArticle-controller.php Implementierung
This commit is contained in:
+5
-1
@@ -43,7 +43,11 @@ include_once 'php/controller/profileArticles-controller.php';
|
||||
<div class="container">
|
||||
<h2 class="section-title">Meine Beiträge</h2>
|
||||
<div class="articles-list">
|
||||
|
||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||
<p class="alert-message is-error">
|
||||
Es ist ein Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
||||
</p>
|
||||
<?php elseif(isset($articles) && count($articles) > 0): ?>
|
||||
<!-- Beispiel-Eintrag 1 (Wird später per PHP wiederholt) -->
|
||||
<div class="article-item">
|
||||
<div class="article-meta">
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
?>
|
||||
@@ -62,6 +62,12 @@ interface ArticleManagerDAO
|
||||
*/
|
||||
public function getAllArticles();
|
||||
|
||||
/**
|
||||
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
||||
* @param $author
|
||||
* @return Article[]
|
||||
*/
|
||||
public function getArticlesByAuthor($author);
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user