public function postDetail()
{
$post_id = intval($_GET['post_id']);
$post_detail = D('weiba_post')->where('is_del=0 and post_id=' . $post_id)->find();
if (!$post_detail || D('weiba')->where('weiba_id=' . $post_detail['weiba_id'])->getField('is_del')) {
$this->error('帖子不存在或已被删除');
}
if (D('weiba_favorite')->where('uid=' . $this->mid . ' AND post_id=' . $post_id)->find()) {
$post_detail['favorite'] = 1;
}
$is_digg = M('weiba_post_digg')->where('post_id=' . $post_detail['post_id'] . ' and uid=' . $this->mid)->find();
$post_detail['digg'] = $is_digg ? 'digg' : 'undigg';
if ($post_detail['attach']) {
$attachids = unserialize($post_detail['attach']);
$attachinfo = model('Attach')->getAttachByIds($attachids);
foreach ($attachinfo as $ak => $av) {
$_attach = array('attach_id' => $av['attach_id'], 'attach_name' => $av['name'], 'attach_url' => getImageUrl($av['save_path'] . $av['save_name']), 'extension' => $av['extension'], 'size' => $av['size']);
$post_detail['attachInfo'][$ak] = $_attach;
}
}
/* # 解析表情 */
$post_detail['content'] = preg_replace_callback('/\\[.+?\\]/is', '_parse_expression', $post_detail['content']);
/* # 解析emoji’ */
$post_detail['content'] = formatEmoji(false, $post_detail['content']);
$post_detail['title'] = formatEmoji(false, $post_detail['title']);
// $post_detail['content'] = html_entity_decode($post_detail['content'], ENT_QUOTES, 'UTF-8');
$this->assign('post_detail', $post_detail);
//dump($post_detail);
D('weiba_post')->where('post_id=' . $post_id)->setInc('read_count');
$weiba_name = D('weiba')->where('weiba_id=' . $post_detail['weiba_id'])->getField('weiba_name');
$this->assign('weiba_id', $post_detail['weiba_id']);
$this->assign('weiba_name', $weiba_name);
//获得圈主uid
$map['weiba_id'] = $post_detail['weiba_id'];
$map['level'] = array('in', '2,3');
$weiba_admin = getSubByKey(D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll(), 'follower_uid');
$weiba_manage = false;
if (CheckWeibaPermission($weiba_admin, 0, 'weiba_global_top') || CheckWeibaPermission($weiba_admin, 0, 'weiba_top') || CheckWeibaPermission($weiba_admin, 0, 'weiba_recommend') || CheckWeibaPermission($weiba_admin, 0, 'weiba_edit') || CheckWeibaPermission($weiba_admin, 0, 'weiba_del')) {
$weiba_manage = true;
}
$this->assign('weiba_manage', $weiba_manage);
$this->assign('weiba_admin', $weiba_admin);
//该作者的其他帖子
$this->_assignUserInfo($post_detail['post_uid']);
$tofollow = model('Follow')->getFollowStateByFids($this->mid, array($post_detail['post_uid']));
$this->assign('tofollow', $tofollow);
$map1['post_id'] = array('neq', $post_id);
$map1['post_uid'] = $this->mid;
$map1['is_del'] = 0;
$otherPost = D('weiba_post')->where($map1)->order('reply_count desc')->limit(5)->findAll();
$weiba_ids = getSubByKey($otherPost, 'weiba_id');
$nameArr = $this->_getWeibaName($weiba_ids);
foreach ($otherPost as $k => $v) {
$otherPost[$k]['weiba'] = $nameArr[$v['weiba_id']];
}
$this->assign('otherPost', $otherPost);
// //最新10条
// $newPost = D('weiba_post')->where('is_del=0')->order('post_time desc')->limit(10)->findAll();
// $weiba_ids = getSubByKey($newPost, 'weiba_id');
// $nameArr = $this->_getWeibaName($weiba_ids);
// foreach($newPost as $k=>$v){
// $newPost[$k]['weiba'] = $nameArr[$v['weiba_id']];
// }
// $this->assign('newPost',$newPost);
//帖子推荐
$post_recommend_list = $this->_post_list('recommend', 10);
$this->assign('post_recommend_list', $post_recommend_list);
$type = isset($_GET['type']) ? t($_GET['type']) : 'time';
$this->assign('type', $type);
$this->_weibaOrder();
$this->assign('nav', 'weibadetail');
$this->setTitle($post_detail['title'] . ' ' . $weiba_name);
$this->setKeywords($post_detail['title'] . ' ' . $weiba_name);
$this->setDescription($post_detail['title'] . ',' . t(getShort($post_detail['content'], 100)));
$this->assign('page', $_REQUEST['p']);
$this->display();
}