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; }