国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

156 рядки
5.5KB

  1. <?php
  2. /**
  3. * 获取栏目列表标签
  4. *
  5. * @version $Id: channel.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_channel(&$ctag,&$refObj)
  12. {
  13. global $dsql;
  14. $attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|,cacheid|";
  15. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  16. extract($ctag->CAttribute->Items, EXTR_SKIP);
  17. $innertext = $ctag->GetInnerText();
  18. $line = empty($row) ? 100 : $row;
  19. $likeType = '';
  20. //读取固定的缓存块
  21. $cacheid = trim($cacheid);
  22. if($cacheid !='') {
  23. $likeType = GetCacheBlock($cacheid);
  24. if($likeType != '') return $likeType;
  25. }
  26. $reid = 0;
  27. $topid = 0;
  28. //如果属性里没指定栏目id,从引用类里获取栏目信息
  29. if(empty($typeid))
  30. {
  31. if( isset($refObj->TypeLink->TypeInfos['id']) )
  32. {
  33. $typeid = $refObj->TypeLink->TypeInfos['id'];
  34. $reid = $refObj->TypeLink->TypeInfos['reid'];
  35. $topid = $refObj->TypeLink->TypeInfos['topid'];
  36. }
  37. else {
  38. $typeid = 0;
  39. }
  40. }
  41. //如果指定了栏目id,从数据库获取栏目信息
  42. else
  43. {
  44. $row2 = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE id='$typeid' ");
  45. if (is_array($row2)) {
  46. $typeid = $row2['id'];
  47. $reid = $row2['reid'];
  48. $topid = $row2['topid'];
  49. $issetInfos = true;
  50. }
  51. }
  52. if($type=='' || $type=='sun') $type='son';
  53. if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");
  54. if($type=='top')
  55. {
  56. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  57. From `#@__arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
  58. }
  59. else if($type=='son')
  60. {
  61. if($typeid==0) return '';
  62. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  63. From `#@__arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
  64. }
  65. else if($type=='self')
  66. {
  67. if($reid==0) return '';
  68. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  69. FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
  70. }
  71. //And id<>'$typeid'
  72. $needRel = false;
  73. $dtp2 = new DedeTagParse();
  74. $dtp2->SetNameSpace('field','[',']');
  75. $dtp2->LoadSource($innertext);
  76. //检查是否有子栏目,并返回rel提示(用于二级菜单)
  77. if(preg_match('#:rel#', $innertext)) $needRel = true;
  78. if(empty($sql)) return '';
  79. $dsql->SetQuery($sql);
  80. $dsql->Execute();
  81. $totalRow = $dsql->GetTotalRow();
  82. //如果用子栏目模式,当没有子栏目时显示同级栏目
  83. if($type=='son' && $reid!=0 && $totalRow==0)
  84. {
  85. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  86. FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
  87. $dsql->SetQuery($sql);
  88. $dsql->Execute();
  89. }
  90. $GLOBALS['autoindex'] = 0;
  91. for($i=0;$i < $line;$i++)
  92. {
  93. if($col>1) $likeType .= "<dl>\r\n";
  94. for($j=0; $j<$col; $j++)
  95. {
  96. if($col>1) $likeType .= "<dd>\r\n";
  97. if($row=$dsql->GetArray())
  98. {
  99. $row['sonids'] = $row['rel'] = '';
  100. if($needRel)
  101. {
  102. $row['sonids'] = GetSonIds($row['id'], 0, false);
  103. if($row['sonids']=='') $row['rel'] = '';
  104. else $row['rel'] = " rel='dropmenu{$row['id']}'";
  105. }
  106. //处理同级栏目中,当前栏目的样式
  107. if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
  108. {
  109. $linkOkstr = $currentstyle;
  110. $row['typelink'] = GetOneTypeUrlA($row);
  111. $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
  112. $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
  113. $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
  114. $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
  115. $likeType .= $linkOkstr;
  116. }
  117. else
  118. {
  119. $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
  120. if(is_array($dtp2->CTags))
  121. {
  122. foreach($dtp2->CTags as $tagid=>$ctag)
  123. {
  124. if(isset($row[$ctag->GetName()])) $dtp2->Assign($tagid,$row[$ctag->GetName()]);
  125. }
  126. }
  127. $likeType .= $dtp2->GetResult();
  128. }
  129. }
  130. if($col>1) $likeType .= "</dd>\r\n";
  131. $GLOBALS['autoindex']++;
  132. }
  133. //Loop Col
  134. if($col>1)
  135. {
  136. $i += $col - 1;
  137. $likeType .= " </dl>\r\n";
  138. }
  139. }
  140. //Loop for $i
  141. $dsql->FreeResult();
  142. if($cacheid !='') {
  143. WriteCacheBlock($cacheid, $likeType);
  144. }
  145. return $likeType;
  146. }