Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9894 add keywords and fix locale for subjects in onix export #1611

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
use APP\submission\Submission;
use DOMDocument;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\filter\FilterGroup;
use PKP\submission\SubmissionSubjectDAO;

class MonographONIX30XmlFilter extends \PKP\plugins\importexport\native\filter\NativeExportFilter
{
Expand Down Expand Up @@ -401,19 +399,20 @@ public 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 ^^

$submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO'); /** @var SubmissionSubjectDAO $submissionSubjectDao */
$allSubjects = $submissionSubjectDao->getSubjects($publication->getId(), array_keys(Locale::getSupportedFormLocales()));
$uniqueSubjects = [];
foreach ($allSubjects as $locale => $subjects) {
$uniqueSubjects = array_merge($uniqueSubjects, $subjects);
if ($publication->getData('subjects')) {
$allSubjects = ($publication->getData('subjects')[$publication->getData('locale')]);
$subjectNode->appendChild($this->_buildTextNode($doc, 'SubjectCode', trim(join(', ', $allSubjects))));
}
$descDetailNode->appendChild($subjectNode);

if (sizeof($uniqueSubjects) > 0) {
$subjectNode->appendChild($this->_buildTextNode($doc, 'SubjectCode', trim(join(', ', $uniqueSubjects))));
if ($publication->getData('keywords')) {
$allKeywords = ($publication->getData('keywords')[$publication->getData('locale')]);
$keywordNode = $doc->createElementNS($deployment->getNamespace(), 'Subject');
$keywordNode->appendChild($this->_buildTextNode($doc, 'SubjectSchemeIdentifier', '20')); // Keywords
$keywordNode->appendChild($this->_buildTextNode($doc, 'SubjectHeadingText', trim(join(', ', $allKeywords))));
$descDetailNode->appendChild($keywordNode);
}

$descDetailNode->appendChild($subjectNode);

/* --- Add Audience elements --- */

if ($submission->getData('audience')) {
Expand Down