public function formatDate($timestamp = null, $full = true)
 {
     if (is_null($timestamp)) {
         $timestamp = time();
     }
     $date = new Base_Date();
     return $date->getSysDate($timestamp, $full);
 }
Exemple #2
0
 public function getCommentDate($format = "H:i M dS Y")
 {
     $Date = new Base_Date();
     $Date->setSysDateFormat($format);
     return $Date->getSysDate($this->getAddedon());
 }
 /**
  * @Created By : Mahipal Singh Adhikari
  * @Created On : 2-Nov-2010
  * @Description: Sumbit comment by blog owner
  */
 public function addCommentAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $userNs = new Zend_Session_Namespace('members');
     $this->view->userId = $userNs->userId;
     if (is_null($userNs->userId) && !numeric($userNs->userId)) {
         $response = "<span style='color:#ff0000;'>Please login to submit your comment on this blog.</span>";
         $JsonResultArray = array('error' => 1, 'response' => $response);
         echo Zend_Json::encode($JsonResultArray);
         exit;
     }
     if ($this->_getParam('comment') == "" || $this->_getParam('comment') == "Comment...") {
         $response = "<span style='color:#ff0000;'>Please enter your comment.</span>";
         $JsonResultArray = array('error' => 1, 'response' => $response);
         echo Zend_Json::encode($JsonResultArray);
         exit;
     }
     //save comment
     $commentM = new Application_Model_Comment();
     $commentM->setComment($this->_getParam('comment'));
     $commentM->setItemId($this->_getParam('item_id'));
     $commentM->setItemType($this->_getParam('item_type'));
     $commentM->setParentId(0);
     $commentM->setPublish(1);
     $commentM->setUserId($userNs->userId);
     $id = $commentM->save();
     //set and display response
     if ($id > 0) {
         //get total number of comments
         $total_comments = $commentM->numComments('blog', $this->_getParam('item_id'));
         $total_comments = $total_comments . " Comments";
         //get comment information to display in comment listings
         $comment = $commentM->find($id);
         //$this->view->comment = $objComment;
         $date = new Base_Date();
         $objModelUser = new Application_Model_User();
         $objUser = $objModelUser->find($comment->userId);
         $username = $objUser->getUsername();
         $firstname = $objUser->getFirstName();
         $lastname = $objUser->getLastName();
         $image = $objUser->getThumbnail();
         $response = "<div class='my-journal-view-comment-row' id='comment-detail-" . $id . "'>";
         $response .= "<div class='my-journal-view-comment-row-l'>";
         $response .= "<a href='/" . $username . "'><img width='37px' height='43px' border='0' src='" . $image . "' alt='' /></a>";
         $response .= "</div>";
         $response .= "<div class='my-journal-view-comment-row-r'>";
         $response .= "<p><span><a href='/" . $username . "'>" . $firstname . " " . $lastname . "</a></span> " . $comment->comment . "</p>";
         $response .= "<div class='jposted'>Posted " . $date->timeAgo($comment->getAddedon()) . " | ";
         $response .= "<a href='#add_comment_form' title='Add Comment'>Comment</a> | ";
         $like_link = "<a href='javascript://' title='Like Comment' onclick='likeComment(" . $id . ", 1)'>Like</a>";
         $response .= "<label id='like-comment-label-" . $id . "'>" . $like_link . "</label> | ";
         $response .= "<a href='javascript://' title='Remove Comment' onclick='removeComment(" . $id . "," . $this->_getParam('item_id') . ")'>Remove</a>";
         $response .= "</div></div></div>";
         $JsonResultArray = array('error' => 0, 'total_comments' => $total_comments, 'response' => $response);
     } else {
         $response = "<span style='color:#ff0000;'>Error occured, Please try again later.</span>";
         $JsonResultArray = array('error' => 1, 'response' => $response);
     }
     echo Zend_Json::encode($JsonResultArray);
     exit;
 }