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

119 lines
5.2KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 分类信息地区与类型快捷链接
  5. *
  6. * @version $Id: infolink.lib.php 1 9:29 2010年7月6日Z tianya $
  7. * @package DedeBIZ.Taglib
  8. * @copyright Copyright (c) 2022, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEINC.'/enums.func.php');
  13. require_once(DEDEDATA.'/enums/nativeplace.php');
  14. require_once(DEDEDATA.'/enums/infotype.php');
  15. function lib_infolink(&$ctag, &$refObj)
  16. {
  17. global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite;
  18. global $em_nativeplaces, $em_infotypes;
  19. //属性处理
  20. //$attlist="row|12,titlelen|24";
  21. //FillAttsDefault($ctag->CAttribute->Items,$attlist);
  22. //extract($ctag->CAttribute->Items, EXTR_SKIP);
  23. $cmspath = ((empty($cfg_cmspath) || !preg_match("#\/$#", $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath);
  24. $baseurl = preg_replace("#\/$#", '', $cfg_mainsite).$cmspath;
  25. $smalltypes = '';
  26. if (!empty($refObj->TypeLink->TypeInfos['smalltypes'])) {
  27. $smalltypes = explode(',', $refObj->TypeLink->TypeInfos['smalltypes']);
  28. }
  29. if (empty($refObj->Fields['typeid'])) {
  30. $row = $dsql->GetOne("SELECT id FROM `#@__arctype` WHERE channeltype='-8' And reid = '0' ");
  31. $typeid = (is_array($row) ? $row['id'] : 0);
  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(
  43. 'nativeplace' => '', 'infotype' => '', 'typeid' => $typeid,
  44. 'channelid' => $channelid, 'linkallplace' => '', 'linkalltype' => ''
  45. );
  46. $fields['nativeplace'] = $fields['infotype'] = '';
  47. $fields['linkallplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
  48. $fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
  49. //地区链接
  50. if (empty($nativeplace)) {
  51. foreach ($em_nativeplaces as $eid => $em) {
  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. } else {
  56. $sontype = (($nativeplace % 500 != 0) ? $nativeplace : 0);
  57. $toptype = (($nativeplace % 500 == 0) ? $nativeplace : ($nativeplace - ($nativeplace % 500)));
  58. $fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";
  59. foreach ($em_nativeplaces as $eid => $em) {
  60. if ($eid < $toptype + 1 || $eid > $toptype + 499) continue;
  61. if ($eid == $nativeplace) {
  62. $fields['nativeplace'] .= " <b>{$em}</b>\r\n";
  63. } else {
  64. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  65. }
  66. }
  67. }
  68. //小分类链接
  69. if (empty($infotype) || is_array($smalltypes)) {
  70. foreach ($em_infotypes as $eid => $em) {
  71. if (!is_array($smalltypes) && $eid % 500 != 0) continue;
  72. if (is_array($smalltypes) && !in_array($eid, $smalltypes)) continue;
  73. if ($eid == $infotype) {
  74. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  75. } else {
  76. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  77. }
  78. }
  79. } else {
  80. $sontype = (($infotype % 500 != 0) ? $infotype : 0);
  81. $toptype = (($infotype % 500 == 0) ? $infotype : ($infotype - ($infotype % 500)));
  82. $fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";
  83. foreach ($em_infotypes as $eid => $em) {
  84. if ($eid < $toptype + 1 || $eid > $toptype + 499) continue;
  85. if ($eid == $infotype) {
  86. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  87. } else {
  88. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  89. }
  90. }
  91. }
  92. if (is_array($ctp->CTags)) {
  93. foreach ($ctp->CTags as $tagid => $ctag) {
  94. if (isset($fields[$ctag->GetName()])) {
  95. $ctp->Assign($tagid, $fields[$ctag->GetName()]);
  96. }
  97. }
  98. $revalue .= $ctp->GetResult();
  99. }
  100. return $revalue;
  101. }