/**
  * Displays and handles the form view.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 22.08.2007<br />
  * Version 0.2, 08.11.2007 (Implemented multi-language support)<br />
  * Version 0.3, 28.12.2007 (Added a captcha)<br />
  * Version 0.4, 13.06.2009 (Removed the captcha handling, introduced the captcha module)<br />
  */
 public function transformContent()
 {
     $form = $this->getForm('AddComment');
     if ($form->isSent() == true) {
         /* @var $m ArticleCommentManager */
         $m = $this->getServiceObject(ArticleCommentManager::class, [$this->getCategoryKey()]);
         if ($form->isValid() == true) {
             $articleComment = new ArticleComment();
             $name = $form->getFormElementByName('Name');
             $articleComment->setName($name->getAttribute('value'));
             $email = $form->getFormElementByName('EMail');
             $articleComment->setEmail($email->getAttribute('value'));
             $comment = $form->getFormElementByName('Comment');
             $articleComment->setComment($comment->getContent());
             $m->saveEntry($articleComment);
         } else {
             $this->buildForm();
         }
     } else {
         $this->buildForm();
     }
 }
 /**
  * Saves a comment.
  *
  * @param ArticleComment $articleComment The entry to save.
  *
  * @author Christian Schäfer
  * @version
  * Version 0.1, 21.08.2007<br />
  * Version 0.2, 28.12.2007<br />
  * Version 0.3, 02.02.2008<br />
  */
 public function saveEntry(ArticleComment $articleComment)
 {
     /* @var $M ArticleCommentMapper */
     $M = $this->getServiceObject(ArticleCommentMapper::class);
     $articleComment->setCategoryKey($this->categoryKey);
     $M->saveArticleComment($articleComment);
     $link = LinkGenerator::generateUrl(Url::fromCurrent()->mergeQuery(['coview' => 'listing'])->setAnchor('comments'));
     $this->getResponse()->forward($link);
 }
 /**
  * Saves a new comment.
  *
  * @param ArticleComment $comment The domain object to save.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 22.08.2007<br />
  */
 public function saveArticleComment(ArticleComment $comment)
 {
     $conn = $this->getConnection();
     if ($comment->getId() == null) {
         $insert = 'INSERT INTO article_comments
                    (Name, EMail, Comment, Date, Time, CategoryKey)
                    VALUES
                    (\'' . $conn->escapeValue($comment->getName()) . '\',\'' . $conn->escapeValue($comment->getEmail()) . '\',\'' . $conn->escapeValue($comment->getComment()) . '\',CURDATE(),CURTIME(),\'' . $comment->getCategoryKey() . '\');';
         $conn->executeTextStatement($insert);
     }
 }