国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.4KB

  1. <?php if(!defined('DEDEINC')) exit("Request Error!");
  2. /**
  3. * 网站地图(sitemap类)
  4. *
  5. * @version $Id: sitemap.class.php 1 15:21 2010年7月5日Z tianya $
  6. * @package DedeCMS.Libraries
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license/v6
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(DEDEINC."/channelunit.func.php");
  12. /**
  13. * 网站地图(sitemap类)
  14. *
  15. * @package TypeLink
  16. * @subpackage DedeCMS.Libraries
  17. * @link https://www.dedebiz.com
  18. */
  19. class SiteMap
  20. {
  21. var $dsql;
  22. var $artDir;
  23. var $baseDir;
  24. //php5构造函数
  25. function __construct()
  26. {
  27. $this->idCounter = 0;
  28. $this->artDir = $GLOBALS['cfg_arcdir'];
  29. $this->baseDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_basedir'];
  30. $this->idArrary = "";
  31. $this->dsql = $GLOBALS['dsql'];
  32. }
  33. function SiteMap()
  34. {
  35. $this->__construct();
  36. }
  37. //清理类
  38. function Close()
  39. {
  40. }
  41. /**
  42. * 获取网站地图
  43. *
  44. * @access public
  45. * @param string $maptype 地图类型 site:站点 rss:rss
  46. * @return string
  47. */
  48. function GetSiteMap($maptype="site")
  49. {
  50. $mapString = "";
  51. if($maptype=="rss")
  52. {
  53. $this->dsql->SetQuery("SELECT id,typedir,isdefault,defaultname,typename,ispart,namerule2,moresite,siteurl,sitepath FROM #@__arctype WHERE ishidden<>1 AND reid=0 AND ispart<>2 ORDER BY sortrank");
  54. }
  55. else
  56. {
  57. $this->dsql->SetQuery("SELECT id,typedir,isdefault,defaultname,typename,ispart,namerule2,siteurl,sitepath,moresite,siteurl,sitepath FROM #@__arctype WHERE reid=0 AND ishidden<>1 ORDER BY sortrank");
  58. }
  59. $this->dsql->Execute(0);
  60. while($row=$this->dsql->GetObject(0))
  61. {
  62. if($maptype=="site")
  63. {
  64. $typelink = GetTypeUrl($row->id,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2,$row->moresite,$row->siteurl,$row->sitepath);
  65. }
  66. else
  67. {
  68. $typelink = $GLOBALS['cfg_cmsurl']."/data/rss/".$row->id.".xml";
  69. }
  70. $mapString .= "<div class=\"linkbox\">\r\n<h3><a href='$typelink'>".$row->typename."</a></h3>";
  71. $mapString .= "\t<ul class=\"f6\">\t\t\r".$this->LogicListAllSunType($row->id,$maptype)."\t\n</ul></div>\r\n";
  72. /*
  73. $mapString .= "<tr><td width='17%' align='center' bgcolor='#FAFEF1'>";
  74. $mapString .= "<a href='$typelink'><b>".$row->typename."</b></a>";
  75. $mapString .= "</td><td width='83%' bgcolor='#FFFFFF'>";
  76. $mapString .= $this->LogicListAllSunType($row->id,$maptype);
  77. $mapString .= "</td></tr>";
  78. */
  79. }
  80. return $mapString;
  81. }
  82. /**
  83. * 获得子类目的递归调用
  84. *
  85. * @access public
  86. * @param int $id 栏目ID
  87. * @param string $maptype 地图类型
  88. * @return string
  89. */
  90. function LogicListAllSunType($id, $maptype)
  91. {
  92. $fid = $id;
  93. $mapString = "";
  94. if($maptype=="rss")
  95. {
  96. $this->dsql->SetQuery("SELECT id,typedir,isdefault,defaultname,typename,ispart,namerule2,moresite,siteurl,sitepath FROM #@__arctype WHERE reid='".$id."' AND ishidden<>1 AND ispart<>2 ORDER BY sortrank");
  97. }
  98. else
  99. {
  100. $this->dsql->SetQuery("SELECT id,typedir,isdefault,defaultname,typename,ispart,namerule2,moresite,siteurl,sitepath FROM #@__arctype WHERE reid='".$id."' AND ishidden<>1 ORDER BY sortrank");
  101. }
  102. $this->dsql->Execute($fid);
  103. while($row=$this->dsql->GetObject($fid))
  104. {
  105. if($maptype=="site")
  106. {
  107. $typelink = GetTypeUrl($row->id,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2,$row->moresite,$row->siteurl,$row->sitepath);
  108. }
  109. else
  110. {
  111. $typelink = $GLOBALS['cfg_cmsurl']."/data/rss/".$row->id.".xml";
  112. }
  113. $mapString .= "<li><a href='$typelink'>".$row->typename."</a></li>\n\t\t";
  114. $mapString .= $this->LogicListAllSunType($row->id,$maptype);
  115. }
  116. return $mapString;
  117. }
  118. }