<?php
require_once(dirname(__FILE__)."/../inc/common.php");
/*******************************************************************************************
' Software name: DJCMS Content Management System
' Version:2.5
' Web: http://www.djcms.net
' Author: 心情(qq:1130731)
' Copyright (C) 2009-2010 DJCMS官方 版权所有
' 法律申明：DJCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/
if (paramset==0 || runMode=="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(paramid,"both");$page=getForm(parampage,"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,$t1;
	$y = explode(",", getTypeNameTemplateArrayOnCache($vType));$z = ifthen(empty($y[1]), "channel.html", $y[1]);$x = DJCMS_TEMPLATE.$z;
	if (strpos(" ,".getHideTypeIDS().",",",".$typeId.",") > 0) { OutNotFound("channel");}
	$typeIds = getTypeIdOnCache($typeId);
	djcms::$currentTypeId = $typeId;$cacheName = "parse_channel_".$typeId;
	if (cacheStart==1){
		if (djcms::$content = memory('get', $cacheName)) {
        } else {
            parseChannelPart($x,$y[0]);
			memory('set', $cacheName, djcms::$content);
        }
	} else {
			parseChannelPart($x,$y[0]);
	}
	djcms::$content = replaceStr(djcms::$content,"{channelpage:page}",$page);
    djcms::ParsePageList($typeIds,$page,"channel");
	djcms::parseIf();
	echo replaceStr(djcms::$content,"{djcms:runinfo}",getRunTime($t1));
}

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