<?php
class IndexAction extends GlobalAction{
    
	/**
     * 首页
     *
     */
	public function index(){
		//新闻活动
		$newslist = array();
		$News_category = D('News_category');
		$condition = array();
		$condition['id']  = array('in','3,2,4');
		$category = $News_category->where($condition)->order('id desc')->findAll();		
	
		foreach ($category as $key => $item){			
			$News = D('News');
			$condition = array();
			$condition['classid'] = array('eq',$item['id']);
			$condition['istop'] = array('eq',1);
			$news = $News->field('id,title,posttime')->where($condition)->order('orderid,id desc')->limit(6)->findAll();
			
			$newslist[$key]['id'] = $item['id'];
			$newslist[$key]['classname'] = $item['classname'];
			$newslist[$key]['news'] = $news;
		}	
		$this->assign('newslist',$newslist);
		
		
		//合作专区
		
		$newslist = array();
		$News_category = D('News_category');
		$condition = array();
		$condition['id']  = array('in','5,7,8,9');
		$category = $News_category->where($condition)->order('id')->findAll();		
	       
	
		foreach ($category as $key => $item){			
			$News = D('News');
			$condition = array();
			$condition['classid'] = array('eq',$item['id']);
			$condition['istop'] = array('eq',1);
			$news = $News->field('id,title,posttime')->where($condition)->order('orderid,id desc')->limit(6)->findAll();
			
			$newslist[$key]['id'] = $item['id'];
			$newslist[$key]['classname'] = $item['classname'];
			$newslist[$key]['news'] = $news;
		}	
		$this->assign('mediaslist',$newslist);
		
		
		//游戏资料
		$helplist = array();
		$Help_category = D('Help_category');
		$condition = array();
		$condition['id']  = array('in','2,3,4');
		$category = $Help_category->where($condition)->order('id ')->findAll();			
        foreach ($category as $key => $item){			
			$Help = D('Help');
			$condition = array();
			$condition['classid'] = array('eq',$item['id']);
			$help = $Help->field('id,url,title')->where($condition)->order('orderid,id asc')->findAll();
			
			$helplist[$item['id']]['id'] = $item['id'];
			$helplist[$item['id']]['classname'] = $item['classname'];
			$helplist[$item['id']]['article'] = $help;
        }	
		$this->assign('helplist',$helplist);		
		
		//媒体合作
		$Adsense = D('Adsense');
		$condition=array();
		$condition['classid'] = array('eq',2);
		$medialist = $Adsense->where($condition)->order('id')->limit(14)->findAll();
		$this->assign('medialist',$medialist);
	
		
		//商城新品
		// $Adsense = D('Adsense');
		// $condition=array();
		// $condition['classid'] = array('eq',5);
		// $productlist = $Adsense->where($condition)->order('id')->findAll();
		// $this->assign('productlist',$productlist);
		
		//游戏截图
		$piclist = array();
		$News_category = D('News_category');
		$condition = array();
		$condition['id']  = array('in','16');
		$category = $News_category->where($condition)->order('id desc')->findAll();		
	
		foreach ($category as $key => $item){			
			$News = D('News');
			$condition = array();
			$condition['classid'] = array('eq',$item['id']);
			$condition['istop'] = array('eq',1);
			$news = $News->field('id,title,posttime')->where($condition)->order('orderid,id desc')->limit(6)->findAll();
			
			$piclist[$key]['id'] = $item['id'];
			$piclist[$key]['classname'] = $item['classname'];
			$piclist[$key]['news'] = $news;
		}	
		$this->assign('piclist',$piclist);
		
		
		
		//常见问题
		$Article = D('Article');
		$condition=array();
		$condition['classid'] = array('eq',2);
		$faqlist = $Article->where($condition)->order('id')->limit(5)->findAll();
		$this->assign('faqlist',$faqlist);
		
		//玩家社区
		$Adsense = D('Adsense');
		$condition=array();
		$condition['classid'] = array('eq',6);
		$condition['pic'] = array('eq','');
		$bbslist = $Adsense->where($condition)->order('id')->findAll();
		$this->assign('bbslist',$bbslist);
		
		$this->display();
	}
	
	
}
?>