From 4f1391a52b021d842129bfbb259705056129b744 Mon Sep 17 00:00:00 2001 From: Dimitris Efstathiou Date: Mon, 4 Dec 2023 20:40:08 +0200 Subject: [PATCH] pkp/pkp-lib#7505 Take into account the passed publication and not only the currentPublication object of submission --- classes/Article.php | 10 ++++++++-- classes/ArticleFront.php | 15 +++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/classes/Article.php b/classes/Article.php index ab0caf3..2a248a5 100644 --- a/classes/Article.php +++ b/classes/Article.php @@ -14,7 +14,13 @@ namespace APP\plugins\generic\jatsTemplate\classes; use APP\core\Application; +use APP\issue\Issue; +use APP\publication\Publication; +use APP\section\Section; +use APP\submission\Submission; use DOMException; +use PKP\context\Context; +use PKP\core\PKPRequest; use PKP\oai\OAIRecord; class Article extends \DOMDocument @@ -42,7 +48,7 @@ public function convertOAIToXml(OAIRecord $record): void /** * Convert submission metadata to JATS XML */ - public function convertSubmission($submission, $context, $section, $issue, $publication, $request): void + public function convertSubmission(Submission $submission, Context $context, Section $section, ?Issue $issue = null, ?Publication $publication = null, PKPRequest $request): void { $articleElement = $this->appendChild($this->createElement('article')) ->setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink')->parentNode @@ -51,7 +57,7 @@ public function convertSubmission($submission, $context, $section, $issue, $publ ->setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance')->parentNode; $articleFront = new ArticleFront(); - $articleElement->appendChild($this->importNode($articleFront->create($context, $submission, $section, $issue, $request, $this), true)); + $articleElement->appendChild($this->importNode($articleFront->create($context, $submission, $section, $issue, $request, $this, $publication), true)); $articleBody = new ArticleBody(); $articleElement->appendChild($this->importNode($articleBody->create($submission), true)); diff --git a/classes/ArticleFront.php b/classes/ArticleFront.php index 3deac54..f5b79a2 100644 --- a/classes/ArticleFront.php +++ b/classes/ArticleFront.php @@ -34,12 +34,12 @@ class ArticleFront extends \DOMDocument /** * Create article front element */ - public function create(Journal $journal, Submission $submission, Section $section, ?Issue $issue, PKPRequest $request, Article $article): \DOMNode + public function create(Journal $journal, Submission $submission, Section $section, ?Issue $issue, PKPRequest $request, Article $article, ?Publication $workingPublication = null): \DOMNode { return $this->appendChild($this->createElement('front')) ->appendChild($this->createJournalMeta($journal, $request)) ->parentNode - ->appendChild($this->createArticleMeta($submission, $journal, $section, $issue, $request, $article)) + ->appendChild($this->createArticleMeta($submission, $journal, $section, $issue, $request, $article, $workingPublication)) ->parentNode; } @@ -132,9 +132,12 @@ public function createJournalMetaJournalTitleGroup(Journal $journal): \DOMNode /** * Create xml article-meta DOMNode */ - function createArticleMeta(Submission $submission, Journal $journal, Section $section, ?Issue $issue, $request, Article $article) + function createArticleMeta(Submission $submission, Journal $journal, Section $section, ?Issue $issue, $request, Article $article, ?Publication $workingPublication = null) { $publication = $submission->getCurrentPublication(); + if ($workingPublication) { + $publication = $workingPublication; + } $articleMetaElement = $this->appendChild($this->createElement('article-meta')); @@ -250,9 +253,9 @@ function createArticleMeta(Submission $submission, Journal $journal, Section $se $pageCount = $matchedPageTo - $matchedPageFrom + 1; } - $copyrightYear = $submission->getCopyrightYear(); - $copyrightHolder = $submission->getLocalizedCopyrightHolder(); - $licenseUrl = $submission->getLicenseURL(); + $copyrightYear = $publication->getData('copyrightYear'); + $copyrightHolder = $publication->getLocalizedData('copyrightHolder'); + $licenseUrl = $publication->getData('licenseUrl'); $ccBadge = Application::get()->getCCLicenseBadge($licenseUrl, $submission->getLocale())=== null?'':Application::get()->getCCLicenseBadge($licenseUrl, $submission->getLocale()); if ($copyrightYear || $copyrightHolder || $licenseUrl || $ccBadge) { $permissionsElement = $articleMetaElement->appendChild($this->createElement('permissions'));