Beispiel #1
0
 public function comments()
 {
     $commentTable = \Ub\Simpleblog\Comments\Table::instance();
     $select = $commentTable->select();
     $select->statusIs(\Ub\Simpleblog\Comments\Model::STATUS_APPROVED);
     $select->post_idIs($this->pk());
     $select->order('time', 'DESC');
     return $commentTable->fetchAll($select);
 }
Beispiel #2
0
 public function actionAddComment($post = null)
 {
     $message = 'Ой. сталась помилка, спробуйте через декілька хвилин.';
     if (empty($post) and !empty($_POST['postpk'])) {
         $postTable = Table::instance();
         $post = $postTable->fetchOne($_POST['postpk']);
     }
     if (empty($post)) {
         $message = 'Ви додаєте коментар до неіснуючого допису. Поверністься назад і спробуйте ще раз';
     }
     if (empty($_POST['comment'])) {
         $message = 'Напишіть коментар';
     }
     if (!empty($_POST['comment']) and !empty($post)) {
         $comment = \Ub\Simpleblog\Comments\Table::instance()->createModel();
         $commentData = array();
         foreach (array('name', 'email', 'url', 'comment') as $field) {
             $commentData[$field] = !empty($_POST['comment'][$field]) ? $_POST['comment'][$field] : false;
         }
         $commentData['post_id'] = $post->pk();
         $comment->setFromArray($commentData);
         $comment->save();
         $message = 'Коментар успішно добавлений. Після модерації він буде опублікований';
     }
     $this->render('addComment', array('message' => $message, 'post' => $post));
 }
Beispiel #3
0
 protected function getConnectedTable()
 {
     return \Ub\Simpleblog\Comments\Table::instance();
 }