From f8acad5b0e1d5cdb23f81cc317efb126ddd76021 Mon Sep 17 00:00:00 2001 From: sunhao Date: Fri, 21 Feb 2025 09:57:38 +0800 Subject: [PATCH] * [misc] add method to get doc content object. --- module/doc/model.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/module/doc/model.php b/module/doc/model.php index f43eb8c94c..a5e2372d22 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1213,6 +1213,27 @@ class docModel extends model return $this->processDoc($doc, (int)$version, $setImgSize); } + /** + * 通过文档ID和版本号获取文档内容,当 $version 为 0 时,获取文档的草稿内容。 + * Get doc content by docID and version, when $version is 0, get doc draft content. + * + * @param int $docID + * @param int $version + * @access public + * @return ?object + */ + public function getContent(int $docID, int $version): ?object + { + $docContent = $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->eq($docID)->andWhere('version')->eq($version)->fetch(); + if($docContent) + { + $docContent->title = htmlspecialchars_decode($docContent->title); + if(!empty($docContent->rawContent)) $docContent->rawContent = htmlspecialchars_decode($docContent->rawContent); + return $docContent; + } + return null; + } + /** * 处理文档数据。 * Process doc data.