public function showAction()
 {
     $comment_mapper = new Application_Model_CommentMapper();
     $comment = $comment_mapper->find($this->_getParam('id'));
     $comment->hide = 0;
     $comment_mapper->save($comment);
     return $this->_response->setRedirect('/admin/entry/list');
 }
 public function indexAction()
 {
     $cache = Zend_Registry::get('cache');
     $id = md5("newcommentControllerIndex");
     if (($result = $cache->load($id)) === false) {
         $comment = new Application_Model_CommentMapper();
         $result = $comment->findBloggerNewComment(BLOGGER_ID);
         $cache->save($result, $id, array('newcommentbox'));
     }
     //print_r($result);
     $this->view->data = $result;
 }
 public function testShowAction()
 {
     $m = new Application_Model_CommentMapper();
     $id = $m->getMaxMessageId();
     $params = array('action' => 'show', 'controller' => 'Comment', 'module' => 'default', 'id' => $id);
     $url = $this->url($this->urlizeOptions($params));
     $this->dispatch($url);
     // assertions
     $this->assertModule($params['module']);
     $this->assertController($params['controller']);
     $this->assertAction($params['action']);
     $this->assertQueryContentContains('div#content h3', 'Single Message');
 }
 public function comdelAction()
 {
     if ($this->getRequest()->isGet()) {
         $id = $this->_request->get('id');
         $comment = new Application_Model_CommentMapper();
         $affected = $comment->delete($id);
     }
     if ($this->getRequest()->isXmlHttpRequest() || $this->_getParam('ajax') == 1) {
         $this->_helper->layout->setLayout('empty_layout');
         $this->_helper->viewRenderer->setNoRender();
         $this->_response->appendBody($affected);
     } else {
         if ($this->_request->get('from')) {
             $url = $this->_request->get('from');
             $url = str_replace('-', '/', $url);
             $this->_helper->viewRenderer->setNoRender();
             $this->_redirect('/' . $url . '#look_comment');
         }
         $this->_redirect('/' . BLOGGER_NAME . '/blogger/comlist');
     }
 }
 public function allcommentAction()
 {
     $request = $this->getRequest();
     $post_id = $request->getParam('id');
     $comment_mapper = new Application_Model_CommentMapper();
     $comments = $comment_mapper->getComments($post_id, false);
     $xml_text = '<?xml version="1.0" encoding="UTF-8"?>';
     $xml_text .= '<comments>';
     foreach ($comments as $comment) {
         $xml_text .= "<comment>";
         $xml_text .= "<text>" . $comment['content'] . "</text>";
         $xml_text .= "<image>" . get_profile_path($comment['user_id']) . "</image>";
         $xml_text .= "<date>" . gmdate("Y/m/d  H:i", $comment['created_at']) . "</date>";
         $xml_text .= "<name>" . $comment['username'] . "</name>";
         $xml_text .= "</comment>";
     }
     $xml_text .= '</comments>';
     header("Content-type: text/xml");
     $xml = new SimpleXMLElement($xml_text);
     echo $xml->asXML();
     exit;
 }
 protected function _getCommentsForm($id)
 {
     // Get the comment form
     $form = new Application_Form_CommentAdd(array('entry' => $id));
     if (!$this->getRequest()->isPost()) {
         $this->view->form = $form;
         return;
     }
     if ($_POST['submit'] == 'Comment') {
         if (!$form->isValid($_POST)) {
             $this->view->errors = $form->getMessages();
             $form->setElementFilters(array());
             // disable all element filters
             $this->_repopulateForm($form, $form->getValues());
             $this->view->form = $form;
             return;
         }
         $values = $form->getValues();
         $data = array('username' => $values['username'], 'email' => $values['email'], 'url' => $values['url'], 'comment' => $values['comment'], 'published_date' => $values['published_date'], 'entry' => $values['entry']);
         $comment = new Application_Model_Comment($data);
         $comment_mapper = new Application_Model_CommentMapper();
         $comment_mapper->save($comment);
         $this->view->blog->addComment($comment);
         // Send email notification
         $mail = new Zend_Mail();
         $mail->setFrom($values['email'], $values['username']);
         $mail->addTo($this->message_details['email'], $this->message_details['name']);
         $mail->setSubject($this->message_details['commentSubject']);
         $mail->setBodyText("{$values['comment']}");
         $mail->setBodyHtml("<p>{$values['comment']}</p>");
         $mail->send();
     }
     // Add the form to the view
     $form->reset();
     $this->view->form = $form;
 }
 public function indexAction()
 {
     $cache = Zend_Registry::get('cache');
     $id = md5("aboutmeControllerIndex");
     if (($result = $cache->load($id)) === false) {
         //$data = $db->fetchAll($select);
         $account = new Application_Model_DbTable_Account();
         $db = $account->getAdapter();
         //获取用户信息
         $select = $db->select();
         $select->from('account', array('nickname', 'photo'));
         $select->where('id = ?', BLOGGER_ID);
         $result = $db->fetchRow($select);
         //获取博主 原创 翻译 转载各自篇数,和评论数
         $select = $db->select();
         $select->from('article', array('count(*) totalori'));
         $select->where('atype_id = 1');
         $select->where('account_id = ?', BLOGGER_ID);
         $arr = $db->fetchRow($select);
         $result['totalori'] = $arr['totalori'];
         $select = $db->select();
         $select->from('article', array('count(*) totaltrans'));
         $select->where('atype_id = 2');
         $select->where('account_id = ?', BLOGGER_ID);
         $arr = $db->fetchRow($select);
         $result['totaltrans'] = $arr['totaltrans'];
         $select = $db->select();
         $select->from('article', array('count(*) totalresp'));
         $select->where('atype_id = 3');
         $select->where('account_id = ?', BLOGGER_ID);
         $arr = $db->fetchRow($select);
         $result['totalresp'] = $arr['totalresp'];
         $comment = new Application_Model_CommentMapper();
         $comment_info = $comment->findBloggerAritcleComment(BLOGGER_ID);
         $totalComment = count($comment_info);
         $result['totalcom'] = $totalComment;
         //获取博客访问量
         //获取博主已访问过的ip
         $select = $db->select();
         $select->from('view_statistic', 'ip');
         $select->where('account_id = ?', BLOGGER_ID);
         $ips = $db->fetchAll($select);
         //获取当前访问ip
         include_once APPLICATION_PATH . '/../library/Cblog/RealIp.php';
         $ipObj = new Cblog_RealIp();
         $ip = $ipObj->getIp();
         foreach ($ips as $arr) {
             if ($ip == $arr['ip']) {
                 $status = "yes";
                 break;
             }
         }
         $select = $db->select();
         $select->from('view_statistic', 'count(id) as totalview');
         $select->where('account_id = ?', BLOGGER_ID);
         $totalViews = $db->fetchOne($select);
         //print_r($status);
         if (!isset($status)) {
             $viewstastic = new Application_Model_DbTable_ViewStatistic();
             $viewstastic->addViewIp(BLOGGER_ID, $ip);
             $result['totalview'] = $totalViews + 1;
         } else {
             $result['totalview'] = $totalViews;
         }
         $cache->save($result, $id, array('aboutmebox'));
     }
     //print_r($result);
     $this->view->data = $result;
 }
Example #8
0
 public function showAction()
 {
     /****************************************************************
      * Show a single message, and maybe eventually replies to that
      * message I guess (Maybe posts to this actual page, in a meta
      * sort of way).
      */
     $this->view->title = "Single Message";
     $cookie = Application_Model_DbTable_Cookie::getUserCookie();
     $cookieMapper = new Application_Model_CookieMapper();
     $mapper = new Application_Model_CommentMapper();
     $messageId = $this->getRequest()->getParam('id');
     if ($messageId == null) {
         throw new Exception("No Message Specified");
     }
     $message = $mapper->find($messageId);
     $viewUserCookie = $message->getCookieObject();
     $nick = $message->getNick();
     $this->view->userDetails = $viewUserCookie;
     $this->view->message = $message;
 }