public function detail() { if ($_GET['weibo_id']) { $data['id'] = intval($_GET['weibo_id']); } elseif ($_GET['id']) { $data['id'] = intval($_GET['id']); } $detail = api('WeiboStatuses')->data($data)->show(); $detail['userGroupData'] = $this->_usergroup($detail['uid']); $map['source_id'] = $data['id']; $map['uid'] = $this->mid; $detail['iscoll']['colled'] = model('Collection')->where($map)->count() ? 1 : 0; $detail['favorited'] = $detail['iscoll']['colled']; // $detail['is_favorite'] = api('Favorites')->data($data)->isFavorite() ? 1 : 0; // $detail['content'] = wapFormatContent($detail['content'], false, urlencode($this->_self_url)); // $detail = $this->__formatByContent($detail); // optimize data if (($detail['type'] === 'repost' && $detail['api_source']['is_del'] === '0' || $detail['type'] === 'repost' && $detail['transpond_data']['api_source']['is_del'] === '0') && isset($detail['transpond_data']['feed_content'])) { switch ($detail['transpond_data']['type']) { case 'postimage': $detail['type'] = 'repost-postimage'; break; case 'postfile': $detail['type'] = 'repost-postfile'; foreach ($detail['transpond_data']['attach'] as $k => $v) { if ($v['size'] > 1024 && $v['size'] < 1024 * 1024) { $detail['transpond_data']['attach'][$k]['size'] = round($v['size'] / 1024, 2) . 'K'; } else { if ($v['size'] < 1024) { $detail['transpond_data']['attach'][$k]['size'] .= 'B'; } else { $detail['transpond_data']['attach'][$k]['size'] = round($v['size'] / 1024 / 1024, 2) . 'M'; } } } break; case 'postvideo': $detail['type'] = 'repost-postvideo'; break; } } else { if (($detail['api_source']['is_del'] === '1' || $detail['transpond_data']['api_source']['is_del'] === '1') && $detail['type'] === 'repost') { $detail['type'] = 'repost-removed'; } else { if ($detail['type'] === 'postfile') { foreach ($detail['attach'] as $k => $v) { if ($v['size'] > 1024 && $v['size'] < 1024 * 1024) { $detail['attach'][$k]['size'] = round($v['size'] / 1024, 2) . 'K'; } else { if ($v['size'] < 1024) { $detail['attach'][$k]['size'] .= 'B'; } else { $detail['attach'][$k]['size'] = round($v['size'] / 1024 / 1024, 2) . 'M'; } } } } else { if ($detail['type'] === 'weiba_repost') { if ($detail['api_source']['is_del'] === '1' || $detail['transpond_data']['is_del'] === '1') { $detail['type'] = 'weiba_repost-removed'; } } } } } $detail['from'] = getFromClient($detail['from'], $detail['app']); if ($detail['type'] == 'postvideo') { // $weibolist[$k]['content'] = $v['source_body']; $detail['content'] = $detail['feed_content'] ? $detail['feed_content'] : $detail['source_body']; $detail['content'] = wapFormatContent($detail['content'], true, $self_url, "视频"); } else { $detail['content'] = wapFormatContent($detail['content'], true, $self_url); } // 非视频分享 if ($detail['transpond_data']['content']) { if (strpos($weibolist[$k]['type'], 'video')) { $detail['transpond_data']['content'] = wapFormatContent($detail['transpond_data']['content'], true, $self_url, "视频"); } else { $detail['transpond_data']['content'] = wapFormatContent($detail['transpond_data']['content'], true, $self_url); } } // 转发分享标志 $detail['repost'] = $detail['app_row_id']; // 如果是转发,看是否有评论当前用户的权限 $privacy1 = $this->privacy($detail['uid']); $detail['cancomment_current'] = 0; if ($privacy1 === true || $privacy1['comment_weibo'] == 0) { $detail['cancomment_current'] = 1; } // 判断是否有评论作者或原文作者权限 $origin_uid = $detail['api_source']['uid'] ? $detail['api_source']['uid'] : 0; $detail['cancomment'] = 0; // 如果是转发,判断是否有评论给原作者的权限 if ($origin_uid && $origin_uid != $this->mid) { $privacy = $this->privacy($origin_uid); if ($privacy === true || $privacy['comment_weibo'] == 0) { $detail['cancomment'] = 1; } } $this->assign('feed', $detail); // dump($detail);exit; // dump($detail); $data['page'] = $this->_page; $data['count'] = 20; $comment = api('WeiboStatuses')->data($data)->comments(); foreach ($comment as $key => $value) { $comment[$key]['level'] = M('credit_user')->where('uid=' . $value['uid'])->find(); $comment[$key]['userGroupData'] = $this->_usergroup($value['uid']); } $this->assign('count', $detail['comment_count']); $this->assign('comment', $comment); $this->assign('headtitle', '分享详情'); $this->assign('uid', $this->mid); // dump($detail['api_source']); $this->display(); }
public function detail() { if (intval($_GET['weibo_id'])) { $data['id'] = intval($_GET['weibo_id']); } elseif (intval($_GET['id'])) { $data['id'] = intval($_GET['id']); } $detail = api('WeiboStatuses')->data($data)->show(); $map['source_id'] = $data['id']; $map['uid'] = $this->mid; $detail['iscoll']['colled'] = model('Collection')->where($map)->count() ? 1 : 0; // $detail['is_favorite'] = api('Favorites')->data($data)->isFavorite() ? 1 : 0; $detail['content'] = wapFormatContent($detail['content'], false, urlencode($this->_self_url)); // $detail = $this->__formatByContent($detail); $this->assign('weibo', $detail); // dump($detail); $data['page'] = $this->_page; $data['count'] = 10; $comment = api('WeiboStatuses')->data($data)->comments(); foreach ($comment as $key => $value) { $comment[$key]['level'] = M('credit_user')->where('uid=' . $value['uid'])->find(); } $this->assign('comment', $comment); $this->assign('headtitle', '微博详情'); $this->display(); }
public function detail() { if (intval($_GET['weibo_id'])) { $data['id'] = intval($_GET['weibo_id']); } elseif (intval($_GET['id'])) { $data['id'] = intval($_GET['id']); } $detail = api('WeiboStatuses')->data($data)->show(); // $detail['favorited'] = api('WeiboStatuses')->data($data)->isFavorite() ? 1 : 0; $map['source_id'] = $data['id']; $map['uid'] = $this->mid; $detail['iscoll']['colled'] = model('Collection')->where($map)->count() ? 1 : 0; $detail['content'] = wapFormatContent($detail['content'], true, urlencode($this->_self_url)); $detail['weibo_id'] = $detail['feed_id']; $this->assign('weibo', $detail); // dump($detail); // 微吧帖子处理 switch ($_GET['type']) { case 'weiba': $weiba_post = D('WeibaPost', 'weiba')->where('post_id=' . $detail['app_row_id'])->find(); // $weiba_post['content'] = $this->assign('weiba_post', 1); $this->assign('weiba', $weiba_post); break; default: # code... break; } // dump($weiba_post); $data['page'] = $this->_page; $comment = api('WeiboStatuses')->data($data)->comments(); $comment = $this->__formatByComment($comment); $admin_Config = model('Xdata')->lget('admin_Config'); $weibo_nums = $admin_Config['feed']['weibo_nums']; $this->assign('weibo_nums', $weibo_nums); $this->assign('comment', $comment); $this->display(); }
private function __formatByContent($weibolist) { $self_url = urlencode($this->_self_url); foreach ($weibolist as $k => $v) { if ($v['app'] === 'blog' || $v['app'] === 'weiba' || $v['app'] === 'group') { unset($weibolist[$k]); continue; } // 转发分享标志 $weibolist[$k]['repost'] = $v['api_source']['feed_id'] ? $v['api_source']['feed_id'] : $v['app_row_id']; // 如果是转发,看是否有评论当前用户的权限 $privacy1 = $this->privacy($v['uid']); $weibolist[$k]['cancomment_current'] = 0; if ($privacy1 === true || $privacy1['comment_weibo'] == 0) { $weibolist[$k]['cancomment_current'] = 1; } // 判断是否有评论作者或原文作者权限 $origin_uid = $v['api_source']['uid'] ? $v['api_source']['uid'] : 0; $weibolist[$k]['cancomment'] = 0; // 如果是转发,判断是否有评论给原作者的权限 if ($origin_uid && $origin_uid != $this->mid) { $privacy = $this->privacy($origin_uid); if ($privacy === true || $privacy['comment_weibo'] == 0) { $weibolist[$k]['cancomment'] = 1; } } $weibolist[$k]['userGroupData'] = $this->_usergroup($v['uid']); switch ($v['app']) { case 'blog': unset($weibolist[$k]); continue; /* * if($v['feed_id']){ * $weibolist[$k]['weibo_id'] = $weibolist[$k]['feed_id']; * // $weibolist[$k]['content'] = wapFormatContent($v['content'], true, $self_url); * // 视频处理 * $weibolist[$k]['content'] = wapFormatContent($v['api_source']['content'], true, $self_url); * * //if($v['type'] == 'postvideo'){ * // //$weibolist[$k]['content'] = $v['source_body']; * // $weibolist[$k]['content'] = $v['feed_content'] ? $v['feed_content'] : $v['source_body']; * // $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url, "知识"); * //}else{ * // $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url); * //} * // 非视频分享 * if ($v['transpond_data']['content']) { * if(strpos($weibolist[$k]['type'], 'video')){ * $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url, "视频"); * }else{ * $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url); * } * $weibolist[$k]['transpond_data']['weibo_id'] = $weibolist[$k]['transpond_data']['feed_id']; * }else{ * $row_id = model('Feed')->where('feed_id='.$v['feed_id'])->getField('app_row_id'); * $uid = model('Feed')->where('feed_id='.$row_id)->getField('uid'); * $weibolist[$k]['transpond_data'] = model('User')->getUserInfo($this->uid); * } * $weibolist[$k]['ctime'] = date('Y-m-d H:i', $v['publish_time']); * }else{ * if($weibolist[$k]['row_id']){ * $weibolist[$k]['ctime'] = strtotime($weibolist[$k]['ctime']); * }else{ * unset($weibolist[$k]); * } * * } */ break; case 'public': if ($v['feed_id']) { $weibolist[$k]['weibo_id'] = $weibolist[$k]['feed_id']; // $weibolist[$k]['content'] = wapFormatContent($v['content'], true, $self_url); // 视频处理 if ($v['type'] == 'postvideo') { // $weibolist[$k]['content'] = $v['source_body']; $weibolist[$k]['content'] = $v['feed_content'] ? $v['feed_content'] : $v['source_body']; $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url, "视频"); } else { $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url); } // 非视频分享 if ($v['transpond_data']['content']) { if (strpos($weibolist[$k]['type'], 'video')) { $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url, "视频"); } else { $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url); } $weibolist[$k]['transpond_data']['weibo_id'] = $weibolist[$k]['transpond_data']['feed_id']; } else { $row_id = model('Feed')->where('feed_id=' . $v['feed_id'])->getField('app_row_id'); $uid = model('Feed')->where('feed_id=' . $row_id)->getField('uid'); $weibolist[$k]['transpond_data'] = model('User')->getUserInfo($this->uid); } $weibolist[$k]['ctime'] = date('Y-m-d H:i', $v['publish_time']); } else { if ($weibolist[$k]['row_id']) { $weibolist[$k]['ctime'] = strtotime($weibolist[$k]['ctime']); } else { unset($weibolist[$k]); } } break; case 'weiba': $weiba_post = D('WeibaPost', 'weiba')->where('post_id=' . $v['app_row_id'])->find(); $weibolist[$k]['weibo_id'] = $weibolist[$k]['feed_id']; $weibolist[$k]['transpond_data'] = $weiba_post; $weibolist[$k]['transpond_data']['weibo_id'] = $weibolist[$k]['feed_id']; $weibolist[$k]['transpond_data']['uname'] = model('User')->where('uid=' . $weiba_post['post_uid'])->getField('uname'); $weibolist[$k]['transpond_data']['uid'] = $weiba_post['post_uid']; break; default: // code... break; } // 处理视频链接 /* * if(strpos($weibolist[$k]['type'], 'video')){ * $weibolist[$k]['content'] = preg_replace("/(.*)<a([^>*])>([^<*])</a>(.*)/i", "\\1<a\\2>视频</a>\\4", $weibolist[$k]['content']); * $weibolist[$k]['transpond_data']['content'] = preg_replace("/(.*)<a([^>*])>([^<*])</a>(.*)/i", "\\1<a\\2>视频</a>\\4", $weibolist[$k]['transpond_data']['content']); * } */ $weibolist[$k]['from'] = getFromClient($weibolist[$k]['from'], $v['app']); $map['source_id'] = $v['feed_id']; $map['uid'] = $this->mid; $fav = model('Collection')->where($map)->getField('source_id'); if ($fav) { $weibolist[$k]['favorited'] = 1; } else { $weibolist[$k]['favorited'] = 0; } } return $weibolist; }
public function detail() { $data['id'] = intval($_GET['weibo_id']); $detail = api('Statuses')->data($data)->show(); $detail['favorited'] = api('Favorites')->data($data)->isFavorite() ? 1 : 0; $detail['content'] = wapFormatContent($detail['content'], true, urlencode($this->_self_url)); $this->assign('weibo', $detail); $data['page'] = $this->_page; $comment = api('Statuses')->data($data)->comments(); $comment = $this->__formatByComment($comment); $this->assign('comment', $comment); $this->display(); }