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

89 lines
3.7KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 动态模板channel标签
  5. *
  6. * @version $id:plus_channel.php 13:58 2010年7月5日 tianya $
  7. * @package DedeBIZ.Tpllib
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEINC.'/channelunit.func.php');
  13. /**
  14. * plus_channel
  15. *
  16. * @param array $atts
  17. * @param object $refObj
  18. * @param mixed $fields
  19. * @return array
  20. */
  21. function plus_channel(&$atts, &$refObj, &$fields)
  22. {
  23. global $dsql, $_vars;
  24. $attlist = "typeid=0,reid=0,row=100,type=son,currentstyle=";
  25. FillAtts($atts, $attlist);
  26. FillFields($atts, $fields, $refObj);
  27. extract($atts, EXTR_OVERWRITE);
  28. $line = empty($row) ? 100 : $row;
  29. $reArray = array();
  30. $reid = 0;
  31. $topid = 0;
  32. //如果属性里没指定栏目id,从引用类里获取栏目信息
  33. if (empty($typeid)) {
  34. if (isset($refObj->TypeLink->TypeInfos['id'])) {
  35. $typeid = $refObj->TypeLink->TypeInfos['id'];
  36. $reid = $refObj->TypeLink->TypeInfos['reid'];
  37. $topid = $refObj->TypeLink->TypeInfos['topid'];
  38. } else {
  39. $typeid = 0;
  40. }
  41. }
  42. //如果指定了栏目id,从数据库获取栏目信息
  43. else {
  44. $row2 = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE id='$typeid' ");
  45. $typeid = $row2['id'];
  46. $reid = $row2['reid'];
  47. $topid = $row2['topid'];
  48. }
  49. if ($type == '' || $type == 'sun') $type = 'son';
  50. if ($type == 'top') {
  51. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=0 AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line ";
  52. } else if ($type == 'son') {
  53. if ($typeid == 0) return $reArray;
  54. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$typeid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line ";
  55. } else if ($type == 'self') {
  56. if ($reid == 0) return $reArray;
  57. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line ";
  58. }
  59. //检查是否有子栏目,并返回rel提示用于二级菜单
  60. $needRel = true;
  61. if (empty($sql)) return $reArray;
  62. $dsql->Execute('me', $sql);
  63. $totalRow = $dsql->GetTotalRow('me');
  64. //如果用子栏目模式,当没有子栏目时显示同级栏目
  65. if ($type == 'son' && $reid != 0 && $totalRow == 0) {
  66. $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line ";
  67. $dsql->Execute('me', $sql);
  68. }
  69. $GLOBALS['autoindex'] = 0;
  70. while ($row = $dsql->GetArray()) {
  71. $row['currentstyle'] = $row['sonids'] = $row['rel'] = '';
  72. if ($needRel) {
  73. $row['sonids'] = GetSonIds($row['id'], 0, false);
  74. if ($row['sonids'] == '') $row['rel'] = '';
  75. else $row['rel'] = " rel='dropmenu{$row['id']}'";
  76. }
  77. //处理同级栏目中,当前栏目的样式
  78. if (($row['id'] == $typeid || ($topid == $row['id'] && $type == 'top')) && $currentstyle != '') {
  79. $row['currentstyle'] = $currentstyle;
  80. }
  81. $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
  82. $reArray[] = $row;
  83. $GLOBALS['autoindex']++;
  84. }
  85. //Loop for $i
  86. $dsql->FreeResult();
  87. return $reArray;
  88. }
  89. ?>