IndexAction::index PHP Method

index() public method

频道首页页面
public index ( )
    public function index()
    {
        // 添加样式
        $this->appCssList[] = 'channel.css';
        // 获取频道分类列表
        $channelCategory = model('CategoryTree')->setTable('channel_category')->getCategoryList();
        $this->assign('channelCategory', $channelCategory);
        // 频道分类选中
        $cid = intval($_GET['cid']);
        $categoryIds = getSubByKey($channelCategory, 'channel_category_id');
        if (!in_array($cid, $categoryIds) && !empty($cid)) {
            $this->error('您请求的频道分类不存在');
            return false;
        }
        $channelConf = model('Xdata')->get('channel_Admin:index');
        if (empty($cid)) {
            $cid = $channelConf['default_category'];
            if (empty($cid)) {
                $cid = array_shift($categoryIds);
            }
        }
        $this->assign('cid', $cid);
        // 获取用户与频道分类的关注状态
        $followStatus = model('ChannelFollow')->getFollowStatus($this->mid, $cid);
        $this->assign('followStatus', $followStatus);
        // 获取模板样式
        $templete = t($_GET['tpl']);
        if (empty($templete) || !in_array($templete, array('load', 'list'))) {
            $categoryConf = model('CategoryTree')->setTable('channel_category')->getCatgoryConf($cid);
            $templete = empty($categoryConf) ? $channelConf['show_type'] == 1 ? 'list' : 'load' : ($categoryConf['show_type'] == 1 ? 'list' : 'load');
        }
        $templete = 'load';
        $this->assign('tpl', $templete);
        //获取频道信息
        //广播数
        $channel_count = model('Channel')->where('channel_category_id=' . $cid . ' AND status=1')->count();
        $this->assign('channel_count', $channel_count);
        //收听人数
        $channel_follower_count = model('ChannelFollow')->where('channel_category_id=' . $cid)->count();
        $this->assign('channel_follower_count', $channel_follower_count);
        //banner,desc
        $channel_category = D('channelCategory')->where('channel_category_id=' . $cid)->getField('ext');
        $channel_category = unserialize($channel_category);
        $channel_banner = getImageUrlByAttachId($channel_category['attach'], 1000);
        $this->assign('channel_banner', $channel_banner);
        $this->assign('channel_desc', $channel_category['desc']);
        //排序
        $order = $_GET['order'] == null ? 0 : $_GET['order'];
        $this->assign('order', intval($order));
        // 设置页面信息
        $titleHash = model('CategoryTree')->setTable('channel_category')->getCategoryHash();
        $title = empty($cid) ? '频道首页' : $titleHash[$cid];
        $this->setTitle($title);
        $this->setKeywords($title);
        $this->setDescription(implode(',', getSubByKey($channelCategory, 'title')));
        $this->display();
    }