diff --git a/php/controller/createArticle-controller.php b/php/controller/createArticle-controller.php index 8224c09..d1c00e6 100644 --- a/php/controller/createArticle-controller.php +++ b/php/controller/createArticle-controller.php @@ -11,7 +11,7 @@ try { try { $author = "max.mustermann@web.de"; // wird später aus session bezogen. - $articleManager->newArticle($_POST['post-title'], $_POST['post-content'], $author); + $articleManager->newArticle(new Article()['post-title'], $_POST['post-content'], $author); } catch (Exception $e) { echo "Fehler beim Erstellen des Beitrags: " . $e->getMessage(); } diff --git a/php/model/Article.php b/php/model/Article.php index e96ea98..8f1e4a0 100644 --- a/php/model/Article.php +++ b/php/model/Article.php @@ -13,7 +13,23 @@ class Article private $author; private $date; - /* + /** + * @param $id integer ID des Beitrages + * @param $title + * @param $content + * @param $author + * @param $date + */ + public function __construct($id, $title, $content, $author, $date) + { + $this->id = $id; + $this->title = $title; + $this->content = $content; + $this->author = $author; + $this->date = $date; + } + + /** * Gibt die ID eines Artikels zurück. */ public function getId() @@ -21,7 +37,7 @@ class Article return $this->id; } - /* + /** * Gibt den Titel eines Artikels zurück. */ public function getTitle() @@ -29,7 +45,7 @@ class Article return $this->title; } - /* + /** * Setzt den Titel eines Artikels. */ public function setTitle($title) @@ -37,7 +53,7 @@ class Article $this->title = $title; } - /* + /** * Gibt den Content eines Artikels zurück. * TODO: Content muss noch definiert werden. */ @@ -46,7 +62,7 @@ class Article return $this->content; } - /* + /** * Setzt den Content eines Artikels. * TODO: Content muss noch definiert werden. */ @@ -55,7 +71,7 @@ class Article $this->content = $content; } - /* + /** * Gibt den Autor eines Artikels zurück. */ public function getAuthor() @@ -63,7 +79,7 @@ class Article return $this->author; } - /* + /** * Gibt das Veröffentlichungsdatum des Artikels zurück. */ public function getDate() diff --git a/php/model/ArticleManager.php b/php/model/ArticleManager.php index 4b9d93f..24a2e92 100644 --- a/php/model/ArticleManager.php +++ b/php/model/ArticleManager.php @@ -7,7 +7,8 @@ require_once 'ArticleManagerDAO.php'; * @author Niklas Ortmann */ class ArticleManager implements ArticleManagerDAO { - /* + + /** * Gibt die Datenbank-Instanz zurück. */ public static function getInstance() @@ -29,13 +30,13 @@ class ArticleManager implements ArticleManagerDAO { } - public function newArticle($title, $content, $author, $category) { + public function newArticle($article) { $newData = array( - "title" => $title, - "content" => $content, - "author" => $author, - "category" => $category, - //"tags" => isset($_POST["tags"]) ? $_POST["tags"] : '', TODO: Später hinzufügen + "title" => $article->getTitle(), + "content" => $article->getContent(), + "author" => $article->getAuthor(), + "category" => $article->getCategory(), + //"tags" => $article->getTags(), TODO: Später hinzufügen "date" => date("d.m.Y, H:i") ); $newData = base64_encode(serialize($newData)); diff --git a/php/model/ArticleManagerDAO.php b/php/model/ArticleManagerDAO.php index 29d2d77..b410188 100644 --- a/php/model/ArticleManagerDAO.php +++ b/php/model/ArticleManagerDAO.php @@ -1,5 +1,5 @@