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

111 lines
5.4KB

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