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

82 lines
3.6KB

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