Merge branch dev/task-145417 of zentao/zentaopms (#9693)
This commit is contained in:
@@ -2317,7 +2317,7 @@ class doc extends control
|
||||
$doc->module = (int)$doc->module;
|
||||
$doc->privs = array('edit' => common::hasPriv('doc', 'edit', $doc) && $doc->acl == 'open');
|
||||
$doc->editors = $this->doc->getEditors($docID);
|
||||
$doc->draft = $this->doc->getDraft($docID);
|
||||
$doc->draft = $doc->status == 'draft' ? $this->doc->getContent($docID, $version) : null;
|
||||
|
||||
$lib = $this->doc->getLibByID((int)$doc->lib);
|
||||
$objectType = $lib->type;
|
||||
|
||||
@@ -1152,19 +1152,6 @@ class docModel extends model
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档草稿。
|
||||
* Get doc draft.
|
||||
*
|
||||
* @param int $docID 文档ID
|
||||
* @access public
|
||||
* @return ?object
|
||||
*/
|
||||
public function getDraft(int $docID): ?object
|
||||
{
|
||||
return $this->getContent($docID, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文档数据。
|
||||
* Process doc data.
|
||||
|
||||
@@ -1883,4 +1883,18 @@ class docTest
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档内容。
|
||||
* Get document content test.
|
||||
*
|
||||
* @param int $docID
|
||||
* @param int $version
|
||||
* @access public
|
||||
* @return object|null
|
||||
*/
|
||||
public function getContentTest(int $docID, int $version): object|null
|
||||
{
|
||||
return $this->objectModel->getContent($docID, $version);
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 docModel->getContent();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 获取docID=1、版本为1的文档内容
|
||||
- 属性doc @1
|
||||
- 属性version @1
|
||||
- 属性title @文档标题1
|
||||
- 获取docID=2、版本为1的文档内容
|
||||
- 属性doc @2
|
||||
- 属性version @1
|
||||
- 属性title @文档标题2
|
||||
- 获取docID=1、版本为2的文档内容为空 @0
|
||||
- 获取docID=2、版本为2的文档内容为空 @0
|
||||
- 获取不存在的文档内容 @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php';
|
||||
|
||||
zenData('doc')->loadYaml('doc')->gen(5);
|
||||
zenData('doccontent')->loadYaml('doccontent')->gen(5);
|
||||
|
||||
$docIDList = array('1', '2', '6');
|
||||
$versionList = array('1', '2');
|
||||
|
||||
$docTester = new docTest();
|
||||
r($docTester->getContentTest($docIDList[0], $versionList[0])) && p('doc,version,title') && e('1,1,文档标题1'); // 获取docID=1、版本为1的文档内容
|
||||
r($docTester->getContentTest($docIDList[1], $versionList[0])) && p('doc,version,title') && e('2,1,文档标题2'); // 获取docID=2、版本为1的文档内容
|
||||
r($docTester->getContentTest($docIDList[0], $versionList[1])) && p() && e(0); // 获取docID=1、版本为2的文档内容为空
|
||||
r($docTester->getContentTest($docIDList[1], $versionList[1])) && p() && e(0); // 获取docID=2、版本为2的文档内容为空
|
||||
r($docTester->getContentTest($docIDList[2], $versionList[0])) && p() && e(0); // 获取不存在的文档内容
|
||||
Reference in New Issue
Block a user