Example #1
0
 public function update(SplSubject $subject)
 {
     $comment = $subject->getComment();
     if ($comment->parent_id) {
         $mapper = new Model_Mapper_Comment();
         $parent_comment = $mapper->getComment($comment->parent_id);
         $this->send($parent_comment, $subject->getPost());
     }
 }
Example #2
0
 public function setComments($post_id)
 {
     $mapper = new Model_Mapper_Comment();
     $comments = $mapper->getPostComments($post_id);
     $array[0] = 'Select a comment...';
     foreach ($comments as $comment) {
         $array[$comment->id] = substr($comment->name, 0, 25) . ': ' . strip_tags(substr($comment->comment, 0, 25)) . '...';
     }
     $this->parent_id->setMultiOptions($array);
 }
Example #3
0
 public function getPost($id, $is_published = 1)
 {
     $select = $this->_db->select()->from(array('p' => 'posts'))->joinLeft(array('u' => 'users'), 'u.id = p.user_id', array('user_id' => 'id', 'user_name' => 'name', 'email'))->joinLeft(array('c' => 'categories'), 'c.id = p.category_id', array('category_id' => 'id', 'category_name' => 'name'))->where('p.id = ?', $id);
     $select = $this->_filter($select);
     $data = $this->_db->fetchRow($select);
     $post = new Model_Post($data);
     $post->category = new Model_Category();
     $post->category->id = $data['category_id'];
     $post->category->name = $data['category_name'];
     $post->user = new Model_User();
     $post->user->id = $data['user_id'];
     $post->user->name = $data['user_name'];
     $mapper_comments = new Model_Mapper_Comment();
     $comments = $mapper_comments->getPostComments($post->id);
     $post->comments = $comments;
     return $post;
 }
Example #4
0
 public function delete($id)
 {
     parent::delete($id);
     $this->_cache->clean('all', array('post'));
 }