参考文献格式
This commit is contained in:
@@ -470,39 +470,52 @@ class CrossrefService
|
||||
*/
|
||||
public function getPublishYear($aDoiInfo = [])
|
||||
{
|
||||
if (!empty($aDoiInfo['issued']['date-parts'][0][0])) {
|
||||
return (string)$aDoiInfo['issued']['date-parts'][0][0];
|
||||
// 著录用的是期次年。issued 取线上/线下较早者,在线优先出版的文献会偏早一年,
|
||||
// 因此先看 published-print,再回退 issued。
|
||||
$candidates = [
|
||||
$aDoiInfo['published-print']['date-parts'][0][0] ?? null,
|
||||
$aDoiInfo['journal-issue']['published-print']['date-parts'][0][0] ?? null,
|
||||
$aDoiInfo['issued']['date-parts'][0][0] ?? null,
|
||||
$aDoiInfo['published']['date-parts'][0][0] ?? null,
|
||||
$aDoiInfo['published-online']['date-parts'][0][0] ?? null,
|
||||
];
|
||||
|
||||
foreach ($candidates as $year) {
|
||||
if (!empty($year)) {
|
||||
return (string)$year;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取卷(期):起始页-终止页(格式:2024:10(2):100-120)
|
||||
* 著录用的年卷期页,格式 Year;Volume(Issue):Pages(如 2024;10(2):100-120)
|
||||
*/
|
||||
public function getVolumeIssuePages($aDoiInfo = [])
|
||||
{
|
||||
$parts = [];
|
||||
|
||||
$year = $this->getPublishYear($aDoiInfo);
|
||||
if ($year) $parts[] = $year;
|
||||
|
||||
$volume = $aDoiInfo['volume'] ?? '';
|
||||
$issue = $aDoiInfo['issue'] ?? '';
|
||||
if ($volume) {
|
||||
$parts[] = $volume . ($issue ? "({$issue})" : '');
|
||||
$volume = trim((string)($aDoiInfo['volume'] ?? ''));
|
||||
$issue = trim((string)($aDoiInfo['issue'] ?? ($aDoiInfo['journal-issue']['issue'] ?? '')));
|
||||
if ($volume !== '') {
|
||||
$volume .= $issue !== '' ? "({$issue})" : '';
|
||||
}
|
||||
|
||||
$pageStart = $aDoiInfo['page']['start'] ?? ($aDoiInfo['first-page'] ?? '');
|
||||
$pageEnd = $aDoiInfo['page']['end'] ?? ($aDoiInfo['last-page'] ?? '');
|
||||
$pages = '';
|
||||
if ($pageStart) {
|
||||
$pages = $pageStart . ($pageEnd ? "-{$pageEnd}" : '');
|
||||
} else {
|
||||
$pages = $aDoiInfo['page'] ?? '';
|
||||
// page 是 "100-120" 这样的字符串;BMC/PLOS 等电子刊无连续页码,改用文章号
|
||||
$pages = trim((string)($aDoiInfo['page'] ?? ''));
|
||||
if ($pages === '') {
|
||||
$pages = trim((string)($aDoiInfo['article-number'] ?? ''));
|
||||
}
|
||||
if ($pages) $parts[] = $pages;
|
||||
|
||||
return implode(':', $parts);
|
||||
$tail = $volume;
|
||||
if ($pages !== '') {
|
||||
$tail = $tail !== '' ? $tail . ':' . $pages : $pages;
|
||||
}
|
||||
|
||||
if ($year === '' || $tail === '') {
|
||||
return $year !== '' ? $year : $tail;
|
||||
}
|
||||
return $year . ';' . $tail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user