/** * 分享列表详细数据 * @param array $list 分享列表 * @param bool $is_parent 是否获取转发信息 * @param bool $is_collect 是否获取喜欢的会员 * @param bool $is_parent 是否获取分享标签 * @return array */ public function getShareDetailList($list, $is_parent = false, $is_collect = false, $is_tag = false, $is_comment = false, $comment_count = 10, $collect_count = 20, $is_user = false) { global $_FANWE; $shares = array(); $share_ids = array(); $rec_shares_ids = array(); $share_users = array(); $share_collects = array(); $share_comments = array(); $share_follows = array(); foreach ($list as $item) { $share_id = $item['share_id']; $share_ids[] = $share_id; $item['cache_data'] = fStripslashes(unserialize($item['cache_data'])); $item['authoritys'] = ShareService::getIsEditShare($item); $item['time'] = getBeforeTimelag($item['create_time']); $item['url'] = FU('note/index', array('sid' => $share_id)); ShareService::shareImageFormat($item); $shares[$share_id] = $item; unset($shares[$share_id]['cache_data']); //分享会员 if ($is_user) { $shares[$share_id]['user'] =& $share_users[$item['uid']]; if ($item['rec_uid'] > 0) { $shares[$share_id]['rec_user'] =& $share_users[$item['rec_uid']]; } } //分享评论 if ($is_comment) { $shares[$share_id]['comments'] = array(); if (!empty($item['cache_data']['comments'])) { $comment_ids = array_slice($item['cache_data']['comments'], 0, $comment_count); foreach ($comment_ids as $comment_id) { $shares[$share_id]['comments'][$comment_id] =& $share_comments[$comment_id]; } } } //喜欢分享的会员 if ($is_collect) { $shares[$share_id]['collects'] = array(); if (!empty($item['cache_data']['collects'])) { $collect_ids = array_slice($item['cache_data']['collects'], 0, $collect_count); foreach ($collect_ids as $collect_uid) { if ($is_user) { $shares[$share_id]['collects'][$collect_uid] =& $share_users[$collect_uid]; } else { $shares[$share_id]['collects'][$collect_uid] = $collect_uid; } } } } if ($is_tag) { $shares[$share_id]['is_eidt_tag'] = ShareService::getIsEditTag($item); $shares[$share_id]['tags'] = $item['cache_data']['tags']; ShareService::tagsFormat($shares[$share_id]['tags']['user']); } $shares[$share_id]['is_relay'] = false; $shares[$share_id]['is_parent'] = false; if ($is_parent) { if ($item['base_id'] > 0) { $shares[$share_id]['is_relay'] = true; $rec_shares_ids[$item['base_id']] = false; $shares[$share_id]['relay_share'] =& $rec_shares_ids[$item['base_id']]; if ($item['parent_id'] > 0 && $item['parent_id'] != $item['base_id']) { $shares[$share_id]['is_parent'] = true; $rec_shares_ids[$item['parent_id']] = false; $shares[$share_id]['parent_share'] =& $rec_shares_ids[$item['parent_id']]; } } } } $rec_ids = array_keys($rec_shares_ids); if (count($rec_ids) > 0) { $intersects = array_intersect($share_ids, $rec_ids); $temp_ids = array(); foreach ($intersects as $share_id) { $rec_shares_ids[$share_id] = $shares[$share_id]; $temp_ids[] = $share_id; } $diffs = array_diff($rec_ids, $temp_ids); if (count($diffs) > 0) { $res = FDB::query('SELECT * FROM ' . FDB::table('share') . ' WHERE share_id IN (' . implode(',', $diffs) . ')'); while ($item = FDB::fetch($res)) { $share_id = $item['share_id']; $share_ids[] = $share_id; $item['cache_data'] = fStripslashes(unserialize($item['cache_data'])); $item['authoritys'] = ShareService::getIsEditShare($item); $item['time'] = getBeforeTimelag($item['create_time']); $item['url'] = FU('note/index', array('sid' => $share_id)); ShareService::shareImageFormat($item); $rec_shares_ids[$share_id] = $item; unset($rec_shares_ids[$share_id]['cache_data']); //分享会员 if ($is_user) { $rec_shares_ids[$share_id]['user'] =& $share_users[$item['uid']]; if ($item['rec_uid'] > 0) { $rec_shares_ids[$share_id]['rec_user'] =& $share_users[$item['rec_uid']]; } } //分享评论 if ($is_comment) { $rec_shares_ids[$share_id]['comments'] = array(); if (!empty($item['cache_data']['comments'])) { $comment_ids = array_slice($item['cache_data']['comments'], 0, $comment_count); foreach ($comment_ids as $comment_id) { $rec_shares_ids[$share_id]['comments'][$comment_id] =& $share_comments[$comment_id]; } } } //喜欢分享的会员 if ($is_collect) { $rec_shares_ids[$share_id]['collects'] = array(); if (!empty($item['cache_data']['collects'])) { $collect_ids = array_slice($item['cache_data']['collects'], 0, $collect_count); foreach ($collect_ids as $collect_uid) { if ($is_user) { $rec_shares_ids[$share_id]['collects'][$collect_uid] =& $share_users[$collect_uid]; } else { $rec_shares_ids[$share_id]['collects'][$collect_uid] = $collect_uid; } } } } if ($is_tag) { $rec_shares_ids[$share_id]['is_eidt_tag'] = ShareService::getIsEditTag($item); $rec_shares_ids[$share_id]['tags'] = $item['cache_data']['tags']; ShareService::tagsFormat($rec_shares_ids[$share_id]['tags']['user']); } } } } $comment_ids = array_keys($share_comments); if (count($comment_ids) > 0) { $res = FDB::query("SELECT * FROM " . FDB::table('share_comment') . ' WHERE comment_id IN (' . implode(',', $comment_ids) . ')'); while ($item = FDB::fetch($res)) { $item['time'] = getBeforeTimelag($item['create_time']); $share_comments[$item['comment_id']] = $item; if ($is_user) { $share_comments[$item['comment_id']]['user'] =& $share_users[$item['uid']]; } } } if ($is_user) { FS('User')->usersFormat($share_users); } return $shares; }