Skip to content

Commit

Permalink
Merge pull request #101 from touhidurabir/i10671_main_fix
Browse files Browse the repository at this point in the history
pkp/pkp-lib#10671 controlled vocab metadata issue fixing
  • Loading branch information
bozana authored Jan 24, 2025
2 parents 05ee782 + e703a5f commit 7e47446
Showing 1 changed file with 49 additions and 54 deletions.
103 changes: 49 additions & 54 deletions classes/form/SubmissionMetadataForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public function __construct($parentForm = null)
*/
public function _getAbstractsRequired($submission)
{
$section = Repo::section()->get($submission->getCurrentPublication()->getData('sectionId'), $submission->getData('contextId'));
$section = Repo::section()
->get(
$submission->getCurrentPublication()->getData('sectionId'),
$submission->getData('contextId')
);

return !$section->getAbstractsNotRequired();
}

Expand Down Expand Up @@ -147,45 +152,11 @@ public function initData($submission)
$this->_parentForm->setData($key, $data);
}

// get the supported locale keys
$locales = array_keys($this->_parentForm->supportedLocales);

$this->_parentForm->setData(
'subjects',
Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId()
)
);
$this->_parentForm->setData(
'keywords',
Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId()
)
);
$this->_parentForm->setData(
'disciplines',
Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId()
)
);
$this->_parentForm->setData(
'agencies',
Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId()
)
);
$this->_parentForm->setData(
'abstractsRequired',
$this->_getAbstractsRequired($submission)
);
$this->_parentForm->setData('subjects', $publication->getData('subjects'));
$this->_parentForm->setData('keywords', $publication->getData('keywords'));
$this->_parentForm->setData('disciplines', $publication->getData('disciplines'));
$this->_parentForm->setData('agencies', $publication->getData('supportingAgencies'));
$this->_parentForm->setData('abstractsRequired', $this->_getAbstractsRequired($submission));
}
}

Expand All @@ -195,7 +166,21 @@ public function initData($submission)
public function readInputData()
{
// 'keywords' is a tagit catchall that contains an array of values for each keyword/locale combination on the form.
$userVars = ['title', 'prefix', 'subtitle', 'abstract', 'coverage', 'type', 'source', 'rights', 'keywords', 'citationsRaw', 'locale', 'dataAvailability'];
$userVars = [
'title',
'prefix',
'subtitle',
'abstract',
'coverage',
'type',
'source',
'rights',
'keywords',
'citationsRaw',
'locale',
'dataAvailability',
];

$this->_parentForm->readUserVars($userVars);
}

Expand All @@ -206,7 +191,17 @@ public function readInputData()
*/
public function getLocaleFieldNames()
{
return ['title', 'prefix', 'subtitle', 'abstract', 'coverage', 'type', 'source', 'rights', 'dataAvailability'];
return [
'title',
'prefix',
'subtitle',
'abstract',
'coverage',
'type',
'source',
'rights',
'dataAvailability',
];
}

/**
Expand Down Expand Up @@ -281,27 +276,27 @@ public function execute($submission, $request)

$currentPublication = $submission->getCurrentPublication();
Repo::controlledVocab()->insertBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
$keywords,
Application::ASSOC_TYPE_PUBLICATION,
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
$keywords,
Application::ASSOC_TYPE_PUBLICATION,
$currentPublication->getId()
);
Repo::controlledVocab()->insertBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
$agencies[$locale],
Application::ASSOC_TYPE_PUBLICATION,
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
$agencies,
Application::ASSOC_TYPE_PUBLICATION,
$currentPublication->getId()
);
Repo::controlledVocab()->insertBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
$disciplines,
Application::ASSOC_TYPE_PUBLICATION,
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
$disciplines,
Application::ASSOC_TYPE_PUBLICATION,
$currentPublication->getId()
);
Repo::controlledVocab()->insertBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
$subjects,
Application::ASSOC_TYPE_PUBLICATION,
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
$subjects,
Application::ASSOC_TYPE_PUBLICATION,
$currentPublication->getId()
);

Expand Down

0 comments on commit 7e47446

Please sign in to comment.