Skip to content

Commit

Permalink
pkp/pkp-lib#9425 Make submission language selection and metadata form…
Browse files Browse the repository at this point in the history
…s independent from website language settings
  • Loading branch information
jyhein committed Nov 14, 2023
1 parent b96a056 commit 6583bf1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion classes/publication/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function validate($publication, array $props, Submission $submission, Con
$errors = parent::validate($publication, $props, $submission, $context);

$primaryLocale = $submission->getData('locale');
$allowedLocales = array_values(array_unique(array_merge($context->getSupportedSubmissionMetadataLocales(), $publication?->getLanguages() ?? [$primaryLocale])));

// Ensure that the specified section exists
$section = null;
Expand Down Expand Up @@ -77,6 +76,7 @@ public function validate($publication, array $props, Submission $submission, Con
}

// Check the word count on abstracts
$allowedLocales = array_values(array_unique(array_merge($context->getSupportedSubmissionMetadataLocales(), $publication?->getLanguages() ?? [$primaryLocale])));
foreach ($allowedLocales as $localeKey) {
if (empty($props['abstract'][$localeKey])) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/articleGalleys/form/ArticleGalleyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct($request, $submission, $publication, $articleGalley
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));

// Ensure a locale is provided and valid
$locales = $request->getJournal()->getSupportedSubmissionMetadataLocaleNames() + $publication->getLanguageNames();
$locales = $request->getJournal()->getSupportedSubmissionMetadataLocaleNames() + $publication->getLanguageNames() + ($articleGalley?->getLanguageNames() ?? []);
$this->addCheck(
new \PKP\form\validation\FormValidator(
$this,
Expand Down Expand Up @@ -92,7 +92,7 @@ public function fetch($request, $template = null, $display = false)
]);
}

$supportedLocales = $request->getContext()->getSupportedSubmissionMetadataLocaleNames() + $this->_publication->getLanguageNames();
$supportedLocales = $request->getContext()->getSupportedSubmissionMetadataLocaleNames() + $this->_publication->getLanguageNames() + ($this->_articleGalley?->getLanguageNames() ?? []);
ksort($supportedLocales);

$templateMgr->assign([
Expand Down
5 changes: 3 additions & 2 deletions pages/workflow/WorkflowHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public function setupIndex($request)

$latestPublication = $submission->getLatestPublication();

$locales = collect($submissionContext->getSupportedSubmissionMetadataLocaleNames() + $latestPublication->getLanguageNames())
$submissionLocale = $submission->getData('locale');
$locales = collect($submissionContext->getSupportedSubmissionMetadataLocaleNames() + $submission->getPublicationLanguageNames())
->map(fn (string $name, string $locale) => ['key' => $locale, 'label' => $name])
->sortBy('key')
->values()
Expand Down Expand Up @@ -116,7 +117,7 @@ class_exists(\APP\components\forms\publication\AssignToIssueForm::class); // For
]);

$components = $templateMgr->getState('components');
$components[FORM_ISSUE_ENTRY] = $this->getLocalizedForm($issueEntryForm, $latestPublication, $submissionContext);
$components[FORM_ISSUE_ENTRY] = $this->getLocalizedForm($issueEntryForm, $submissionLocale, $locales);

// Add payments form if enabled
$paymentManager = Application::getPaymentManager($submissionContext);
Expand Down

0 comments on commit 6583bf1

Please sign in to comment.