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

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