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

144 lines
5.6KB

  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) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. /*>>dede>>
  12. <name>分类信息地区与类型快捷链接</name>
  13. <type>全局标记</type>
  14. <for>V55,V56,V57</for>
  15. <description>调用分类信息地区与类型快捷链接</description>
  16. <demo>
  17. {dede:infolink /}
  18. </demo>
  19. <attributes>
  20. </attributes>
  21. >>dede>>*/
  22. require_once(DEDEINC.'/enums.func.php');
  23. require_once(DEDEDATA.'/enums/nativeplace.php');
  24. require_once(DEDEDATA.'/enums/infotype.php');
  25. function lib_infolink(&$ctag,&$refObj)
  26. {
  27. global $dsql,$nativeplace,$infotype,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite;
  28. global $em_nativeplaces,$em_infotypes;
  29. //属性处理
  30. //$attlist="row|12,titlelen|24";
  31. //FillAttsDefault($ctag->CAttribute->Items,$attlist);
  32. //extract($ctag->CAttribute->Items, EXTR_SKIP);
  33. $cmspath = ( (empty($cfg_cmspath) || !preg_match("#\/$#", $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath );
  34. $baseurl = preg_replace("#\/$#", '', $cfg_mainsite).$cmspath;
  35. $smalltypes = '';
  36. if( !empty($refObj->TypeLink->TypeInfos['smalltypes']) ) {
  37. $smalltypes = explode(',', $refObj->TypeLink->TypeInfos['smalltypes']);
  38. }
  39. if(empty($refObj->Fields['typeid'])) {
  40. $row = $dsql->GetOne("SELECT id FROM `#@__arctype` WHERE channeltype='-8' And reid = '0' ");
  41. $typeid = (is_array($row) ? $row['id'] : 0);
  42. }
  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('nativeplace'=>'','infotype'=>'','typeid'=>$typeid,
  54. 'channelid'=>$channelid,'linkallplace'=>'','linkalltype'=>'');
  55. $fields['nativeplace'] = $fields['infotype'] = '';
  56. $fields['linkallplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
  57. $fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
  58. //地区链接
  59. if(empty($nativeplace))
  60. {
  61. foreach($em_nativeplaces as $eid=>$em)
  62. {
  63. if($eid % 500 != 0) continue;
  64. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  65. }
  66. }
  67. else
  68. {
  69. $sontype = ( ($nativeplace % 500 != 0) ? $nativeplace : 0 );
  70. $toptype = ( ($nativeplace % 500 == 0) ? $nativeplace : ( $nativeplace-($nativeplace%500) ) );
  71. $fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";
  72. foreach($em_nativeplaces as $eid=>$em)
  73. {
  74. if($eid < $toptype+1 || $eid > $toptype+499) continue;
  75. if($eid == $nativeplace) {
  76. $fields['nativeplace'] .= " <b>{$em}</b>\r\n";
  77. }
  78. else {
  79. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  80. }
  81. }
  82. }
  83. //小分类链接
  84. if(empty($infotype) || is_array($smalltypes))
  85. {
  86. foreach($em_infotypes as $eid=>$em)
  87. {
  88. if(!is_array($smalltypes) && $eid % 500 != 0) continue;
  89. if(is_array($smalltypes) && !in_array($eid, $smalltypes)) continue;
  90. if($eid == $infotype)
  91. {
  92. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  93. }
  94. else {
  95. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  96. }
  97. }
  98. }
  99. else
  100. {
  101. $sontype = ( ($infotype % 500 != 0) ? $infotype : 0 );
  102. $toptype = ( ($infotype % 500 == 0) ? $infotype : ( $infotype-($infotype%500) ) );
  103. $fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";
  104. foreach($em_infotypes as $eid=>$em)
  105. {
  106. if($eid < $toptype+1 || $eid > $toptype+499) continue;
  107. if($eid == $infotype) {
  108. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  109. }
  110. else {
  111. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  112. }
  113. }
  114. }
  115. if(is_array($ctp->CTags))
  116. {
  117. foreach($ctp->CTags as $tagid=>$ctag)
  118. {
  119. if(isset($fields[$ctag->GetName()])) {
  120. $ctp->Assign($tagid,$fields[$ctag->GetName()]);
  121. }
  122. }
  123. $revalue .= $ctp->GetResult();
  124. }
  125. return $revalue;
  126. }