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);
     }
 }
Beispiel #2
0
 protected function _prepareFbPost($post_datas)
 {
     $post = new Core_Model_Default();
     $icon_url = "https://graph.facebook.com/{$post_datas['from']['id']}/picture";
     $count_comments = isset($post_datas['comments']['data']) ? count($post_datas['comments']['data']) : 0;
     if ($count_comments == 25) {
         $count_comments = ' > ' . $count_comments;
     }
     $count_likes = isset($post_datas['likes']['data']) ? count($post_datas['likes']['data']) : 0;
     if ($count_likes == 25) {
         $count_likes = ' > ' . $count_likes;
     }
     $comments = array();
     if (!empty($post_datas['comments']['data']) && is_array($post_datas['comments']['data'])) {
         foreach ($post_datas['comments']['data'] as $comment) {
             $created_at = new Zend_Date($comment['created_time'], Zend_Date::ISO_8601, new Zend_Locale('en_US'));
             $comments[] = new Core_Model_Default(array('id' => $comment['id'], 'name' => $comment['from']['name'], 'message' => $comment['message'], 'picture' => "https://graph.facebook.com/{$comment['from']['id']}/picture", 'created_at' => $created_at->toString($this->_("MM/dd/y hh:mm a"))));
         }
     }
     $created_at = new Zend_Date($post_datas['created_time'], Zend_Date::ISO_8601, new Zend_Locale('en_US'));
     $message = '';
     if (!empty($post_datas['message'])) {
         $message = $post_datas['message'];
     } else {
         if (!empty($post_datas['story'])) {
             $message = $post_datas['story'];
         }
     }
     $picture = !empty($post_datas['picture']) ? $post_datas['picture'] : '';
     $picture = !empty($post_datas['object_id']) ? "https://graph.facebook.com/{$post_datas['object_id']}/picture?width=200" : $picture;
     $datas = array('id' => $post_datas['id'], 'author' => $post_datas['from']['name'], "avatar_url" => $icon_url, 'message' => $message, 'short_message' => strlen($message) > 300 ? Core_Model_Lib_String::truncate($message, 300) : $message, 'picture' => $picture, 'details' => !empty($post_datas['name']) ? $post_datas['name'] : '', "link" => isset($post_datas['link']) ? $post_datas['link'] : '', "created_at" => $created_at->toString($this->_("MM/dd/y hh:mm a")), "comments" => $comments, "nbr_of_comments" => $count_comments, "nbr_of_likes" => $count_likes);
     $post->setData($datas);
     return $post;
 }