Exemplo n.º 1
0
 public function getAllCommentsAction()
 {
     if ($this->_getParam('xaction') == "destroy") {
         $id = $this->_getParam("comments");
         $id = str_replace('"', '', $id);
         RatingsComments_Plugin::deleteComment($id);
         $results["success"] = true;
         $results["comments"] = "";
     } else {
         $comments = RatingsComments_Plugin::getAllComments($this->_getParam("limit"), $this->_getParam("start"));
         if (is_array($comments)) {
             foreach ($comments as $comment) {
                 $shorttext = $comment->getComment();
                 if (strlen($shorttext) > 50) {
                     $shorttext = substr($shorttext, 0, 50) . "...";
                 }
                 $results["comments"][] = array("c_id" => $comment->getId(), "c_o_id" => $comment->getTargetId(), "c_shorttext" => $shorttext, "c_text" => $comment->getComment(), "c_rating" => $comment->getRating(), "c_user" => $comment->getName(), "c_created" => $comment->getDate());
             }
         }
         if (!isset($results["comments"])) {
             $results["comments"] = "";
         }
     }
     echo Zend_Json::encode($results);
     $this->removeViewRenderer();
 }
Exemplo n.º 2
0
 public function getComments($limit = null)
 {
     if (class_exists('RatingsComments_Plugin') and RatingsComments_Plugin::isInstalled()) {
         if (!$this->isVariant()) {
             $object = $this;
         } elseif ($this->getType() == Object_Abstract::OBJECT_TYPE_OBJECT) {
             $object = $this->getParent();
         } elseif ($this->getType() == Object_Abstract::OBJECT_TYPE_VARIANT && $this->getParent()->getType() == Object_Abstract::OBJECT_TYPE_OBJECT) {
             $object = $this->getParent()->getParent();
         }
         $comments = RatingsComments_Plugin::getComments($object, $limit, false);
         return $comments;
     } else {
         return null;
     }
 }