<?php
require_once 'Config.php';
/**
 * 新闻列表搜索类
 *
 * @author Wzb
 *        
 */
class USL_NewsSearch extends USL_Base {
	/**
	 * 标签
	 *
	 * @var string
	 */
	private $_tag;
	
	/**
	 * 翻页对象
	 *
	 * @var object
	 */
	private $_pdObj;
	
	/**
	 * 翻页所需要的字段
	 *
	 * @var string
	 */
	private $_needCode;
	
	/**
	 * 排版样式
	 *
	 * @var string
	 */
	private $_stype;
	
	/**
	 * 每页显示的数量
	 *
	 * @var int
	 */
	private $_pageSize;
	
	/**
	 * 构造类
	 *
	 * @param string $tag 标签
	 * @param int $theId ID
	 */
	public function __construct($tag) {
		parent::__construct ();
		$this->init ( $tag );
		$this->setNewsPd ();
	}
	
	/**
	 * 初始化
	 *
	 * @param string $tag 标签
	 *       
	 */
	private function init($tag) {
		$this->_weizhi = $this->_tag = $tag;
		// 如果为非文字列表在这里设置排版样式
		// $this->_stype = "PicList";
		switch ($tag) {
			case "Search" : // 站内搜索
				$this->_thisName = "站内搜索";
				$this->_keywords = "站内搜索";
				$this->_webStr = COM_OftenFunction::setWebName ( '站内搜索-' );
				$this->_address [] = array ("title" => "站内搜索","url" => "" );
				$this->_leftNav = USL_LeftNav::_OneNav ( "站内搜索", "javascript:;" );
				break;
			default :
				die ( COM_OftenJavaScript::showInfo ( "标签错误" ) );
				break;
		}
		
		switch ($this->_stype) {
			case "PicList" : // 图片列表
				$this->_needCode = 'id,title,picture';
				$this->_pageSize = 9;
				break;
			default :
				$this->_stype = "TitleList"; // 默认为文字列表
				$this->_needCode = 'id,title,addTime';
				$this->_pageSize = 18;
				break;
		}
	}
	
	/**
	 * 设置变量值
	 */
	public function _assignContent() {
		parent::_showComm ();
		$this->_tpl->assign ( "webName", $this->_webStr ); // 网站标题
		$this->_tpl->assign ( "theKeyWords", $this->_keywords ); // 网站关键字
		$this->_tpl->assign ( "thisName", $this->_thisName ); // 栏目名称
		$this->_tpl->assign ( "leftNav", $this->_leftNav ); // 左侧导航
		$this->_tpl->assign ( "address", $this->_address ); // 当前位置
		$this->_tpl->assign ( "style", $this->_stype ); // 排版样式
		$this->_tpl->assign ( "dataList", $this->_pdObj->_getDataList () ); // 数据列表
		$this->_tpl->assign ( "pageInfo", $this->_pdObj->_getPageInfo () ); // 设置翻页信息
	}
	
	/**
	 * 设置新闻翻页
	 */
	private function setNewsPd() {
		switch ($this->weizhiRoot ()) {
			// 这里可以设置其他搜索的翻页模式
			default :
				// 默认采用搜索标题
				$thetxt = COM_OftenFunction::delSpecialChar ( $_GET ['thetxt'] );
				$whereArray = array ();
				$whereArray [] = array ('type' => 'likeString','name' => 'title','value' => $thetxt );
				$this->_pdObj = new COM_PagingDevice ( $this->_pageSize );
				$this->_pdObj->_setDataList ( BLL_News::getSerachList ( "1", $whereArray, true, $this->_needCode, $this->_pdObj->_getLimitArr () ) );
				$this->_pdObj->_setSuffixal ( 'tag=' . $this->_tag . '&thetxt=' . $thetxt );
				break;
		}
	}
}

// 实例化
$configObj = BLL_WebSet::getOne ();
$thisPage = new USL_NewsSearch ( $_GET ['tag'] );
$thisPage->_assignContent ();
$thisPage->_tpl->display ( "Tpl/News_List.tpl" );
?>