public function findallAction()
 {
     if ($value_id = $this->getRequest()->getParam('value_id')) {
         $application = $this->getApplication();
         $comment = new Comment_Model_Comment();
         $comments = $comment->findLastest($value_id);
         $color = $application->getBlock('background')->getColor();
         $data = array("news" => array(), "application" => array());
         foreach ($comments as $comment) {
             $data['news'][] = array("text" => Core_Model_Lib_String::truncate($comment->getText(), 88), "created_at" => $comments->getFormattedCreatedAt(), "number_of_comments" => count($comment->getAnswers()), "number_of_likes" => count($comment->getLikes()));
         }
         $data['application'] = array("icon_url" => $application->getIconUrl(74), "name" => $application->getName());
         $data['picto'] = array("pencil" => $this->_getColorizedImage($this->getImage("picto/pencil.png"), $color), "comment" => $this->_getColorizedImage($this->getImage("picto/comment.png"), $color), "like" => $this->_getColorizedImage($this->getImage("picto/like.png"), $color));
         $this->_sendHtml($data);
     }
 }
Esempio n. 2
0
 public function findAction()
 {
     if ($value_id = $this->getRequest()->getParam('value_id') and $comment_id = $this->getRequest()->getParam('comment_id')) {
         $application = $this->getApplication();
         $comment = new Comment_Model_Comment();
         $comment->find($comment_id);
         $option = $this->getCurrentOptionValue();
         if ($comment->getId() and $comment->getValueId() == $value_id) {
             $customer = $comment->getCustomer();
             $color = $application->getBlock('background')->getColor();
             $cleaned_message = str_replace(array("\n", "\r"), "", html_entity_decode(strip_tags($comment->getText()), ENT_QUOTES, 'UTF-8'));
             switch ($this->getCurrentOptionValue()->getLayoutId()) {
                 case 2:
                     $data = array("id" => $comment->getId(), "author" => $customer->getFirstname() ? $customer->getFirstname() : $application->getName(), "title" => $comment->getTitle(), "subtitle" => $comment->getSubtitle(), "message" => $comment->getText(), "cleaned_message" => mb_strlen($cleaned_message) > 67 ? mb_substr($cleaned_message, 0, 64) . "..." : $cleaned_message, "picture" => $comment->getImageUrl(), "created_at" => $comment->getFormattedDate($this->_("MM.dd.y")), "code" => $this->getCurrentOptionValue()->getCode(), "social_sharing_active" => $option->getSocialSharingIsActive());
                     break;
                 case 1:
                 default:
                     $data = array("id" => $comment->getId(), "author" => $customer->getFirstname() ? $customer->getFirstname() : $application->getName(), "message" => $comment->getText(), "cleaned_message" => mb_strlen($cleaned_message) > 67 ? mb_substr($cleaned_message, 0, 64) . "..." : $cleaned_message, "picture" => $comment->getImageUrl(), "icon" => $application->getIcon(74), "can_comment" => true, "created_at" => $this->_durationSince($comment->getCreatedAt()), "number_of_likes" => count($comment->getLikes()), "flag_icon" => $this->_getColorizedImage($this->_getImage("pictos/flag.png"), $color), "code" => $this->getCurrentOptionValue()->getCode(), "social_sharing_active" => $option->getSocialSharingIsActive());
                     break;
             }
             $this->_sendHtml($data);
         }
     }
 }