<?php

/**
 * 本类放置专题类
 *
 * @author Administrator
 */
class SubjectAction extends PublicAction {

    //首页
    public function index() {
        $this->sort_list(); //显示列表项
        //显示推荐专题
	$map['status'] = 1;
        $map['recommend'] = 1;
        $map['pid'] = C('HOME_CUSTOMACTION_ID');
        $map['extend'] = 0;

        $menu = M('menu');

        $menu_recomment = F('Subject_recommend/recommend_list');    //读取缓存
        if (1) {   //缓存不存在
            $menu_recomment = $menu->field('id, name, SUBSTR(`explain`, 1, 60) AS `explain`, picture, title')->where($map)->select();
            //echo $menu->getLastSql();
            F('Subject_recommend/recommend_list', $menu_recomment); //增加缓存
        }

	$menu_msg = $menu->field('`name`, `keyword`, `explain`')->where("id='" . C('HOME_CUSTOMACTION_ID') . "'")->find();
        //dump($menu_msg);
        //dump($menu_recomment);
        $this->assign('subject_recommnd', $menu_recomment); //专题推荐
        //SEO
        $this->assign('title', '专题'.'-'.$this->setting['title']); //分配标题
        if($menu_msg['keyword'] != ''){
        $this->assign('keyword', $menu_msg['keyword']);
        }else{
              $this->assign('keyword', $this->setting['keyword']);
        }
        if($menu_msg['explain'] !=''){
              $this->assign('content', $menu_msg['explain']);
        }else{
              $this->assign('content', $this->setting['describe']);
        }
        //SEO 
       // dump($menu_recomment);
        $this->assign('barName', '专题');
        $this->display();
    }

    //专题详细介绍
    public function _empty($method) {
        if (is_numeric($method)) {
            $map['id'] = $method;
            $map['status'] = 1;
            $map['pid'] = C('HOME_CUSTOMACTION_ID');

            $menu = M('menu');

            //专题信息
            $subject_msg = F('Subject/subject_msg_' . $method);
            if (empty($subject_msg)) {
                $subject_msg = $menu->field('id, name, `explain`, picture, title')->where($map)->find();
            }

            if (!$subject_msg) {
                $this->error(C('ERROR_MESSAGE'));
            } else {
                F('Subject/subject_msg_' . $method, $subject_msg);
                $soft = M('soft_belong');

                $arg['menu_child_id'] = $method;
                $arg['status'] = 1;
                $arg['LENGTH(jumpurl)'] = 0;

                //获取专题软件列表
                $this->software_list($arg, 'down', 'desc', 100);
            }
            $this->sort_list();
            $this->assign('subject_msg', $subject_msg);
            $this->assign('title', '专题 - ' . $subject_msg['name']); //分配标题  
            $this->assign('barName', $subject_msg['name']);
            $this->assign('keyword', '专题|' . $subject_msg['name']);   //分配关键字    
            $this->assign('content', $subject_msg['explain'] . '|安卓专题');  //分配简介
            $this->display('s_list');
        } else {
            $this->error(C('ERROR_MESSAGE'));
        }
    }

}

?>
