国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
7.1KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 关联文档标签
  5. *
  6. * @version $id:relation.lib.php 9:29 2020年9月23日 tianya $
  7. * @package DedeBIZ.Taglib
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. function lib_relation(&$ctag, &$refObj)
  13. {
  14. global $dsql;
  15. <<<<<<< Updated upstream
  16. $attlist = "row|10,titlelen|30,infolen|160,name|default,orderby|";
  17. =======
  18. $attlist = "row|10,titlelen|30,infolen|150,name|default,orderby|";
  19. >>>>>>> Stashed changes
  20. FillAttsDefault($ctag->CAttribute->Items, $attlist);
  21. extract($ctag->CAttribute->Items, EXTR_SKIP);
  22. if (get_class($refObj) != "Archives") {
  23. return "暂无相关文档";
  24. }
  25. if (empty($refObj->Fields[$name])) {
  26. return "暂无相关文档";
  27. }
  28. if (!isset($refObj->ChannelUnit->ChannelFields[$name])) {
  29. return "暂无相关文档";
  30. }
  31. if (empty($tablewidth)) $tablewidth = 100;
  32. if (empty($col)) $col = 1;
  33. $colWidth = ceil(100 / $col);
  34. $tablewidth = $tablewidth."%";
  35. $colWidth = $colWidth."%";
  36. $ids = array();
  37. $channelid = $refObj->ChannelUnit->ChannelFields[$name]["channel"];
  38. $odb = '';
  39. if ($channelid > 0) {
  40. $odb = " ORDER BY arc.sortrank DESC";
  41. } else {
  42. $odb = " ORDER BY arc.senddate DESC";
  43. }
  44. if ($orderby == "click") {
  45. $odb = " ORDER BY arc.click DESC";
  46. }
  47. if ($channelid > 0) {
  48. $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.arcrank>-1 AND arc.id IN (".$refObj->Fields[$name].") $odb";
  49. } else {
  50. $gquery = "SELECT addtable,listfields FROM `#@__channeltype` WHERE id='$channelid' ";
  51. $grow = $dsql->GetOne($gquery);
  52. $maintable = trim($grow['addtable']);
  53. $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `{$maintable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.arcrank>-1 AND arc.aid IN (".$refObj->Fields[$name].") $odb";
  54. }
  55. $innertext = trim($ctag->GetInnerText());
  56. if ($innertext == '') $innertext = GetSysTemplets('part_arclist.htm');
  57. $dsql->SetQuery($query);
  58. $dsql->Execute('al');
  59. $artlist = '';
  60. if ($col > 1) {
  61. $artlist = "<table width='$tablewidth'>\r\n";
  62. }
  63. $dtp2 = new DedeTagParse();
  64. $dtp2->SetNameSpace('field', '[', ']');
  65. $dtp2->LoadString($innertext);
  66. $GLOBALS['autoindex'] = 0;
  67. $line = $row;
  68. for ($i = 0; $i < $line; $i++) {
  69. if ($col > 1) $artlist .= "<tr>\r\n";
  70. for ($j = 0; $j < $col; $j++) {
  71. if ($col > 1) $artlist .= "<td width='$colWidth'>\r\n";
  72. if ($row = $dsql->GetArray("al")) {
  73. if ($channelid > 0) {
  74. $row['aid'] = $row['id'];
  75. } else {
  76. $row['id'] = $row['aid'];
  77. }
  78. $ids[] = $row['id'];
  79. $row['description'] = isset($row['description']) ? $row['description'] : "";
  80. $row['filename'] = isset($row['filename']) ? $row['filename'] : "";
  81. $row['money'] = isset($row['money']) ? $row['money'] : 0;
  82. $row['ismake'] = isset($row['ismake']) ? $row['ismake'] : 0;
  83. //处理一些特殊字段
  84. $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
  85. if ($row['corank'] > 0 && $row['arcrank'] == 0) {
  86. $row['arcrank'] = $row['corank'];
  87. }
  88. $row['filename'] = $row['arcurl'] = GetFileUrl(
  89. $row['id'],
  90. $row['typeid'],
  91. $row['senddate'],
  92. $row['title'],
  93. $row['ismake'],
  94. $row['arcrank'],
  95. $row['namerule'],
  96. $row['typedir'],
  97. $row['money'],
  98. $row['filename'],
  99. $row['moresite'],
  100. $row['siteurl'],
  101. $row['sitepath']
  102. );
  103. $row['typeurl'] = GetTypeUrl(
  104. $row['typeid'],
  105. $row['typedir'],
  106. $row['isdefault'],
  107. $row['defaultname'],
  108. $row['ispart'],
  109. $row['namerule2'],
  110. $row['moresite'],
  111. $row['siteurl'],
  112. $row['sitepath']
  113. );
  114. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  115. $row['litpic'] = '/static/web/img/thumbnail.jpg';
  116. }
  117. if (!preg_match("#^(http|https):\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  118. $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
  119. }
  120. $row['picname'] = $row['litpic'];
  121. $row['pubdate'] = isset($row['pubdate']) ? $row['pubdate'] : $row['senddate'];
  122. $row['stime'] = GetDateMK($row['pubdate']);
  123. $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
  124. $row['image'] = "<img src='".$row['picname']."' title='".preg_replace("#['><]#", "", $row['title'])."'>";
  125. $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
  126. $row['fulltitle'] = $row['title'];
  127. $row['title'] = cn_substr($row['title'], $titlelen);
  128. if (isset($row['color']) && $row['color'] != '') $row['title'] = "<span style='color:".$row['color']."'>".$row['title']."</span>";
  129. if (preg_match('#b#', $row['flag'])) $row['title'] = "".$row['title']."";
  130. $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
  131. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  132. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  133. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  134. if (is_array($dtp2->CTags)) {
  135. foreach ($dtp2->CTags as $k => $ctag) {
  136. if ($ctag->GetName() == 'array') {
  137. $dtp2->Assign($k, $row);
  138. } else {
  139. if (isset($row[$ctag->GetName()])) $dtp2->Assign($k, $row[$ctag->GetName()]);
  140. else $dtp2->Assign($k, '');
  141. }
  142. }
  143. $GLOBALS['autoindex']++;
  144. }
  145. $artlist .= $dtp2->GetResult()."\r\n";
  146. }
  147. //if hasRow
  148. else {
  149. $artlist .= '';
  150. }
  151. if ($col > 1) $artlist .= "</td>\r\n";
  152. }
  153. //Loop Col
  154. if ($col > 1) $i += $col - 1;
  155. if ($col > 1) $artlist .= "</tr>\r\n";
  156. }
  157. //loop line
  158. if ($col > 1) $artlist .= "</table>\r\n";
  159. $dsql->FreeResult("al");
  160. return $artlist;
  161. }
  162. ?>