public function addcommentAction() { if ($this->getRequest()->isPost()) { $user = iconv("UTF-8", "Windows-1251", $this->_getParam('name')); $text = iconv("UTF-8", "Windows-1251", $this->_getParam('text')); $id = $this->_getParam('id'); $dt = time() + TIME_DIFFER; $dt = date('Y-m-d H:i:s', $dt); $db = new Application_Model_DbTable_Comments(); $params = array('user' => $user, 'comment' => $text, 'dt' => $dt, 'productId' => $id); $last = $db->addComment($params); $last_comment = $db->getCommentById($last); $last_comment = $last_comment[0]; $this->view->user = $last_comment['user']; $this->view->comment = $last_comment['comment']; $this->view->dt = $last_comment['dt']; $out = $this->view->render('commentsloop.phtml'); echo iconv("Windows-1251", "UTF-8", $out); exit; } }
public function replyAction() { $this->view->form = $form = new Application_Form_Comment(); // id post $id = $this->_request->getParam('id', 0); $post = $this->_request->getParam('post', 0); if ($this->_request->isPost() && $id > 0) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $c = new Application_Model_DbTable_Comments(); $c->addComment($form->getValues()); $this->_redirect('/post/index'); } else { $form->populate($formData); } } else { if ($id > 0) { $form->parent->setValue($id); $form->post->setValue($post); } } }
/** * Specifically for Comments actions. * * @return mixed * @throws Exception */ public function commentAction() { if ($this->getRequest()->isPost()) { $comment = $this->getRequest()->getPost('pcomment'); if ($comment == "Post Comment") { $id = (int) $this->getRequest()->getPost('id'); $user_name = $this->getRequest()->getPost('user_name'); $description = $this->getRequest()->getPost('description'); $comments = new Application_Model_DbTable_Comments(); $comments->addComment($id, $user_name, $description); return $this->_helper->redirector('index'); } else { $id = $this->_getParam('id', 0); if ($id > 0) { $comments = new Application_Model_DbTable_Comments(); $this->view->comment = $comments->getComments($id); } } } }