Skip to content

Commit

Permalink
pkp/pkp-lib#10046 fix onix export calls to get localized data
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinnewson committed Sep 17, 2024
1 parent c3c903f commit ad51938
Showing 1 changed file with 36 additions and 40 deletions.
76 changes: 36 additions & 40 deletions plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class MonographONIX30XmlFilter
Expand Down Expand Up @@ -121,7 +121,7 @@ function createHeaderNode($doc) {
$senderNode->appendChild($senderIdentifierNode);

// Assemble SenderName element.
$senderNode->appendChild($this->_buildTextNode($doc, 'SenderName', $context->getLocalizedName()));
$senderNode->appendChild($this->_buildTextNode($doc, 'SenderName', $context->getName($context->getPrimaryLocale())));
$senderNode->appendChild($this->_buildTextNode($doc, 'ContactName', $context->getContactName()));
$senderNode->appendChild($this->_buildTextNode($doc, 'EmailAddress', $context->getContactEmail()));

Expand Down Expand Up @@ -248,13 +248,14 @@ function createProductNode($doc, $submission, $publicationFormat) {
/* --- License information --- */

$publication = $submission->getCurrentPublication();
$pubLocale = $publication->getData('locale');

if ($publication->isCCLicense()) {
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION); // For CC License Names
$licenseOpts = Application::getCCLicenseOptions();
$licenseUrl = $publication->getData('licenseUrl');
if (array_key_exists($licenseUrl, $licenseOpts)) {
$licenseName = (__($licenseOpts[$licenseUrl], [], $publication->getData('locale')));
$licenseName = (__($licenseOpts[$licenseUrl], [], $pubLocale));

$epubLicenseNode = $doc->createElementNS($deployment->getNamespace(), 'EpubLicense');
$descDetailNode->appendChild($epubLicenseNode);
Expand Down Expand Up @@ -291,19 +292,19 @@ function createProductNode($doc, $submission, $publicationFormat) {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'PartNumber', $submission->getCurrentPublication()->getData('seriesPosition')));
}

if ($series->getLocalizedPrefix() == '' || $series->getLocalizedTitle(false) == '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleText', trim(join(' ', array($series->getLocalizedPrefix(), $series->getLocalizedTitle(false))))));
if ($series->getPrefix($pubLocale) == '' || $series->getTitle($pubLocale, false) == '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleText', trim(join(' ', array($series->getPrefix($pubLocale), $series->getTitle($pubLocale, false))))));
} else {
if ($series->getLocalizedPrefix() != '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitlePrefix', $series->getLocalizedPrefix()));
if ($series->getPrefix($pubLocale) != '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitlePrefix', $series->getPrefix($pubLocale)));
} else {
$titleElementNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'NoPrefix'));
}
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleWithoutPrefix', $series->getLocalizedTitle(false)));
$titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleWithoutPrefix', $series->getTitle($pubLocale, false)));
}

if ($series->getLocalizedSubtitle() != '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $series->getLocalizedSubtitle()));
if ($series->getSubtitle($pubLocale) != '') {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $series->getSubtitle($pubLocale)));
}
} else {
$seriesCollectionNode = $doc->createElementNS($deployment->getNamespace(), 'NoCollection');
Expand All @@ -322,20 +323,20 @@ function createProductNode($doc, $submission, $publicationFormat) {

$productTitleDetailNode->appendChild($titleElementNode);

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

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

if ($publication->getData('subtitle', $publication->getData('locale'))) {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $publication->getData('subtitle', $publication->getData('locale'))));
if ($publication->getData('subtitle', $pubLocale)) {
$titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $publication->getData('subtitle', $pubLocale)));
}

