修改的是dedecms目錄下的/include/inc_sitemap.php文件
復(fù)制代碼 代碼如下:
<?php
//class SiteMap
//--------------------------------
require_once(dirname(__FILE__)."/config_base.php");
require_once(dirname(__FILE__)."/inc_channel_unit_functions.php");
class SiteMap
{
var $dsql;
var $artDir;
var $baseDir;
//-------------
//php5構(gòu)造函數(shù)
//-------------
function __construct()
{
$this->idCounter = 0;
$this->artDir = $GLOBALS['cfg_arcdir'];
$this->baseDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_basedir'];
$this->idArrary = "";
$this->dsql = new DedeSql(false);
}
function SiteMap()
{
$this->__construct();
}
//------------------
//清理類
//------------------
function Close()
{
$this->dsql->Close();
}
//---------------------------
//獲取網(wǎng)站地圖
//$maptype = "site" 或 "rss"
//---------------------------
function GetSiteMap($maptype="site")
{
$mapString = "<DL>";
if($maptype=="rss") $this->dsql->SetQuery("Select ID,typedir,isdefault,defaultname,typename,ispart,namerule2 From dede_arctype where ishidden<>1 And reID=0 And ispart<>2 order by sortrank");
else $this->dsql->SetQuery("Select ID,typedir,isdefault,defaultname,typename,ispart,namerule2 From dede_arctype where reID=0 And ishidden<>1 order by sortrank");
$this->dsql->Execute(0);
while($row=$this->dsql->GetObject(0))
{
if($maptype=="site") $typelink = GetTypeUrl($row->ID,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2);
else $typelink = $GLOBALS['cfg_plus_dir']."/rss/".$row->ID.".xml";
$mapString .= "<DL><DT><SPAN><a href='$typelink'>".$row->typename."</a></span><A ;
$mapString .= $this->LogicListAllSunType($row->ID,$maptype,0);
}
$mapString .= "";
return $mapString;
}
//獲得子類目的遞歸調(diào)用
function LogicListAllSunType($ID,$maptype,$pd)
{
$fid = $ID;
$mapString = "";
$pd = $pd + 15;
if($maptype=="rss") $this->dsql->SetQuery("Select ID,typedir,isdefault,defaultname,typename,ispart,namerule2 From dede_arctype where reID='".$ID."' And ishidden<>1 And ispart<>2 order by sortrank");
else $this->dsql->SetQuery("Select ID,typedir,isdefault,defaultname,typename,ispart,namerule2 From dede_arctype where reID='".$ID."' And ishidden<>1 order by sortrank");
$this->dsql->Execute($fid);
$mapString .= "";
while($row=$this->dsql->GetObject($fid))
{
if($maptype=="site") $typelink = GetTypeUrl($row->ID,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2);
else $typelink = $GLOBALS['cfg_plus_dir']."/rss/".$row->ID.".xml";
$lastLink = "<DD><a href='$typelink'>".$row->typename."</a></DD>";
$mapString .= $lastLink;
$mok = $this->LogicListAllSunType($row->ID,$maptype,$pd);
if(ereg("<a",$mok)){
//$mapString = str_replace($lastLink,"<div style='margin-left:{$pd}px'>$lastLink",$mapString);
$mapString .= $mok;
}
}
$mapString .= "</DL>\r\n";
return $mapString;
}
}
?>