Boys.php 1.62 KB
<?php

use Action\AbstractAction;
use Plugin\Helpers;

/**
 * 男生首页
 */
class BoysController extends AbstractAction
{

    /**
     * 男生首页
     */
    public function indexAction()
    {
        if (null !== $this->get('go')) {
            // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页
            Index\HomeModel::goSwitchChannel();
        } else {
            // 设置浏览器缓存5分钟
            $this->setExpires(300); // 缓存5分钟
        }

        // 设置COOKIE标识用户访问过该页面了
        Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS);

        // 设置网站标题
        $this->setTitle('男生首页');
        // 显示侧边栏
        $this->setNavSide('boys');
        // 显示底部TAB
        $this->setNavFooterTab();

        // 渲染模板并输出
        $this->_view->display('index', array(
            'boysHomePage' => true,
            'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')),
            'maybeLike' => true,
            'content' => Index\HomeModel::getBoysFloor(),
            'pageFooter' => true,
        ));
    }

    /**
     * 异步获取男首底部banner数据
     * @return string 底部Banner数据
     */
    public function bottomBannerAction()
    {
        do {
            if (!$this->isAjax()) {
                break;
            }

            $bottomBanner = Index\HomeModel::getBottomBanner(1);
            if (empty($bottomBanner)) {
                break;
            }

            $this->echoJson($bottomBanner);
        } while (false);

        echo ' ';
    }

}