国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

189 líneas
9.1KB

  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 is_str_float($value){
  24. return ((int)$value != $value) ;
  25. }
  26. function lib_infolink(&$ctag, &$refObj)
  27. {
  28. global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite;
  29. global $em_nativeplaces, $em_infotypes;
  30. //属性处理
  31. //$attlist="row|12,titlelen|24";
  32. //FillAttsDefault($ctag->CAttribute->Items,$attlist);
  33. //extract($ctag->CAttribute->Items, EXTR_SKIP);
  34. $cmspath = ((empty($cfg_cmspath) || !preg_match("#\/$#", $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath);
  35. $baseurl = preg_replace("#\/$#", '', $cfg_mainsite).$cmspath;
  36. $smalltypes = '';
  37. if (!empty($refObj->TypeLink->TypeInfos['smalltypes'])) {
  38. $smalltypes = explode(',', $refObj->TypeLink->TypeInfos['smalltypes']);
  39. }
  40. if (empty($refObj->Fields['typeid'])) {
  41. $row = $dsql->GetOne("SELECT id FROM `#@__arctype` WHERE channeltype='-8' And reid = '0' ");
  42. $typeid = (is_array($row) ? $row['id'] : 0);
  43. } else {
  44. $typeid = $refObj->Fields['typeid'];
  45. }
  46. $innerText = trim($ctag->GetInnerText());
  47. if (empty($innerText)) $innerText = GetSysTemplets("info_link.htm");
  48. $ctp = new DedeTagParse();
  49. $ctp->SetNameSpace('field', '[', ']');
  50. $ctp->LoadSource($innerText);
  51. $revalue = $seli = '';
  52. $channelid = (empty($refObj->TypeLink->TypeInfos['channeltype']) ? -8 : $refObj->TypeLink->TypeInfos['channeltype']);
  53. $fields = array(
  54. 'nativeplace' => '', 'infotype' => '', 'typeid' => $typeid,
  55. 'channelid' => $channelid, 'linkallplace' => '', 'linkalltype' => ''
  56. );
  57. $fields['nativeplace'] = $fields['infotype'] = '';
  58. $fields['linkallplace'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
  59. $fields['linkalltype'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
  60. //地区链接
  61. if (empty($nativeplace)) {
  62. foreach ($em_nativeplaces as $eid => $em) {
  63. if ($eid % 500 != 0) continue;
  64. $fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  65. }
  66. } else {
  67. $sontype = (($nativeplace % 500 != 0) ? $nativeplace : 0); // 子集
  68. $toptype = (($nativeplace % 500 == 0) ? (int)$nativeplace : (int)($nativeplace - ($nativeplace % 500))); // 顶级联动分类
  69. $fields['nativeplace'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> {$em_nativeplaces[$toptype]}</a> &gt;";
  70. if ($nativeplace % 500 == 0) {
  71. // 1级分类
  72. foreach ($em_nativeplaces as $eid => $em) {
  73. if ($eid < $toptype + 1 || $eid > $toptype + 499) continue;
  74. if (is_str_float($eid)) continue; // 仅显示2级
  75. if ($eid == $nativeplace) {
  76. $fields['nativeplace'] .= " {$em}\r\n";
  77. } else {
  78. $fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  79. }
  80. }
  81. } else if(!is_str_float($nativeplace)) {
  82. // 2级分类
  83. $fields['nativeplace'] .= "<span> {$em_nativeplaces[$sontype]}</span>";
  84. $i = 0;
  85. $ff = "";
  86. foreach ($em_nativeplaces as $eid => $em) {
  87. if ($eid < $sontype + 1 && $eid > $sontype)
  88. {
  89. if (is_str_float($eid)) {
  90. $i++;
  91. }
  92. if ($eid === $nativeplace) {
  93. $ff .= " {$em}\r\n";
  94. } else {
  95. $ff .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  96. }
  97. }
  98. }
  99. if($i > 0) $fields['nativeplace'] .= " &gt; ";
  100. $fields['nativeplace'] .= $ff;
  101. } else {
  102. // 3级分类
  103. $t = intval($nativeplace);
  104. $fields['nativeplace'] .= "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$t}&infotype={$infotype}'> {$em_nativeplaces[$t]}</a> &gt;";
  105. foreach ($em_nativeplaces as $eid => $em) {
  106. if ($eid < $t + 1 && $eid > $t)
  107. {
  108. if ($eid === $nativeplace) {
  109. $fields['nativeplace'] .= " {$em}\r\n";
  110. } else {
  111. $fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  112. }
  113. }
  114. }
  115. }
  116. }
  117. //小分类链接
  118. if (empty($infotype) || is_array($smalltypes)) {
  119. foreach ($em_infotypes as $eid => $em) {
  120. if (!is_array($smalltypes) && $eid % 500 != 0) continue;
  121. if (is_array($smalltypes) && !in_array($eid, $smalltypes)) continue;
  122. if ($eid == $infotype) {
  123. $fields['infotype'] .= " {$em}\r\n";
  124. } else {
  125. $fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  126. }
  127. }
  128. } else {
  129. $sontype = (($infotype % 500 != 0) ? $infotype : 0);
  130. $toptype = (($infotype % 500 == 0) ? (int)$infotype : (int)($infotype - ($infotype % 500)));
  131. $fields['infotype'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'>{$em_infotypes[$toptype]}</a> &gt; ";
  132. if ($infotype % 500 == 0) {
  133. // 1级分类
  134. foreach ($em_infotypes as $eid => $em) {
  135. if ($eid < $toptype + 1 || $eid > $toptype + 499) continue;
  136. if (is_str_float($eid)) continue; // 仅显示2级
  137. if ($eid == $infotype) {
  138. $fields['infotype'] .= " {$em}\r\n";
  139. } else {
  140. $fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
  141. }
  142. }
  143. } else if(!is_str_float($infotype)) {
  144. // 2级分类
  145. $fields['infotype'] .= "<span> {$em_infotypes[$sontype]}</span>";
  146. $i = 0;
  147. $ff = "";
  148. foreach ($em_infotypes as $eid => $em) {
  149. if ($eid < $sontype + 1 && $eid > $sontype)
  150. {
  151. if (is_str_float($eid)) {
  152. $i++;
  153. }
  154. if ($eid === $infotype) {
  155. $ff .= " {$em}\r\n";
  156. } else {
  157. $ff .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
  158. }
  159. }
  160. }
  161. if($i > 0) $fields['infotype'] .= " &gt; ";
  162. $fields['infotype'] .= $ff;
  163. } else {
  164. // 3级分类
  165. $t = intval($infotype);
  166. $fields['infotype'] .= "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$t}'> {$em_infotypes[$t]}</a> &gt;";
  167. foreach ($em_infotypes as $eid => $em) {
  168. if ($eid < $t + 1 && $eid > $t)
  169. {
  170. if ($eid === $infotype) {
  171. $fields['infotype'] .= " {$em}\r\n";
  172. } else {
  173. $fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
  174. }
  175. }
  176. }
  177. }
  178. }
  179. if (is_array($ctp->CTags)) {
  180. foreach ($ctp->CTags as $tagid => $ctag) {
  181. if (isset($fields[$ctag->GetName()])) {
  182. $ctp->Assign($tagid, $fields[$ctag->GetName()]);
  183. }
  184. }
  185. $revalue .= $ctp->GetResult();
  186. }
  187. return $revalue;
  188. }