<?php
require_once 'Config.php';
/**
 * 系列单页类
 *
 * @author Wzb
 *        
 */
class USL_IntroNews extends USL_Base {
	/**
	 * 页面标签
	 *
	 * @var string
	 */
	private $_tag;
	
	/**
	 * 新闻对象
	 *
	 * @var object
	 */
	private $_NewsObj;
	
	/**
	 * 类别对象
	 *
	 * @var object
	 */
	private $_SortObj;
	
	/**
	 * 构造类
	 *
	 * @param string $tag 标签
	 */
	public function __construct($tag, $theId) {
		parent::__construct ();
		$this->init ( $tag );
		$this->setIntroNews ( $theId );
		$this->setWeiZhi ();
	}
	
	/**
	 * 初始化
	 *
	 * @param string $tag 标签
	 */
	private function init($tag) {
		$this->_weizhi = $this->_tag = $tag;
		switch ($tag) {
			case "About" :
				$this->_SortObj = BLL_NewsSort::getOne ( 4, 'id,sortName' ); // 关于我们
// 				print_r($this->_SortObj);die;
				break;
			case "rlzy" :
				$this->_SortObj = BLL_NewsSort::getOne ( 5, 'id,sortName' ); //
				// 				print_r($this->_SortObj);die;
				break;
			default :
				die ( COM_OftenJavaScript::showInfo ( "标签错误" ) );
				break;
		}
	}
	
	/**
	 * 设置变量值
	 */
	public function _assignContent() {
		parent::_showComm ();
		$this->_tpl->assign ( "webName", $this->_webStr ); // 网站标题
		$this->_tpl->assign ( "theKeyWords", $this->_keywords ); // 网站关键字
		$this->_tpl->assign ( "theDescription", $this->_description ); // 网站描述
		$this->_tpl->assign ( "leftNav", $this->_leftNav ); // 左侧导航
		$this->_tpl->assign ( "thisName", $this->_thisName ); // 栏目名称
		$this->_tpl->assign ( "address", $this->_address ); // 当前位置
		$this->_tpl->assign ( "onePage", $this->_NewsObj ); // 单页对象
	}
	
	/**
	 * 设置位置信息
	 */
	private function setWeiZhi() {
		switch ($this->weizhiRoot ()) {
			// 在这里进行 “ 当前位置 、左侧导航 ” 的非常规设置!!!!!
			default :
				$this->_leftNav = USL_LeftNav::_IntroNews ( $this->_SortObj ['id'], $this->_SortObj ['sortName'], $this->_tag, $this->_NewsObj ['id'] );
				break;
		}
		$this->_address [] = array ("title" => $this->_SortObj ['sortName'],"url" => 'IntroNews.php?tag=' . $this->_tag );
		$this->_address [] = array ("title" => $this->_NewsObj ['title'],"url" => "" );
	}
	
	/**
	 * 设置系列单页常规信息
	 */
	private function setIntroNews($theId) {
		if (count ( $this->_SortObj ) == 0) {
			die ( COM_OftenJavaScript::showInfo ( "类别不存在" ) );
		}
		if ($theId > 0) {
			$this->_NewsObj = BLL_News::getOne ( $theId );
			if (count ( $this->_NewsObj ) == 0) {
				die ( COM_OftenJavaScript::showInfo ( "该信息不存在，可能已被删除" ) );
			}
		} else {
			$tempList = BLL_News::getList ( $this->_SortObj ['id'], false, '*', array ('begin' => 0,'num' => 1 ) );
			if (count ( $tempList ) == 0) {
				die ( COM_OftenJavaScript::showInfo ( "该类别下没有内容" ) );
			}
			$this->_NewsObj = $tempList [0];
		}
		$this->_weizhi .= '_' . $this->_NewsObj ['id'];
		$this->_thisName = $this->_NewsObj ['title'];
		$this->_webStr = COM_OftenFunction::setWebName ( $this->_NewsObj ['title'] . '-' );
		$this->_keywords = $this->_NewsObj ['title'];
		$this->_description = COM_OftenFunction::CutStr ( COM_OftenFunction::noHtml ( $this->_NewsObj ['content'] ), 200 );
		// 注意设置这里的内容页图片宽度限制PX
		$this->_NewsObj ['content'] = str_replace ( array ("<img","<IMG" ), "<img onload=\"resize(this,700)\"", $this->_NewsObj ['content'] );
	}
}

// 实例化
$configObj = BLL_WebSet::getOne ();
$thisPage = new USL_IntroNews ( $_GET ['tag'], array_key_exists ( 'theId', $_GET ) ? intval ( $_GET ['theId'] ) : 0 );
$thisPage->_assignContent ();
$thisPage->_tpl->display ( "Tpl/Intro.tpl" );
?>