Example #1
0
 /**
  * HTML for a single comment
  *
  * @param Comment $comment
  * @param boolean $is_child
  * @return string
  **/
 public function _commentBox(Comment $comment, $is_child = false)
 {
     $extra = $comment->getEmail() == '*****@*****.**' ? ' rob' : '';
     $extra .= $is_child ? ' reply' : '';
     if ($comment->getWebsite()) {
         $author = '<a title="' . $comment->getName() . '\'s website" href="' . $comment->getWebsite() . '">' . $comment->getName() . '</a>';
     } else {
         $author = $comment->getName();
     }
     $string = '<div id="comment-' . $comment->getId() . '" class="comment-container' . $extra . '">';
     $string .= '<h2>' . $author . ' - ' . $comment->getDateAdded()->format("F jS, Y @ g:ia") . ' <a class="reply" title="Reply to this comment" href="javascript:replyToComment(\'' . $comment->getId() . '\')">reply</a></h2>';
     $string .= '<div class="comment">';
     $string .= '<div class="photo">' . '<a title="Get a gravatar" href="http://www.gravatar.com">' . $this->view->gravatar($comment->getEmail(), array('img_size' => 50), array('alt' => 'gravatar', 'title' => 'avatar')) . '</a>' . '</div>';
     $string .= stripslashes($comment->getComment());
     if ($this->_role == UserService::ROLE_ADMIN) {
         $string .= '<p>';
         $string .= sprintf('<a title="edit" href="%s">edit</a> | ', $this->view->myUrl('blog/default/query', array('controller' => 'comment', 'action' => 'edit', 'id' => $comment->getId())));
         $string .= sprintf('<a title="delete" href="javascript:deleteComment(%s)">delete</a>', $comment->getId());
         $string .= '</p>';
     }
     $string .= '<div class="clear"></div>';
     $string .= '</div>';
     $string .= '</div>';
     return $string;
 }
Example #2
0
 /**
  * Removes comment
  *
  * @param Comment $comment
  * @return void
  */
 public function delete(Comment $comment)
 {
     $dql = sprintf('UPDATE %s c SET c.parentId = 0 WHERE c.parentId = %s', self::ENTITY_COMMENT, $comment->getId());
     $query = $this->em->createQuery($dql);
     $query->execute();
     $this->em->remove($comment);
     $this->em->flush();
 }