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

111 lines
4.1KB

  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. /*>>dede>>
  12. <name>树形类目标签</name>
  13. <type>全局标记</type>
  14. <for>V55,V56,V57</for>
  15. <description>调用树形类目</description>
  16. <demo>
  17. {dede:cattree typeid='' catid='' showall=''/}
  18. </demo>
  19. <attributes>
  20. <iterm>typeid:顶级树id</iterm>
  21. <iterm>catid:上级栏目id</iterm>
  22. <iterm>showall:在空或不存在时,强制用产品模型id;如果是 yes 刚显示整个语言区栏目树;为其它数字则是这个数字的模型的id</iterm>
  23. </attributes>
  24. >>dede>>*/
  25. function lib_cattree(&$ctag, &$refObj)
  26. {
  27. global $dsql;
  28. //属性处理
  29. //属性 showall 在空或不存在时,强制用产品模型id;如果是 yes 刚显示整个语言区栏目树;为其它数字则是这个数字的模型的id
  30. //typeid 指定顶级树 id ,指定后,前一个属性将无效
  31. $attlist="showall|,catid|0";
  32. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  33. extract($ctag->CAttribute->Items, EXTR_SKIP);
  34. $revalue = '';
  35. if(empty($typeid))
  36. {
  37. if( isset($refObj->TypeLink->TypeInfos['id']) ) {
  38. $typeid = $refObj->TypeLink->TypeInfos['id'];
  39. $reid = $refObj->TypeLink->TypeInfos['reid'];
  40. $topid = $refObj->TypeLink->TypeInfos['topid'];
  41. $channeltype = $refObj->TypeLink->TypeInfos['channeltype'];
  42. $ispart = $refObj->TypeLink->TypeInfos['ispart'];
  43. if($reid==0) $topid = $typeid;
  44. } else {
  45. $typeid = $reid = $topid = $channeltype = $ispart = 0;
  46. }
  47. }
  48. else
  49. {
  50. $row = $dsql->GetOne("SELECT reid,topid,channeltype,ispart FROM `#@__arctype` WHERE id='$typeid' ");
  51. if(!is_array($row))
  52. {
  53. $typeid = $reid = $topid = $channeltype = $ispart = 0;
  54. } else {
  55. $reid = $row['reid'];
  56. $topid = $row['topid'];
  57. $channeltype = $row['channeltype'];
  58. $ispart = $row['ispart'];
  59. }
  60. }
  61. if( !empty($catid) )
  62. {
  63. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$catid' And ishidden<>1 ";
  64. }
  65. else
  66. {
  67. if($showall == "yes" )
  68. {
  69. $topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$topid' ";
  70. }
  71. else
  72. {
  73. if($showall=='')
  74. {
  75. if( $ispart < 2 && !empty($channeltype) ) $showall = $channeltype;
  76. else $showall = 6;
  77. }
  78. $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 ";
  79. }
  80. }
  81. $dsql->Execute('t', $topQuery);
  82. while($row = $dsql->GetArray('t'))
  83. {
  84. $row['typelink'] = GetOneTypeUrlA($row);
  85. $revalue .= "<dl class='cattree'>\n";
  86. $revalue .= "<dt><a href='{$row['typelink']}'>{$row['typename']}</a></dt>\n";
  87. cattreeListSon($row['id'], $revalue);
  88. $revalue .= "</dl>\n";
  89. }
  90. return $revalue;
  91. }
  92. function cattreeListSon($id, &$revalue)
  93. {
  94. global $dsql;
  95. $query = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='{$id}' And ishidden<>1 ";
  96. $dsql->Execute($id, $query);
  97. $thisv = '';
  98. while($row = $dsql->GetArray($id))
  99. {
  100. $row['typelink'] = GetOneTypeUrlA($row);
  101. $thisv .= " <dl class='cattree'>\n";
  102. $thisv .= " <dt><a href='{$row['typelink']}'>{$row['typename']}</a></dt>\n";
  103. cattreeListSon($row['id'], $thisv);
  104. $thisv .= " </dl>\n";
  105. }
  106. if($thisv!='') $revalue .= " <dd>\n$thisv </dd>\n";
  107. }