国内流行的内容管理系统(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.

113 lines
4.2KB

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