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

  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. //2011-6-21 修改地区列表的一个小空格 论坛http://bbs.dedecms.com/371492.html(by:织梦的鱼)
  72. $fields['nativeplace'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> <b>{$em_nativeplaces[$toptype]}</b></a> &gt;&gt; ";
  73. foreach($em_nativeplaces as $eid=>$em)
  74. {
  75. if($eid < $toptype+1 || $eid > $toptype+499) continue;
  76. if($eid == $nativeplace) {
  77. $fields['nativeplace'] .= " <b>{$em}</b>\r\n";
  78. }
  79. else {
  80. $fields['nativeplace'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
  81. }
  82. }
  83. }
  84. //小分类链接
  85. if(empty($infotype) || is_array($smalltypes))
  86. {
  87. foreach($em_infotypes as $eid=>$em)
  88. {
  89. if(!is_array($smalltypes) && $eid % 500 != 0) continue;
  90. if(is_array($smalltypes) && !in_array($eid, $smalltypes)) continue;
  91. if($eid == $infotype)
  92. {
  93. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  94. }
  95. else {
  96. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  97. }
  98. }
  99. }
  100. else
  101. {
  102. $sontype = ( ($infotype % 500 != 0) ? $infotype : 0 );
  103. $toptype = ( ($infotype % 500 == 0) ? $infotype : ( $infotype-($infotype%500) ) );
  104. $fields['infotype'] .= "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'><b>{$em_infotypes[$toptype]}</b></a> &gt;&gt; ";
  105. foreach($em_infotypes as $eid=>$em)
  106. {
  107. if($eid < $toptype+1 || $eid > $toptype+499) continue;
  108. if($eid == $infotype) {
  109. $fields['infotype'] .= " <b>{$em}</b>\r\n";
  110. }
  111. else {
  112. $fields['infotype'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
  113. }
  114. }
  115. }
  116. if(is_array($ctp->CTags))
  117. {
  118. foreach($ctp->CTags as $tagid=>$ctag)
  119. {
  120. if(isset($fields[$ctag->GetName()])) {
  121. $ctp->Assign($tagid,$fields[$ctag->GetName()]);
  122. }
  123. }
  124. $revalue .= $ctp->GetResult();
  125. }
  126. return $revalue;
  127. }