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

112 lines
4.3KB

  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 DedeBIZ.Libraries
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(DEDEINC . "/channelunit.func.php");
  12. /**
  13. * 网站地图(sitemap类)
  14. *
  15. * @package TypeLink
  16. * @subpackage DedeBIZ.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. $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");
  53. } else {
  54. $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");
  55. }
  56. $this->dsql->Execute(0);
  57. while ($row = $this->dsql->GetObject(0)) {
  58. if ($maptype == "site") {
  59. $typelink = GetTypeUrl($row->id, MfTypedir($row->typedir), $row->isdefault, $row->defaultname, $row->ispart, $row->namerule2, $row->moresite, $row->siteurl, $row->sitepath);
  60. } else {
  61. $typelink = $GLOBALS['cfg_cmsurl'] . "/data/rss/" . $row->id . ".xml";
  62. }
  63. $mapString .= "<div class=\"linkbox\">\r\n<h3><a href='$typelink'>" . $row->typename . "</a></h3>";
  64. $mapString .= "\t<ul class=\"f6\">\t\t\r" . $this->LogicListAllSunType($row->id, $maptype) . "\t\n</ul></div>\r\n";
  65. /*
  66. $mapString .= "<tr><td width='17%' align='center' bgcolor='#FAFEF1'>";
  67. $mapString .= "<a href='$typelink'><b>".$row->typename."</b></a>";
  68. $mapString .= "</td><td width='83%' bgcolor='#FFFFFF'>";
  69. $mapString .= $this->LogicListAllSunType($row->id,$maptype);
  70. $mapString .= "</td></tr>";
  71. */
  72. }
  73. return $mapString;
  74. }
  75. /**
  76. * 获得子类目的递归调用
  77. *
  78. * @access public
  79. * @param int $id 栏目ID
  80. * @param string $maptype 地图类型
  81. * @return string
  82. */
  83. function LogicListAllSunType($id, $maptype)
  84. {
  85. $fid = $id;
  86. $mapString = "";
  87. if ($maptype == "rss") {
  88. $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");
  89. } else {
  90. $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");
  91. }
  92. $this->dsql->Execute($fid);
  93. while ($row = $this->dsql->GetObject($fid)) {
  94. if ($maptype == "site") {
  95. $typelink = GetTypeUrl($row->id, MfTypedir($row->typedir), $row->isdefault, $row->defaultname, $row->ispart, $row->namerule2, $row->moresite, $row->siteurl, $row->sitepath);
  96. } else {
  97. $typelink = $GLOBALS['cfg_cmsurl'] . "/data/rss/" . $row->id . ".xml";
  98. }
  99. $mapString .= "<li><a href='$typelink'>" . $row->typename . "</a></li>\n\t\t";
  100. $mapString .= $this->LogicListAllSunType($row->id, $maptype);
  101. }
  102. return $mapString;
  103. }
  104. }