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#10671 controlled vocab metadata issue fixing #101

Merged
merged 2 commits into from
Jan 24, 2025
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
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