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

96 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 DedeCMS.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. {
  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. }
  34. else
  35. {
  36. $row = $dsql->GetOne("SELECT reid,topid,channeltype,ispart FROM `#@__arctype` WHERE id='$typeid' ");
  37. if(!is_array($row))
  38. {
  39. $typeid = $reid = $topid = $channeltype = $ispart = 0;
  40. } else {
  41. $reid = $row['reid'];
  42. $topid = $row['topid'];
  43. $channeltype = $row['channeltype'];
  44. $ispart = $row['ispart'];
  45. }
  46. }
  47. if( !empty($catid) )
  48. {
  49. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$catid' And ishidden<>1 ";
  50. }
  51. else
  52. {
  53. if($showall == "yes" )
  54. {
  55. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$topid' ";
  56. }
  57. else
  58. {
  59. if($showall=='')
  60. {
  61. if( $ispart < 2 && !empty($channeltype) ) $showall = $channeltype;
  62. else $showall = 6;
  63. }
  64. $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 ";
  65. }
  66. }
  67. $dsql->Execute('t', $topQuery);
  68. while($row = $dsql->GetArray('t'))
  69. {
  70. $row['typelink'] = GetOneTypeUrlA($row);
  71. $revalue .= "<dl class='cattree'>\n";
  72. $revalue .= "<dt><a href='{$row['typelink']}'>{$row['typename']}</a></dt>\n";
  73. cattreeListSon($row['id'], $revalue);
  74. $revalue .= "</dl>\n";
  75. }
  76. return $revalue;
  77. }
  78. function cattreeListSon($id, &$revalue)
  79. {
  80. global $dsql;
  81. $query = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='{$id}' And ishidden<>1 ";
  82. $dsql->Execute($id, $query);
  83. $thisv = '';
  84. while($row = $dsql->GetArray($id))
  85. {
  86. $row['typelink'] = GetOneTypeUrlA($row);
  87. $thisv .= " <dl class='cattree'>\n";
  88. $thisv .= " <dt><a href='{$row['typelink']}'>{$row['typename']}</a></dt>\n";
  89. cattreeListSon($row['id'], $thisv);
  90. $thisv .= " </dl>\n";
  91. }
  92. if($thisv!='') $revalue .= " <dd>\n$thisv </dd>\n";
  93. }