/* --- Contributor information --- */
Expand All @@ -355,17 +356,17 @@ function createProductNode($doc, $submission, $publicationFormat) {
$role = array_key_exists($nameKey, $userGroupOnixMap) ? $userGroupOnixMap[$nameKey] : 'Z99'; // Z99 - unknown contributor type.

$contributorNode->appendChild($this->_buildTextNode($doc, 'ContributorRole', $role));
$contributorNode->appendChild($this->_buildTextNode($doc, 'PersonName', $author->getFullName(false)));
$contributorNode->appendChild($this->_buildTextNode($doc, 'PersonNameInverted', $author->getFullName(false, true)));
$contributorNode->appendChild($this->_buildTextNode($doc, 'NamesBeforeKey', $author->getLocalizedGivenName()));
if ($author->getLocalizedFamilyName() != '') {
$contributorNode->appendChild($this->_buildTextNode($doc, 'KeyNames', $author->getLocalizedFamilyName()));
$contributorNode->appendChild($this->_buildTextNode($doc, 'PersonName', $author->getFullName(false, false, $pubLocale)));
$contributorNode->appendChild($this->_buildTextNode($doc, 'PersonNameInverted', $author->getFullName(false, true, $pubLocale)));
$contributorNode->appendChild($this->_buildTextNode($doc, 'NamesBeforeKey', $author->getGivenName($pubLocale)));
if ($author->getFamilyName($pubLocale) != '') {
$contributorNode->appendChild($this->_buildTextNode($doc, 'KeyNames', $author->getFamilyName($pubLocale)));
} else {
$contributorNode->appendChild($this->_buildTextNode($doc, 'KeyNames', $author->getFullName(false)));
$contributorNode->appendChild($this->_buildTextNode($doc, 'KeyNames', $author->getFullName(false, false, $pubLocale)));
}

if ($author->getLocalizedBiography() != '') {
$contributorNode->appendChild($this->_buildTextNode($doc, 'BiographicalNote', $author->getLocalizedBiography()));
if ($author->getBiography($pubLocale) != '') {
$contributorNode->appendChild($this->_buildTextNode($doc, 'BiographicalNote', $author->getBiography($pubLocale)));
}

if ($author->getCountry() != '') {
Expand Down Expand Up @@ -442,13 +443,13 @@ function createProductNode($doc, $submission, $publicationFormat) {
$subjectNode->appendChild($this->_buildTextNode($doc, 'SubjectSchemeIdentifier', '12')); // 12 is BIC subject category code list.
$subjectNode->appendChild($this->_buildTextNode($doc, 'SubjectSchemeVersion', '2')); // Version 2 of ^^

$allSubjects = ($publication->getData('subjects')[$publication->getData('locale')]);
$allSubjects = ($publication->getData('subjects')[$pubLocale]);
$subjectNode->appendChild($this->_buildTextNode($doc, 'SubjectCode', trim(join(', ', $allSubjects))));
$descDetailNode->appendChild($subjectNode);
}

if ($publication->getData('keywords')) {
$allKeywords = ($publication->getData('keywords')[$publication->getData('locale')]);
$allKeywords = ($publication->getData('keywords')[$pubLocale]);
$keywordNode = $doc->createElementNS($deployment->getNamespace(), 'Subject');
$keywordNode->appendChild($this->_buildTextNode($doc, 'SubjectSchemeIdentifier', '20')); // Keywords
$keywordNode->appendChild($this->_buildTextNode($doc, 'SubjectHeadingText', trim(join(', ', $allKeywords))));
Expand Down Expand Up @@ -493,7 +494,7 @@ function createProductNode($doc, $submission, $publicationFormat) {
$collateralDetailNode = $doc->createElementNS($deployment->getNamespace(), 'CollateralDetail');
$productNode->appendChild($collateralDetailNode);

$abstract = strip_tags($publication->getLocalizedData('abstract'));
$abstract = strip_tags($publication->getLocalizedData('abstract', $pubLocale));

$textContentNode = $doc->createElementNS($deployment->getNamespace(), 'TextContent');
$collateralDetailNode->appendChild($textContentNode);
Expand All @@ -517,7 +518,7 @@ function createProductNode($doc, $submission, $publicationFormat) {
$resourceVersionNode = $doc->createElementNS($deployment->getNamespace(), 'ResourceVersion');
$supportingResourceNode->appendChild($resourceVersionNode);
$resourceVersionNode->appendChild($this->_buildTextNode($doc, 'ResourceForm', '01')); // Linkable resource
$resourceVersionNode->appendChild($this->_buildTextNode($doc, 'ResourceLink', $publication->getLocalizedCoverImageUrl($context->getId(), $publication->getData('locale'))));
$resourceVersionNode->appendChild($this->_buildTextNode($doc, 'ResourceLink', $publication->getLocalizedCoverImageUrl($context->getId(), $pubLocale)));

/* --- Publishing Detail --- */

Expand Down Expand Up @@ -707,15 +708,16 @@ function createProductNode($doc, $submission, $publicationFormat) {
$supplyDetailNode = $doc->createElementNS($deployment->getNamespace(), 'SupplyDetail');
$productSupplyNode->appendChild($supplyDetailNode);

$supplierNode = $doc->createElementNS($deployment->getNamespace(), 'Supplier');
$supplyDetailNode->appendChild($supplierNode);
if (isset($supplier)) {
$supplierNode = $doc->createElementNS($deployment->getNamespace(), 'Supplier');
$supplyDetailNode->appendChild($supplierNode);

$supplierNode->appendChild($this->_buildTextNode($doc, 'SupplierRole', $supplier->getRole()));
$supplierNode->appendChild($this->_buildTextNode($doc, 'SupplierName', $supplier->getName()));
if ($supplier->getPhone()) {
$supplierNode->appendChild($this->_buildTextNode($doc, 'TelephoneNumber', $supplier->getPhone()));
}

if ($supplier->getEmail()) {
$supplierNode->appendChild($this->_buildTextNode($doc, 'EmailAddress', $supplier->getEmail()));
}
Expand All @@ -735,12 +737,8 @@ function createProductNode($doc, $submission, $publicationFormat) {

$supplierWebsiteNode->appendChild($this->_buildTextNode($doc, 'WebsiteRole', '29')); // 29 -> Web page for full content
$supplierWebsiteNode->appendChild($this->_buildTextNode($doc, 'WebsiteLink', $request->url($context->getPath(), 'catalog', 'book', $submissionBestId)));
unset($supplierNode);
unset($supplierWebsiteNode);

} else { // No suppliers specified, use the Press settings instead.
$supplierNode = $doc->createElementNS($deployment->getNamespace(), 'Supplier');
$supplyDetailNode->appendChild($supplierNode);

$supplierNode->appendChild($this->_buildTextNode($doc, 'SupplierRole', '09')); // Publisher supplying to end customers
$supplierNode->appendChild($this->_buildTextNode($doc, 'SupplierName', $context->getData('publisher')));
Expand All @@ -755,9 +753,9 @@ function createProductNode($doc, $submission, $publicationFormat) {
$supplierWebsiteNode->appendChild($this->_buildTextNode($doc, 'WebsiteRole', '18')); // 18 -> Public website
$supplierWebsiteNode->appendChild($this->_buildTextNode($doc, 'WebsiteLink', $request->url($context->getPath())));

unset($supplierNode);
unset($supplierWebsiteNode);
}
unset($supplierNode);
unset($supplierWebsiteNode);

if ($publicationFormat->getReturnableIndicatorCode() != '') {
$returnsNode = $doc->createElementNS($deployment->getNamespace(), 'ReturnsConditions');
Expand Down Expand Up @@ -892,5 +890,3 @@ function _buildTextNode($doc, $nodeName, $textContent) {
return $node;
}
}


0 comments on commit ad51938

Please sign in to comment.