Skip to content

Commit

Permalink
Merge pull request #1795 from kaitlinnewson/10641-main
Browse files Browse the repository at this point in the history
pkp/pkp-lib#10641 fix onix export language and update title elements …
  • Loading branch information
bozana authored Jan 3, 2025
2 parents 97bd1e8 + 86afce7 commit ded02c5
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use PKP\filter\FilterGroup;
use PKP\i18n\LocaleConversion;
use PKP\plugins\importexport\native\filter\NativeExportFilter;
use PKP\userGroup\UserGroup;

class MonographONIX30XmlFilter extends NativeExportFilter
{
Expand Down Expand Up @@ -326,18 +327,14 @@ public function createProductNode(DOMDocument $doc, Submission $submission, Publ
$seriesLocale = $context->getPrimaryLocale();
}

if ($series->getPrefix($seriesLocale) == '' || $series->getTitle($seriesLocale, false) == '') {
$titleElementNode->appendChild($this->buildTextNode($doc, 'TitleText', trim(join(' ', [$series->getPrefix($seriesLocale), $series->getTitle($seriesLocale, false)]))));
if ($series->getPrefix($seriesLocale) != '') {
$titleElementNode->appendChild($this->buildTextNode($doc, 'TitlePrefix', $series->getPrefix($seriesLocale)));
} else {
if ($series->getPrefix($seriesLocale) != '') {
$titleElementNode->appendChild($this->buildTextNode($doc, 'TitlePrefix', $series->getPrefix($seriesLocale)));
} else {
$titleElementNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoPrefix'));
}

$titleElementNode->appendChild($this->buildTextNode($doc, 'TitleWithoutPrefix', $series->getTitle($seriesLocale, false)));
$titleElementNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoPrefix'));
}

$titleElementNode->appendChild($this->buildTextNode($doc, 'TitleWithoutPrefix', $series->getTitle($seriesLocale, false)));

if ($series->getSubtitle($seriesLocale) != '') {
$titleElementNode->appendChild($this->buildTextNode($doc, 'Subtitle', $series->getSubtitle($seriesLocale)));
}
Expand All @@ -357,18 +354,14 @@ public function createProductNode(DOMDocument $doc, Submission $submission, Publ

$productTitleDetailNode->appendChild($titleElementNode);

if (!$publication->getData('prefix', $pubLocale) || !$publication->getData('title', $pubLocale)) {
$titleElementNode->appendChild($this->buildTextNode($doc, 'TitleText', trim($publication->getData('prefix', $pubLocale) ?? $publication->getData('title', $pubLocale))));
if ($publication->getData('prefix', $pubLocale)) {
$titleElementNode->appendChild($this->buildTextNode($doc, 'TitlePrefix', $publication->getData('prefix', $pubLocale)));
} else {
if ($publication->getData('prefix', $pubLocale)) {
$titleElementNode->appendChild($this->buildTextNode($doc, 'TitlePrefix', $publication->getData('prefix', $pubLocale)));
} else {
$titleElementNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoPrefix'));
}

$titleElementNode->appendChild($this->buildTextNode($doc, 'TitleWithoutPrefix', strip_tags($publication->getData('title', $pubLocale))));
$titleElementNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoPrefix'));
}

$titleElementNode->appendChild($this->buildTextNode($doc, 'TitleWithoutPrefix', $publication->getData('title', $pubLocale)));

if ($subTitle = $publication->getData('subtitle', $pubLocale)) {
$titleElementNode->appendChild($this->buildTextNode($doc, 'Subtitle', $subTitle));
}
Expand All @@ -381,11 +374,17 @@ public function createProductNode(DOMDocument $doc, Submission $submission, Publ
$contributorNode = $doc->createElementNS($deployment->getNamespace(), 'Contributor');
$contributorNode->appendChild($this->buildTextNode($doc, 'SequenceNumber', $sequence));

$userGroup = Repo::userGroup()->get($author->getUserGroupId());
$userGroup = UserGroup::find($author->getUserGroupId());

$userGroupOnixMap = ['default.groups.name.author' => 'A01', 'default.groups.name.volumeEditor' => 'B01', 'default.groups.name.chapterAuthor' => 'A01', 'default.groups.name.translator' => 'B06', 'default.groups.name.editor' => 'B21']; // From List17, ContributorRole types.
$userGroupOnixMap = [
'default.groups.name.author' => 'A01',
'default.groups.name.volumeEditor' => 'B01',
'default.groups.name.chapterAuthor' => 'A01',
'default.groups.name.translator' => 'B06',
'default.groups.name.editor' => 'B21'
]; // From List17, ContributorRole types.

$nameKey = $userGroup->getData('nameLocaleKey');
$nameKey = $userGroup->nameLocaleKey;
$role = array_key_exists($nameKey, $userGroupOnixMap) ? $userGroupOnixMap[$nameKey] : 'Z99'; // Z99 - unknown contributor type.

$contributorNode->appendChild($this->buildTextNode($doc, 'ContributorRole', $role));
Expand Down Expand Up @@ -424,11 +423,10 @@ public function createProductNode(DOMDocument $doc, Submission $submission, Publ

/* --- Add Language element --- */

$languageNode = $doc->createElementNS($deployment->getNamespace(), 'Language');
$languageNode->appendChild($this->buildTextNode($doc, 'LanguageRole', '01'));
$onixLanguageCode = $onixCodelistItemDao->getCodeFromValue(LocaleConversion::get3LetterIsoFromLocale($submission->getData('locale')), '74');
if ($onixLanguageCode != '') {
$languageNode->appendChild($this->buildTextNode($doc, 'LanguageCode', $onixLanguageCode));
if ($onixCodelistItemDao->codeExistsInList(LocaleConversion::get3LetterIsoFromLocale($pubLocale), '74')) {
$languageNode = $doc->createElementNS($deployment->getNamespace(), 'Language');
$languageNode->appendChild($this->buildTextNode($doc, 'LanguageRole', '01'));
$languageNode->appendChild($this->buildTextNode($doc, 'LanguageCode', LocaleConversion::get3LetterIsoFromLocale($pubLocale)));
$descDetailNode->appendChild($languageNode);
}

Expand Down

0 comments on commit ded02c5

Please sign in to comment.