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