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

64 lines
2.1KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 文档内容调用标签
  5. *
  6. * @version $Id: arccontent.lib.php 2020年9月14日 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."/channelunit.class.php");
  13. //这是一个用来调用文档内容的标签,只是提供一种方法,不建议太多地方调用,毕竟比较损耗性能
  14. /*
  15. 用法:
  16. {dede:arccontent type='pre|next'}
  17. [field:body/]
  18. {/dede:arccontent}
  19. */
  20. function lib_arccontent(&$ctag, &$refObj)
  21. {
  22. global $dsql;
  23. $aid = $ctag->GetAtt('aid');
  24. $type = $ctag->GetAtt('type');
  25. $revalue = "";
  26. if (in_array($type, array("pre", "next")) && get_class($refObj) === "Archives") {
  27. //在内容页面获取上一篇下一篇内容
  28. $asql = "WHERE id<{$refObj->Fields['id']}";
  29. if ($type === "next") {
  30. $asql = "WHERE id>{$refObj->Fields['id']}";
  31. }
  32. $row = $dsql->GetOne("SELECT id,channel FROM `#@__arctiny` $asql AND arcrank>-1 AND typeid='{$refObj->Fields['typeid']}' ORDER BY id DESC");
  33. $channel = new ChannelUnit($row['channel'], $refObj->Fields['id']);
  34. $fields = $dsql->GetOne("SELECT * FROM `{$channel->ChannelInfos['addtable']}` WHERE aid = {$row['id']}");
  35. }
  36. if (!empty($aid)) {
  37. //指定ID获取内容
  38. $row = $dsql->GetOne("SELECT id,channel FROM `#@__arctiny` WHERE id={$aid} AND arcrank>-1");
  39. $channel = new ChannelUnit($row['channel'], $aid);
  40. $fields = $dsql->GetOne("SELECT * FROM `{$channel->ChannelInfos['addtable']}` WHERE aid = {$row['id']}");
  41. }
  42. $innerText = trim($ctag->GetInnerText());
  43. $ctp = new DedeTagParse();
  44. $ctp->SetNameSpace('field', '[', ']');
  45. $ctp->LoadSource($innerText);
  46. if (is_array($ctp->CTags)) {
  47. foreach ($ctp->CTags as $tagid => $ctag) {
  48. if (isset($fields[$ctag->GetName()])) {
  49. $ctp->Assign($tagid, $fields[$ctag->GetName()]);
  50. }
  51. }
  52. $revalue .= $ctp->GetResult();
  53. }
  54. return $revalue;
  55. }