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

98 lines
3.9KB

  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']."/static/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. return $mapString;
  68. }
  69. /**
  70. * 获得子类目的递归调用
  71. *
  72. * @access public
  73. * @param int $id 栏目ID
  74. * @param string $maptype 地图类型
  75. * @return string
  76. */
  77. function LogicListAllSunType($id, $maptype)
  78. {
  79. $fid = $id;
  80. $mapString = "";
  81. if ($maptype == "rss") {
  82. $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");
  83. } else {
  84. $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");
  85. }
  86. $this->dsql->Execute($fid);
  87. while ($row = $this->dsql->GetObject($fid)) {
  88. if ($maptype == "site") {
  89. $typelink = GetTypeUrl($row->id, MfTypedir($row->typedir), $row->isdefault, $row->defaultname, $row->ispart, $row->namerule2, $row->moresite, $row->siteurl, $row->sitepath);
  90. } else {
  91. $typelink = $GLOBALS['cfg_cmsurl']."/static/rss/".$row->id.".xml";
  92. }
  93. $mapString .= "<li><a href='$typelink'>".$row->typename."</a></li>\n\t\t";
  94. $mapString .= $this->LogicListAllSunType($row->id, $maptype);
  95. }
  96. return $mapString;
  97. }
  98. }