Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions filter/PreprintCrossrefXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use APP\core\Request;
use APP\plugins\generic\crossref\CrossrefExportDeployment;
use APP\publication\Publication;
use PKP\context\Context;
use DOMDocument;
use PKP\core\Dispatcher;
use PKP\i18n\LocaleConversion;
Expand Down Expand Up @@ -66,10 +67,16 @@ public function &process(&$pubObjects)
$bodyNode = $doc->createElementNS($deployment->getNamespace(), 'body');
$rootNode->appendChild($bodyNode);

$doiVersioning = (bool) ($context->getData(Context::SETTING_DOI_VERSIONING) ?? true);
foreach ($pubObjects as $pubObject) {
$publications = $pubObject->getData('publications')->toArray();
// Use array reverse so that the latest version of the submission is first in the xml output and the DOI relations do not cause an error with Crossref
$publications = array_reverse($publications, true);
if (!$doiVersioning) {
$publications = [$pubObject->getCurrentPublication()];
} else {
$publications = $pubObject->getData('publications')->toArray();
// Use array reverse so that the latest version of the submission is first in the xml output and the DOI relations do not cause an error with Crossref
$publications = array_reverse($publications, true);
}

foreach ($publications as $publication) {
if ($publication->getDoi() && $publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
$postedContentNode = $this->createPostedContentNode($doc, $publication, $pubObject);
Expand Down Expand Up @@ -120,7 +127,8 @@ public function createHeadNode($doc)
$plugin = $deployment->getPlugin();
$headNode = $doc->createElementNS($deployment->getNamespace(), 'head');
$headNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'doi_batch_id', htmlspecialchars($context->getData('acronym', $context->getPrimaryLocale()) . '_' . time(), ENT_COMPAT, 'UTF-8')));
$headNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'timestamp', date('YmdHisv')));
$timestamp = (new \DateTime())->format('YmdHisv');
$headNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'timestamp', $timestamp));
$depositorNode = $doc->createElementNS($deployment->getNamespace(), 'depositor');
$depositorName = $plugin->getSetting($context->getId(), 'depositorName');
if (empty($depositorName)) {
Expand Down