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

133 lines
5.3KB

  1. <?php if(!defined('DEDEINC')) exit('Request Error!');
  2. /**
  3. * 分类信息地区与类型快捷链接
  4. *
  5. * @version $Id: infolink.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. require_once(DEDEINC.'/enums.func.php');
  12. require_once(DEDEDATA.'/enums/nativeplace.php');
  13. require_once(DEDEDATA.'/enums/infotype.php');
  14. function lib_infolink(&$ctag,&$refObj)
  15. {
  16. global $dsql,$nativeplace,$infotype,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite;
  17. global $em_nativeplaces,$em_infotypes;
  18. //属性处理
  19. //$attlist="row|12,titlelen|24";
  20. //FillAttsDefault($ctag->CAttribute->Items,$attlist);
  21. //extract($ctag->CAttribute->Items, EXTR_SKIP);
  22. $cmspath = ( (empty($cfg_cmspath) || !preg_match("#\/$#", $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath );
  23. $baseurl = preg_replace("#\/$#", '', $cfg_mainsite).$cmspath;
  24. $smalltypes = '';
  25. if( !empty($refObj->TypeLink->TypeInfos['smalltypes']) ) {
  26. $smalltypes = explode(',', $refObj->TypeLink->TypeInfos['smalltypes']);
  27. }
  28. if(empty($refObj->Fields['typeid'])) {
  29. $row = $dsql->GetOne("SELECT id FROM `#@__arctype` WHERE channeltype='-8' And reid = '0' ");
  30. $typeid = (is_array($row) ? $row['id'] : 0);
  31. }
  32. else {
  33. $typeid = $refObj->Fields['typeid'];
  34. }
  35. $innerText = trim($ctag->GetInnerText());
  36. if(empty($innerText)) $innerText = GetSysTemplets("info_link.htm");
  37. $ctp = new DedeTagParse();
  38. $ctp->SetNameSpace('field','[',']');
  39. $ctp->LoadSource($innerText);
  40. $revalue = $seli = '';
  41. $channelid = ( empty($refObj->TypeLink->TypeInfos['channeltype']) ? -8 : $refObj->TypeLink->TypeInfos['channeltype'] );
  42. $fields = array('nativeplace'=>'','infotype'=>'','typeid'=>$typeid,
  43. 'channelid'=>$channelid,'linkallplace'=>'','linkalltype'=>'');
  44. $fields['nativeplace'] = $fields['infotype'] = '';
  45. $fields['linkallplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
  46. $fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
  47. //地区链接
  48. if(empty($nativeplace))
  49. {
  50. foreach($em_nativeplaces as $eid=>$em)
  51. {
  52. if($eid % 500 != 0) continue;
  53. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  54. }
  55. }
  56. else
  57. {
  58. $sontype = ( ($nativeplace % 500 != 0) ? $nativeplace : 0 );
  59. $toptype = ( ($nativeplace % 500 == 0) ? $nativeplace : ( $nativeplace-($nativeplace%500) ) );
  60. $fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";
  61. foreach($em_nativeplaces as $eid=>$em)
  62. {
  63. if($eid < $toptype+1 || $eid > $toptype+499) continue;
  64. if($eid == $nativeplace) {
  65. $fields['nativeplace'] .= " <b>{$em}</b>\r\n";
  66. }
  67. else {
  68. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  69. }
  70. }
  71. }
  72. //小分类链接
  73. if(empty($infotype) || is_array($smalltypes))
  74. {
  75. foreach($em_infotypes as $eid=>$em)
  76. {
  77. if(!is_array($smalltypes) && $eid % 500 != 0) continue;
  78. if(is_array($smalltypes) && !in_array($eid, $smalltypes)) continue;
  79. if($eid == $infotype)
  80. {
  81. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  82. }
  83. else {
  84. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  85. }
  86. }
  87. }
  88. else
  89. {
  90. $sontype = ( ($infotype % 500 != 0) ? $infotype : 0 );
  91. $toptype = ( ($infotype % 500 == 0) ? $infotype : ( $infotype-($infotype%500) ) );
  92. $fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";
  93. foreach($em_infotypes as $eid=>$em)
  94. {
  95. if($eid < $toptype+1 || $eid > $toptype+499) continue;
  96. if($eid == $infotype) {
  97. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  98. }
  99. else {
  100. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  101. }
  102. }
  103. }
  104. if(is_array($ctp->CTags))
  105. {
  106. foreach($ctp->CTags as $tagid=>$ctag)
  107. {
  108. if(isset($fields[$ctag->GetName()])) {
  109. $ctp->Assign($tagid,$fields[$ctag->GetName()]);
  110. }
  111. }
  112. $revalue .= $ctp->GetResult();
  113. }
  114. return $revalue;
  115. }