<?php
/**
 * 五十九秒网络购物cms 文章列表页实体类
 * ============================================================================
 * 版权所有 2009-2012 五十九秒网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.59miao.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: longzhang
 * 
*/
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
class ArtilelistModel extends Model {	
	public function __construct() {
	   parent::__construct();	  	
	  $this->_fields = array('id','title','keywords','info','source','ontop','hot','color','pid','content','date');
	  $this->_tables = array(DB_FREFIX.'artile');
	   $this->_check = new ArtilelistCheck();
	   list(
				$this->_R['pid'],
				$this->_R['id'],
				$this->_R['page']						
				
		) = $this->getRequest()->getParam(array(
				isset($_GET['pid']) ? $_GET['pid'] : null,
				isset($_GET['id'])?$_GET['id']:null,
				isset($_GET['page'])?$_GET['page']:'1'		
				
		));	
	}	
	//重新构造分页类
	public function artilelist(){		
		//显示前台调用的所有文章
		if(!is_numeric($this->_R['pid']) || $this->_R['pid']==null){
			header('Location: ./');
			exit;			
		}
		$page=($this->_R['page']-1)*FRONT_PAGE_SIZE;	
		$size=FRONT_PAGE_SIZE;
		$this->_fields = array('id','title','keywords','info','source','ontop','hot','color','pid','date');
		$_where=array("pid='{$this->_R['pid']}'");		
		return parent::select(array('id','title','color'),array('where'=>$_where,'limit'=>"$page,$size",'order'=>'ontop desc'));
	}
	public function findOneArtileNav() {			
		
		$_where = array("id='{$this->_R['pid']}'");
		$this->_tables=	array(DB_FREFIX.'artilenav');
		return parent::select(array('id','name','info'),
											array('where'=>$_where, 'limit'=>'1'));
	}

	//获取文章内容
	public function FindFrontContent(){
		$_where = array("id='{$this->_R['id']}'");
		if (!is_numeric($this->_R['id']) || $this->_R['id']==null || !$this->_check->oneCheck($this, $_where))
		{
			header('Location: ./');
			exit;
		}
		return parent::select(array('id','title','keywords','info','source','ontop','hot','color','pid','content','date'), 
											array('where'=>$_where,'limit'=>1, 'order'=>'date DESC'));	
	}
	public function total(){
		$_where=array("pid='{$this->_R['pid']}'");
		return parent::total(array('where'=>$_where));
	}

}
?>