Skip to content

Commit

Permalink
pkp/pkp-lib#9894 add keywords and fix locale for subjects in onix export
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinnewson committed Jun 25, 2024
1 parent 641957f commit d4725b1
Showing 1 changed file with 10 additions and 11 deletions.
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

0 comments on commit d4725b1

Please sign in to comment.