From 213a52e16aa1be1eaa5944fb92a8ec007aaa9a7e Mon Sep 17 00:00:00 2001 From: jyhein <124268211+jyhein@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:17:08 +0200 Subject: [PATCH 1/2] pkp/pkp-lib#5000 Remove separate Dublin Core Language metadata field and only use Submission Locale to define the language --- .../dc11/filter/Dc11SchemaPreprintAdapter.php | 22 ++++++------------- .../dc/tests/OAIMetadataFormat_DCTest.php | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/plugins/metadata/dc11/filter/Dc11SchemaPreprintAdapter.php b/plugins/metadata/dc11/filter/Dc11SchemaPreprintAdapter.php index c9aa1ea146..62f060cb11 100644 --- a/plugins/metadata/dc11/filter/Dc11SchemaPreprintAdapter.php +++ b/plugins/metadata/dc11/filter/Dc11SchemaPreprintAdapter.php @@ -28,7 +28,6 @@ use APP\submission\Submission; use PKP\db\DAORegistry; use PKP\facades\Locale; -use PKP\i18n\LocaleConversion; use PKP\metadata\MetadataDataObjectAdapter; use PKP\metadata\MetadataDescription; use PKP\plugins\Hook; @@ -59,6 +58,7 @@ public function &injectMetadataIntoDataObject(&$metadataDescription, &$targetDat * @param Submission $submission * * @return MetadataDescription + * * @hook Dc11SchemaPreprintAdapter::extractMetadataFromDataObject [[$this, $submission, $server, &$dc11Description]] */ public function &extractMetadataFromDataObject(&$submission) @@ -145,20 +145,12 @@ public function &extractMetadataFromDataObject(&$submission) $dc11Description->addStatement('dc:identifier', $request->url($server->getPath(), 'preprint', 'view', [$submission->getBestId()])); // Language - $locales = []; - foreach ($galleys as $galley) { - $galleyLocale = $galley->getLocale(); - if (!is_null($galleyLocale) && !in_array($galleyLocale, $locales)) { - $locales[] = $galleyLocale; - $dc11Description->addStatement('dc:language', LocaleConversion::getIso3FromLocale($galleyLocale)); - } - } - $submissionLanguages = $submission->getLanguage(); - if (empty($locales) && isset($submissionLanguages[$submission->getLocale()])) { - foreach ($submissionLanguages[$submission->getLocale()] as $language) { - $dc11Description->addStatement('dc:language', $language); - } - } + collect($galleys) + ->map(fn ($g) => $g->getData('locale')) + ->push($publication->getData('locale')) + ->filter() + ->unique() + ->each(fn ($l) => $dc11Description->addStatement('dc:language', $l)); // Relation // full text URLs diff --git a/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php b/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php index f5469b2441..f6296ca346 100755 --- a/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php +++ b/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php @@ -101,7 +101,6 @@ public function testToXml() $publication->setData('abstract', 'preprint-abstract', 'en'); $publication->setData('sponsor', 'preprint-sponsor', 'en'); $publication->setData('doiObject', $publicationDoiObject); - $publication->setData('languages', ['en' => ['en']]); $publication->setData('copyrightHolder', 'preprint-copyright'); $publication->setData('copyrightYear', 'year'); $publication->setData('datePublished', '2010-11-05'); @@ -144,6 +143,7 @@ public function testToXml() ->will($this->returnValue(98)); $galley->setId(98); $galley->setData('doiObject', $galleyDoiObject); + $galley->setData('locale', 'en'); $galleys = [$galley]; From 5bfc14249b65340e68eede899f757f1243eaff32 Mon Sep 17 00:00:00 2001 From: jyhein <124268211+jyhein@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:49:13 +0200 Subject: [PATCH 2/2] pkp/pkp-lib#5000 Submodule update ##jyhein/f5000## --- lib/pkp | 2 +- plugins/generic/citationStyleLanguage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkp b/lib/pkp index a328708889..515da5c286 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit a328708889384c54584bf6332ac65c740a599e95 +Subproject commit 515da5c286caade25c115ce80cc650f77874525e diff --git a/plugins/generic/citationStyleLanguage b/plugins/generic/citationStyleLanguage index ae8028c801..b0cddf1882 160000 --- a/plugins/generic/citationStyleLanguage +++ b/plugins/generic/citationStyleLanguage @@ -1 +1 @@ -Subproject commit ae8028c801e9b94233132809f90e11ef6fa6aa35 +Subproject commit b0cddf188254dca5337960faa7c03716b98d6499