<?php
require_once(dirname(__FILE__)."/../inc/common.php");
/*******************************************************************************************
' Software name: DJCMS Content Management System
' Version:3.0
' Web: http://www.djcms.net
' Author: 心情(qq:1130731)
' Copyright (C) 2009-2010 DJCMS官方 版权所有
' 法律申明：DJCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/
if (newsparamset==0 || newsrunMode=="forgedStatic"){
    $paras = replaceStr(QUERY_STRING,fileSuffix,'');
    if (strpos($paras, "-") > 0) {
	    $parasArray = explode("-",$paras); $id = $parasArray[0]; $page = $parasArray[1];
    } else {
	    $id = $paras; $page = 1;
    }
} else {
	$id = getForm(newsparamid,"both") ; $page = getForm(newsparampage,"both");
}
if (empty($id)) {
	echoSaveStr("null");exit();
} else {
	if (is_numeric($id)){ $id = intval($id); } else { echoSaveStr("safe");exit();}
}
if (empty($page)) {
	$page=1;
} else {
	if (is_numeric($page)) { $page = intval($page); } else { echoSaveStr("safe");exit();}
}
echoChannel($id);

function echoChannel($typeId){
	global $page;
	$y = explode(",", getNewsTypeNameTemplateArrayOnCache($vType));$z = ifthen(empty($y[1]), "newspage.html", $y[1]);$x = DJCMS_TEMPLATE.$z;
	if (strpos(" ,".getHideNewsTypeIDS().",",",".$typeId.",") > 0) { OutNotFound("newspage");}
	$typeIds = getNewsTypeIdOnCache($typeId);
	djcms::$currentTypeId = $typeId;$cacheName = "parse_npl_".$typeId;
	if (cacheStart==1){
		if (!djcms::$content = memory('get', $cacheName)) {
            parseChannelPart($x,$y[0]);
            memory('set', $cacheName, djcms::$content);
        }
	} else {
		parseChannelPart($x,$y[0]);
	}
	djcms::$content = replaceStr(djcms::$content,"{newspagelist:page}",$page);
    djcms::parseNewsPartList($typeIds,$page,"newspage");
	djcms::parseIf();
	echo replaceStr(djcms::$content,"{djcms:runinfo}",getRunTime());
}

function parseChannelPart($x,$y)
{
	djcms::$content=loadFile($x);
	djcms::parseTopAndFoot();
	djcms::parseSelf();
	djcms::parseGlobal();
	$z = getTypeField(djcms::$currentTypeId,"m_keyword,m_description","news");
	$content = replaceStr(djcms::$content,"{djcms:currenttypeid}", djcms::$currentTypeId);
	$content = replaceStr($content,"{newspagelist:typename}",$y);
	djcms::$content = replaceStr(replaceStr($content,"{newspagelist:keywords}",$z[0]),"{newspagelist:description}",$z[1]);
	djcms::parseMenuList("");
	djcms::parseNewsList();
	djcms::parseAreaList();
	djcms::parseVideoList();
	djcms::parseTopicList();
	djcms::$content = replaceStr(djcms::$content,"{newspagelist:typetext}", getNewsTypeTextOnCache(djcms::$currentTypeId));
}
?>
