<?php
if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');}
class special extends controllerBase
{
	function __construct(){
		parent::__construct();
		$this->sy_class_type=syClass('syclasstype');
		$this->Class=syClass('ldi_special');

		$this->SysIconfig = parent::geticonfig();;

	}
	function index(){
		if($this->sysParams('file',1)!=''){
			$this->special=syDB('special')->find(' htmlfile="'.$this->sysParams('file',1).'" or sid='.$this->sysParams('file').' ');
			$tid = $this->special['sid'];
		}else{
			$sid = $this->sysParams('sid');
			$this->special=syDB('special')->find(" sid=".$sid." ");
		}
		if(!$this->special){message("指定专题不存在");}

		$this->db = func_get_iglobal(array('db','prefix')).$this->special['molds'];
		
		if($this->special['isindex']==0)$t=$this->special['t_index'];
		if($this->special['isindex']==2)$t=$this->special['t_listb'];
		if($this->special['isindex']==1)$t=$this->special['t_list'];
		if($this->special['isindex']==1){
			$w.=' where isshow=1 ';
			$w.='and sid='.$sid.' ';
			$order=' order by orders desc,addtime desc,id desc';
			$f=syDB('fields')->findAll(" molds='".$this->special['molds']."' and lists=1 ");
			if($f){
				foreach($f as $v){$fields.=','.$v['fields'];}
				$sql='select id,tid,sid,title,style,trait,gourl,addtime,hits,litpic,orders,mrank,mgold,isshow,description,user'.$fields.' from '.$this->db.' a left join '.$this->db.'_field b on (a.id=b.aid)'.$w.$order;
			}else{
				$sql='select id,tid,sid,title,style,trait,gourl,addtime,hits,litpic,orders,mrank,mgold,isshow,description,user from '.$this->db.$w.$order;
			}
			$this->lists = $this->Class->syPager($this->sysParams('page',0,1),$this->special['listnum'])->findSql($sql);
			$pages=$this->Class->syPager()->getPager();
			$this->pages=html_url(array("type"=>"classtype","sid"=>$this->special["sid"],"url"=>$this->special["gourl"],"htmldir"=>$this->special["htmldir"],"htmlfile"=>$this->special["htmlfile"]),$pages);
			$i=1;
			$list_c=$this->lists;
			foreach($list_c as $k=>$v){
				$list_c[$k]['url']=html_url('article',$v);
			}
			$this->lists=$list_c;
		}
		$this->positions='<a href="'.$GLOBALS["WWW"].'">首页</a>  &gt;  专题  &gt;  '.$this->special['name'];
		$this->display('special/'.$t);
	}
}	