IndexAction::detail PHP Method

detail() public method

微吧详情页
public detail ( )
    public function detail()
    {
        $weiba_id = intval($_GET['weiba_id']);
        $weiba_detail = D('weiba')->where('is_del=0 and status=1 and weiba_id=' . $weiba_id)->find();
        if (!$weiba_detail) {
            $this->error('该微吧还未被审核或已被解散');
        }
        $weiba_detail['logo'] = getImageUrlByAttachId($weiba_detail['logo'], 200, 200);
        //圈主
        $map['weiba_id'] = $weiba_id;
        $map['level'] = array('in', '2,3');
        $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid,level')->findAll();
        if ($weiba_admin) {
            foreach ($weiba_admin as $k => $v) {
                // 获取用户用户组信息
                $userGids = model('UserGroupLink')->getUserGroup($v['follower_uid']);
                $userGroupData = model('UserGroup')->getUserGroupByGids($userGids[$v['follower_uid']]);
                foreach ($userGroupData as $key => $value) {
                    if ($value['user_group_icon'] == -1) {
                        unset($userGroupData[$key]);
                        continue;
                    }
                    $userGroupData[$key]['user_group_icon_url'] = THEME_PUBLIC_URL . '/image/usergroup/' . $value['user_group_icon'];
                }
                $weiba_admin[$k]['userGroupData'] = $userGroupData;
                $weiba_admin[$k]['userinfo'] = model('User')->getUserInfo($v['follower_uid']);
            }
            $weiba_admin_uids = getSubByKey($weiba_admin, 'follower_uid');
            $this->_assignFollowUidState($weiba_admin_uids);
            $this->assign('weiba_admin', $weiba_admin);
            $this->assign('weiba_admin_uids', $weiba_admin_uids);
            $this->assign('weiba_super_admin', D('weiba_follow')->where('level=3 and weiba_id=' . $weiba_id)->getField('follower_uid'));
            $this->assign('weiba_admin_count', D('weiba_follow')->where($map)->count());
        }
        $isadmin = 0;
        if (in_array($this->mid, $weiba_admin_uids) || CheckPermission('core_admin', 'admin_login')) {
            $isadmin = 1;
            $this->assign('mid', $this->mid);
        }
        $this->assign('isadmin', $isadmin);
        //帖子
        $maps['is_del'] = 0;
        if ($_GET['type'] == 'digest') {
            $maps['digest'] = 1;
            $order = 'post_time desc';
            $this->assign('type', 'digest');
            $this->assign('post_count', D('weiba_post')->where('is_del=0 AND digest=1 AND weiba_id=' . $weiba_id)->count());
        } else {
            // $maps['top'] = 0;
            $this->assign('type', 'all');
            $this->assign('post_count', D('weiba_post')->where('is_del=0 AND weiba_id=' . $weiba_id)->count());
        }
        $order = 'top desc';
        if ($_GET['order'] == 'post_time') {
            $order .= ',post_time desc';
            $this->assign('order', 'post_time');
        } else {
            $order .= ',last_reply_time desc';
            $this->assign('order', 'reply_time');
        }
        $maps['weiba_id'] = $weiba_id;
        $list = D('weiba_post')->where($maps)->order($order)->findpage(20);
        $post_uids = getSubByKey($list['data'], 'post_uid');
        $reply_uids = getSubByKey($list['data'], 'last_reply_uid');
        !$weiba_admin_uids && ($weiba_admin_uids = array());
        $uids = array_unique(array_filter(array_merge($post_uids, $reply_uids, $weiba_admin_uids)));
        $this->_assignUserInfo($uids);
        $this->_assignFollowState($weiba_id);
        foreach ($list['data'] as $k => $v) {
            //匹配图片的src
            preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match);
            foreach ($match[1] as $imgurl) {
                $imgurl = $imgurl;
                if (!empty($imgurl)) {
                    $list['data'][$k]['img'][] = $imgurl;
                }
            }
            $userinfo = model('User')->getUserInfo($v['post_uid']);
            //dump($userinfo);avatar_small,avatar_tiny
            $list['data'][$k]['image'] = $userinfo['avatar_middle'];
            /* 解析emoji */
            $list['data'][$k]['title'] = formatEmoji(false, $v['title']);
            $list['data'][$k]['content'] = formatEmoji(false, $v['content']);
        }
        $this->assign('list', $list);
        //dump($weiba_detail['cid']);
        if ($weiba_detail['cid'] > 0) {
            $cid = M('weiba_category')->where('id=' . $weiba_detail['cid'])->find();
            $weiba_detail['cid'] = $cid['name'];
            //dump($weiba_detail['cid']);
            //exit;
        } else {
            $weiba_detail['cid'] = '';
        }
        unset($map);
        if ((int) $weiba_detail['province'] > 0 && $weiba_detail['province']) {
            $map['area_id'] = (int) $weiba_detail['province'];
            $result = M('area')->where($map)->find();
            //dump(M()->getLastSql());
            //dump('=====');dump($result);exit;
            $weiba_detail['province'] = $result['title'];
        } else {
            $weiba_detail['province'] = null;
        }
        if ($weiba_detail['city'] > 0 && $weiba_detail['city']) {
            $map['area_id'] = (int) $weiba_detail['city'];
            $result = M('area')->where($map)->find();
            $weiba_detail['city'] = $result['title'];
        } else {
            $weiba_detail['city'] = null;
        }
        if ($weiba_detail['area'] > 0 && $weiba_detail['area']) {
            $map['area_id'] = (int) $weiba_detail['area'];
            $result = M('area')->where($map)->find();
            $weiba_detail['area'] = $result['title'];
        } else {
            $weiba_detail['area'] = null;
        }
        //微吧帖子数
        $weiba_detail['tiezi_count'] = D('weiba_reply')->where('weiba_id=' . $weiba_id . ' AND is_del=0')->count() + D('weiba_post')->where('weiba_id=' . $weiba_id . ' AND is_del=0')->count();
        $this->assign('weiba_detail', $weiba_detail);
        if ($_GET['type'] == 'digest') {
            $jinghua = '精华帖';
        }
        $this->assign('nav', 'weibadetail');
        $this->assign('weiba_name', $weiba_detail['weiba_name']);
        $this->assign('weiba_id', $weiba_id);
        //微吧达人
        $daren_arr = $this->_weiba_daren($weiba_id);
        $daren_arr_uid = getSubByKey($daren_arr, 'uid');
        $daren_arr_follow = model('Follow')->getFollowStateByFids($this->mid, $daren_arr_uid);
        $this->assign('daren_arr', $daren_arr);
        $this->assign('daren_arr_follow', $daren_arr_follow);
        $daren_arrs = $this->_weiba_darens($weiba_id);
        $daren_arrs_uid = getSubByKey($daren_arrs, 'uid');
        $daren_arrs_follow = model('Follow')->getFollowStateByFids($this->mid, $daren_arrs_uid);
        $this->assign('daren_arrs', $daren_arrs);
        $this->assign('daren_arrs_follow', $daren_arrs_follow);
        //dump($daren_arrs);exit;
        //帖子推荐
        $post_recommend_list = $this->_post_list('recommend', 10);
        $this->assign('post_recommend_list', $post_recommend_list);
        $this->setTitle($weiba_detail['weiba_name'] . $jinghua);
        $this->setKeywords($weiba_detail['weiba_name'] . $jinghua);
        $this->setDescription($weiba_detail['weiba_name'] . ',' . $weiba_detail['intro']);
        $this->display();
    }