From 42a91f2375b258f8f7bdd1ed239ad9315fb1c68c Mon Sep 17 00:00:00 2001 From: jyhein <124268211+jyhein@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:49:47 +0200 Subject: [PATCH] pkp/pkp-lib#9425 Make submission language selection and metadata forms independent from website language settings --- classes/publication/Repository.php | 2 +- classes/publication/maps/Schema.php | 2 +- classes/submission/Repository.php | 2 +- controllers/grid/articleGalleys/form/ArticleGalleyForm.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/publication/Repository.php b/classes/publication/Repository.php index 6311a45ba6d..300bf4617de 100644 --- a/classes/publication/Repository.php +++ b/classes/publication/Repository.php @@ -76,7 +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]))); + $allowedLocales = $submission->getPublicationLanguages($context->getSupportedSubmissionMetadataLocales()); foreach ($allowedLocales as $localeKey) { if (empty($props['abstract'][$localeKey])) { continue; diff --git a/classes/publication/maps/Schema.php b/classes/publication/maps/Schema.php index 4250afa5400..d8d813f48ce 100644 --- a/classes/publication/maps/Schema.php +++ b/classes/publication/maps/Schema.php @@ -49,7 +49,7 @@ protected function mapByProperties(array $props, Publication $publication, bool ); } - $locales = $publication->getLanguages($this->context->getSupportedSubmissionMetadataLocales()); + $locales = $this->submission->getPublicationLanguages($this->context->getSupportedSubmissionMetadataLocales()); $output = $this->schemaService->addMissingMultilingualValues(PKPSchemaService::SCHEMA_PUBLICATION, $output, $locales); diff --git a/classes/submission/Repository.php b/classes/submission/Repository.php index 8a49c7c53bc..10d6ee5ac46 100644 --- a/classes/submission/Repository.php +++ b/classes/submission/Repository.php @@ -80,7 +80,7 @@ public function validateSubmit(Submission $submission, Context $context): array $abstracts = $publication->getData('abstract'); if ($abstracts) { $abstractErrors = []; - $allowedLocales = $publication->getLanguages($context->getSupportedSubmissionMetadataLocales()); + $allowedLocales = $submission->getPublicationLanguages($context->getSupportedSubmissionMetadataLocales()); foreach ($allowedLocales as $localeKey) { $abstract = $publication->getData('abstract', $localeKey); $wordCount = $abstract ? PKPString::getWordCount($abstract) : 0; diff --git a/controllers/grid/articleGalleys/form/ArticleGalleyForm.php b/controllers/grid/articleGalleys/form/ArticleGalleyForm.php index f5db5662846..8896f7d741e 100644 --- a/controllers/grid/articleGalleys/form/ArticleGalleyForm.php +++ b/controllers/grid/articleGalleys/form/ArticleGalleyForm.php @@ -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() + ($articleGalley?->getLanguageNames() ?? []); + $locales = $request->getJournal()->getSupportedSubmissionMetadataLocaleNames() + $submission->getPublicationLanguageNames() + ($articleGalley?->getLanguageNames() ?? []); $this->addCheck( new \PKP\form\validation\FormValidator( $this, @@ -92,7 +92,7 @@ public function fetch($request, $template = null, $display = false) ]); } - $supportedLocales = $request->getContext()->getSupportedSubmissionMetadataLocaleNames() + $this->_publication->getLanguageNames() + ($this->_articleGalley?->getLanguageNames() ?? []); + $supportedLocales = $request->getContext()->getSupportedSubmissionMetadataLocaleNames() + $this->_submission->getPublicationLanguageNames() + ($this->_articleGalley?->getLanguageNames() ?? []); ksort($supportedLocales); $templateMgr->assign([