国内流行的内容管理系统(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 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 DedeBIZ.Taglib
  7. * @copyright Copyright (c) 2021, 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. } else {
  32. $typeid = $refObj->Fields['typeid'];
  33. }
  34. $innerText = trim($ctag->GetInnerText());
  35. if (empty($innerText)) $innerText = GetSysTemplets("info_link.htm");
  36. $ctp = new DedeTagParse();
  37. $ctp->SetNameSpace('field', '[', ']');
  38. $ctp->LoadSource($innerText);
  39. $revalue = $seli = '';
  40. $channelid = (empty($refObj->TypeLink->TypeInfos['channeltype']) ? -8 : $refObj->TypeLink->TypeInfos['channeltype']);
  41. $fields = array(
  42. 'nativeplace' => '', 'infotype' => '', 'typeid' => $typeid,
  43. 'channelid' => $channelid, 'linkallplace' => '', 'linkalltype' => ''
  44. );
  45. $fields['nativeplace'] = $fields['infotype'] = '';
  46. $fields['linkallplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
  47. $fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
  48. //地区链接
  49. if (empty($nativeplace)) {
  50. foreach ($em_nativeplaces as $eid => $em) {
  51. if ($eid % 500 != 0) continue;
  52. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  53. }
  54. } else {
  55. $sontype = (($nativeplace % 500 != 0) ? $nativeplace : 0);
  56. $toptype = (($nativeplace % 500 == 0) ? $nativeplace : ($nativeplace - ($nativeplace % 500)));
  57. $fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";
  58. foreach ($em_nativeplaces as $eid => $em) {
  59. if ($eid < $toptype + 1 || $eid > $toptype + 499) continue;
  60. if ($eid == $nativeplace) {
  61. $fields['nativeplace'] .= " <b>{$em}</b>\r\n";
  62. } else {
  63. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  64. }
  65. }
  66. }
  67. //小分类链接
  68. if (empty($infotype) || is_array($smalltypes)) {
  69. foreach ($em_infotypes as $eid => $em) {
  70. if (!is_array($smalltypes) && $eid % 500 != 0) continue;
  71. if (is_array($smalltypes) && !in_array($eid, $smalltypes)) continue;
  72. if ($eid == $infotype) {
  73. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  74. } else {
  75. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  76. }
  77. }
  78. } else {
  79. $sontype = (($infotype % 500 != 0) ? $infotype : 0);
  80. $toptype = (($infotype % 500 == 0) ? $infotype : ($infotype - ($infotype % 500)));
  81. $fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";
  82. foreach ($em_infotypes as $eid => $em) {
  83. if ($eid < $toptype + 1 || $eid > $toptype + 499) continue;
  84. if ($eid == $infotype) {
  85. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  86. } else {
  87. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  88. }
  89. }
  90. }
  91. if (is_array($ctp->CTags)) {
  92. foreach ($ctp->CTags as $tagid => $ctag) {
  93. if (isset($fields[$ctag->GetName()])) {
  94. $ctp->Assign($tagid, $fields[$ctag->GetName()]);
  95. }
  96. }
  97. $revalue .= $ctp->GetResult();
  98. }
  99. return $revalue;
  100. }