本文整理汇总了PHP中Core_Model_Default::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Core_Model_Default::setData方法的具体用法?PHP Core_Model_Default::setData怎么用?PHP Core_Model_Default::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core_Model_Default
的用法示例。
在下文中一共展示了Core_Model_Default::setData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareFbPost
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;
}