diff --git a/classes/publication/Publication.inc.php b/classes/publication/Publication.inc.php index da83ab583f5..2b30f7a4bf7 100644 --- a/classes/publication/Publication.inc.php +++ b/classes/publication/Publication.inc.php @@ -36,6 +36,30 @@ public function getEditorString() { return join(__('common.commaListSeparator') . ' ', $editorNames); } + /** + * Get the URL to a cover image + * + * @param int $contextId + * @param string $preferredLocale Return the cover image in a specified locale. + * @return string + */ + public function getCoverImageUrl($contextId, $preferredLocale = null) { + $coverImage = $this->getData('coverImage', $preferredLocale); + + if (!$coverImage) { + return Application::get()->getRequest()->getBaseUrl() . '/templates/images/book-default.png'; + } + + import('classes.file.PublicFileManager'); + $publicFileManager = new PublicFileManager(); + + return join('/', [ + Application::get()->getRequest()->getBaseUrl(), + $publicFileManager->getContextFilesPath($contextId), + $coverImage['uploadName'], + ]); + } + /** * Get the URL to a localized cover image * diff --git a/lib/pkp b/lib/pkp index bf243e1e25e..058e5f4c4de 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit bf243e1e25e25523434916e1c54c172f6169c702 +Subproject commit 058e5f4c4de7cdc2ebbb8889c032f309f6d6da3b diff --git a/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php b/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php index fd9eb2310df..7f67fa29406 100644 --- a/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php +++ b/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php @@ -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 @@ -29,7 +29,6 @@ function __construct($filterGroup) { parent::__construct($filterGroup); } - // // Implement template methods from PersistableFilter // @@ -121,7 +120,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())); @@ -248,13 +247,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 + AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION, $pubLocale); // 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); @@ -291,19 +291,25 @@ 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)))))); + $seriesLocale = $pubLocale; + // If the series title doesn't exist in the submission locale, use the press locale + if ($series->getTitle($seriesLocale, false) == '') { + $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)))))); } else { - if ($series->getLocalizedPrefix() != '') { - $titleElementNode->appendChild($this->_buildTextNode($doc, 'TitlePrefix', $series->getLocalizedPrefix())); + 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->getLocalizedTitle(false))); + $titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleWithoutPrefix', $series->getTitle($seriesLocale, false))); } - if ($series->getLocalizedSubtitle() != '') { - $titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $series->getLocalizedSubtitle())); + if ($series->getSubtitle($seriesLocale) != '') { + $titleElementNode->appendChild($this->_buildTextNode($doc, 'Subtitle', $series->getSubtitle($seriesLocale))); } } else { $seriesCollectionNode = $doc->createElementNS($deployment->getNamespace(), 'NoCollection'); @@ -322,20 +328,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->getData('prefix', $pubLocale) || !$publication->getData('title', $pubLocale)) { + $titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleText', trim($publication->getData('prefix', $pubLocale) ?? $publication->getData('title', $pubLocale)))); } else { - if ($publication->getLocalizedData('prefix')) { - $titleElementNode->appendChild($this->_buildTextNode($doc, 'TitlePrefix', $publication->getLocalizedData('prefix'))); + 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->getLocalizedTitle())); + $titleElementNode->appendChild($this->_buildTextNode($doc, 'TitleWithoutPrefix', $publication->getData('title', $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 --- */ @@ -355,17 +361,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, null, $pubLocale))); + $contributorNode->appendChild($this->_buildTextNode($doc, 'PersonNameInverted', $author->getFullName(false, true, null, $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, null, $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() != '') { @@ -442,13 +448,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)))); @@ -493,7 +499,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->getData('abstract', $pubLocale)); $textContentNode = $doc->createElementNS($deployment->getNamespace(), 'TextContent'); $collateralDetailNode->appendChild($textContentNode); @@ -517,7 +523,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->getCoverImageUrl($context->getId(), $pubLocale))); /* --- Publishing Detail --- */ @@ -707,15 +713,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())); } @@ -735,12 +742,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'))); @@ -755,9 +758,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'); @@ -892,5 +895,3 @@ function _buildTextNode($doc, $nodeName, $textContent) { return $node; } } - -