Index.php 3.77 KB
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use LibModels\Web\Guang\ListData;
use Guang\IndexModel;
use WebPlugin\Paging;
use Index\HomeModel;
class IndexController extends WebAction
{
    /**
     * 逛的首页
     */
    public function indexAction()
    {
        $this->setWebNavHeader();
        $paging = new Paging('yoho');
        $type = intval($this->get('type', 0));
        $channel = Helpers::getChannelNameByCookie();
        $gender = Helpers::getGenderByCookie();
        $page = intval($this->get('page', 1));
        $uid = $this->getUid();
        $udid = $this->getUdid();
        $limit = 20;
        $article = IndexModel::article($gender, $type, $uid, $udid, $page, '', '', $limit);
        $this->setTitle('逛', true);
        $total = $article['total'];
        $tags = IndexModel::getHotTags(1, 20);
        $ads = IndexModel::getAds($channel);
        $paging->setTotal($total)->setSize($limit)->setQuery(array('type' => $type));
        $data['guangIndexPage'] = true;
        //导航
        $data['pathNav'] = array_merge(array(HomeModel::getHomeChannelNav()), IndexModel::getPathNav());
        $data['guang'] = array(
            'slider' => IndexModel::getBanner($channel),
            'msgTypes' => IndexModel::getCategory($type),
            'msgs' => $article['msgs'],
            'ads'=> $ads,
            'msgPager'=> $paging->view(false),
            'exRecos' => IndexModel::getExcellectRecos($gender, 1, 10),
            'hotTags' => $tags
        );
        $this->_view->display('index', $data);
    }
    
    /**
     * 作者信息
     */
    public function editorAction()
    {
        $this->setWebNavHeader();
        //author_id = 7613683
        $author_id = $this->get('author_id');
        $channel = Helpers::getChannelNameByCookie();
        // APP访问时通过频道参数判断性别
        $gender = Helpers::getGenderByCookie();

        $uid = $this->getUid();
        $udid = $this->getUdid();
        
        // 获取作者信息
        $author = ListData::author($author_id);
        // 作者信息不存在,则跳到错误页面
        if (!isset($author['data']['name'])) {
            $this->error();
        }

        // 设置标签页标题
        $authorName = $author['data']['name'];
        $this->setTitle($authorName, true, '');

        $data = array();
        // 模板中使用JS的标识
        $data['guangList'] = true;

        $page = intval($this->get('page', 1));
        $limit = 20;
        // 标签聚合内容列表
        $article = IndexModel::article($gender, null, $uid, $udid, $page, '', $author_id, $limit);
        $data['guang']['gender'] = $gender;

        $paging = new Paging('yoho');
        $total = $article['total'];
        $tags = IndexModel::getHotTags(1, 20);
        $ads = IndexModel::getAds($channel);
        $paging->setTotal($total)->setSize($limit)->setQuery(null);

        $data = array(
            'guangListPage' => true,
            'guang' => array(
                'editor' => array(
                    'avatar' => Helpers::getImageUrl($author['data']['avatar'], 100, 100),
                    'name' => $author['data']['name'],
                    'intro' => $author['data']['author_desc'],
                    'info' => '设计理念:时尚,线条流畅'
                ),
                'msgs' => $article['msgs'],
                'exRecos' => IndexModel::getExcellectRecos($gender, 1, 10),
                'hotTags' => $tags,
                'ads' => $ads,
                'msgPager' => $paging->view(false)
            ),
            'pathNav' => array_merge(array(HomeModel::getHomeChannelNav()), IndexModel::getPathNav())
        );
        $this->_view->display('editor', $data);
    }
}