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

84 lines
3.6KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. *
  5. *
  6. * @version $Id: cattree.lib.php 1 9:29 2010年7月6日Z tianya $
  7. * @package DedeBIZ.Taglib
  8. * @copyright Copyright (c) 2022, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. function lib_cattree(&$ctag, &$refObj)
  13. {
  14. global $dsql;
  15. //属性处理
  16. //属性 showall 在空或不存在时,强制用产品模型id;如果是 yes 刚显示整个语言区栏目树;为其它数字则是这个数字的模型的id
  17. //typeid 指定顶级树 id ,指定后,前一个属性将无效
  18. $attlist = "showall|,catid|0";
  19. FillAttsDefault($ctag->CAttribute->Items, $attlist);
  20. extract($ctag->CAttribute->Items, EXTR_SKIP);
  21. $revalue = '';
  22. if (empty($typeid)) {
  23. if (isset($refObj->TypeLink->TypeInfos['id'])) {
  24. $typeid = $refObj->TypeLink->TypeInfos['id'];
  25. $reid = $refObj->TypeLink->TypeInfos['reid'];
  26. $topid = $refObj->TypeLink->TypeInfos['topid'];
  27. $channeltype = $refObj->TypeLink->TypeInfos['channeltype'];
  28. $ispart = $refObj->TypeLink->TypeInfos['ispart'];
  29. if ($reid == 0) $topid = $typeid;
  30. } else {
  31. $typeid = $reid = $topid = $channeltype = $ispart = 0;
  32. }
  33. } else {
  34. $row = $dsql->GetOne("SELECT reid,topid,channeltype,ispart FROM `#@__arctype` WHERE id='$typeid' ");
  35. if (!is_array($row)) {
  36. $typeid = $reid = $topid = $channeltype = $ispart = 0;
  37. } else {
  38. $reid = $row['reid'];
  39. $topid = $row['topid'];
  40. $channeltype = $row['channeltype'];
  41. $ispart = $row['ispart'];
  42. }
  43. }
  44. if (!empty($catid)) {
  45. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$catid' And ishidden<>1 ";
  46. } else {
  47. if ($showall == "yes") {
  48. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$topid' ";
  49. } else {
  50. if ($showall == '') {
  51. if ($ispart < 2 && !empty($channeltype)) $showall = $channeltype;
  52. else $showall = 6;
  53. }
  54. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='{$topid}' And channeltype='{$showall}' And ispart<2 And ishidden<>1 ";
  55. }
  56. }
  57. $dsql->Execute('t', $topQuery);
  58. while ($row = $dsql->GetArray('t')) {
  59. $row['typelink'] = GetOneTypeUrlA($row);
  60. $revalue .= "<dl class='cattree'>\n";
  61. $revalue .= "<dt><a href='{$row['typelink']}'>{$row['typename']}</a></dt>\n";
  62. cattreeListSon($row['id'], $revalue);
  63. $revalue .= "</dl>\n";
  64. }
  65. return $revalue;
  66. }
  67. function cattreeListSon($id, &$revalue)
  68. {
  69. global $dsql;
  70. $query = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='{$id}' And ishidden<>1 ";
  71. $dsql->Execute($id, $query);
  72. $thisv = '';
  73. while ($row = $dsql->GetArray($id)) {
  74. $row['typelink'] = GetOneTypeUrlA($row);
  75. $thisv .= " <dl class='cattree'>\n";
  76. $thisv .= " <dt><a href='{$row['typelink']}'>{$row['typename']}</a></dt>\n";
  77. cattreeListSon($row['id'], $thisv);
  78. $thisv .= " </dl>\n";
  79. }
  80. if ($thisv != '') $revalue .= " <dd>\n$thisv </dd>\n";
  81. }