<?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 (paramset==0 || runMode=="forgedStatic"){
	$paras = replaceStr(QUERY_STRING,fileSuffix,'');
	$page=$paras;
}else{
	$page=getForm(parampage,"both") ;
}

if (empty($page)) {
	$page=1;
} else {
	if (is_numeric($page)) { $page = intval($page); } else { echoSaveStr("safe");exit();}
}
GetTopicById($page);

function GetTopicById($page){
	global $t1;
	$x = DJCMS_TEMPLATE."topicindex.html";
	$r = DB::fetch_first("SELECT count(*) as number FROM ".DB::table('topic')." ORDER BY m_sort ASC");
    $TotalResult = $r['number'];
	$pSize = getPageSizeOnCache($x, "topicindex", "topindex.html");if (empty($pSize)) $pSize=12;
	$cacheName = "parse_tp_";
	if (cacheStart==1){
		if (djcms::$content = memory('get', $cacheName)) {
        } else {
            parseTopicIndex($x);
			memory('set', $cacheName, djcms::$content);
        }
	} else {
			parseTopicIndex($x);
	}
	$pCount = ceil($TotalResult/$pSize);
	djcms::$content=replaceStr(djcms::$content,"{topicindexlist:page}",$page);
	djcms::parseTopicIndex($page,$pCount);
	djcms::parseIf();
	echo replaceStr(djcms::$content,"{djcms:runinfo}",getRunTime($t1));
}

function parseTopicIndex($x)
{
	djcms::$content=loadFile($x);
	djcms::parseTopAndFoot();
	djcms::parseSelf();
	djcms::parseGlobal();
	djcms::$content=replaceCurrentTypeId(djcms::$content);
	djcms::$content=replaceTopicId(djcms::$content);
	djcms::parseMenuList("");
	djcms::parseNewsList();
	djcms::parseAreaList();
	djcms::parseVideoList();
	djcms::parseTopicList();
}
?>
