Skip to content

Commit

Permalink
Merge pull request #1793 from kaitlinnewson/10641-3_3_0
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 bc53731 + 10388bd commit aeb524e
Showing 1 changed file with 21 additions and 34 deletions.
55 changes: 21 additions & 34 deletions plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,14 @@ function createProductNode($doc, $submission, $publicationFormat, $identificatio
$seriesLocale = $context->getPrimaryLocale();
}

if ($series->getPrefix($seriesLocale) == '' || $series->getTitle($seriesLocale, false) == '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleText', trim(join(' ', array($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 @@ -338,18 +335,14 @@ function createProductNode($doc, $submission, $publicationFormat, $identificatio

$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', $publication->getData('title', $pubLocale)));
$titleElementNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoPrefix'));
}

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

if ($publication->getData('subtitle', $pubLocale)) {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $publication->getData('subtitle', $pubLocale)));
}
Expand All @@ -365,7 +358,13 @@ function createProductNode($doc, $submission, $publicationFormat, $identificatio
$userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
$userGroup = $userGroupDao->getById($author->getUserGroupId(), $submission->getContextId());

$userGroupOnixMap = array('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');
$role = array_key_exists($nameKey, $userGroupOnixMap) ? $userGroupOnixMap[$nameKey] : 'Z99'; // Z99 - unknown contributor type.
Expand Down Expand Up @@ -405,25 +404,13 @@ function createProductNode($doc, $submission, $publicationFormat, $identificatio
$descDetailNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoContributor')); // empty state of fact.
}

/* --- Add Language elements --- */

$submissionLanguageDao = DAORegistry::getDAO('SubmissionLanguageDAO'); /* @var $submissionLanguageDao SubmissionLanguageDAO */
$allLanguages = $submissionLanguageDao->getLanguages($publication->getId(), array_keys(AppLocale::getSupportedFormLocales()));
$uniqueLanguages = array();
foreach ($allLanguages as $locale => $languages) {
$uniqueLanguages = array_merge($uniqueLanguages, $languages);
}
/* --- Add Language element --- */

foreach ($uniqueLanguages as $language) {
if ($onixCodelistItemDao->codeExistsInList(AppLocale::get3LetterIsoFromLocale($pubLocale), 'List74')) {
$languageNode = $doc->createElementNS($deployment->getNamespace(), 'Language');

$languageNode->appendChild($this->_buildTextNode($doc, 'LanguageRole', '01'));
$onixLanguageCode = $onixCodelistItemDao->getCodeFromValue($language, 'List74');
if ($onixLanguageCode != '') {
$languageNode->appendChild($this->_buildTextNode($doc, 'LanguageCode', $onixLanguageCode));
$descDetailNode->appendChild($languageNode);
}
unset($languageNode);
$languageNode->appendChild($this->_buildTextNode($doc, 'LanguageCode', AppLocale::get3LetterIsoFromLocale($pubLocale)));
$descDetailNode->appendChild($languageNode);
}

/* --- add Extents for 03 (front matter), 04 (back matter), 22 for digital works ---*/
Expand Down

0 comments on commit aeb524e

Please sign in to comment.