diff --git a/classes/publication/PKPPublication.php b/classes/publication/PKPPublication.php index e3cbb6a4596..e796f1f7020 100644 --- a/classes/publication/PKPPublication.php +++ b/classes/publication/PKPPublication.php @@ -467,6 +467,7 @@ public function getLanguages(array $additionalLocales = []): array ->concat($additionalLocales) ->flatten() ->unique() + ->values() ->toArray(); } } diff --git a/classes/submissionFile/maps/Schema.php b/classes/submissionFile/maps/Schema.php index 8e86ac5a514..37e0fbce086 100644 --- a/classes/submissionFile/maps/Schema.php +++ b/classes/submissionFile/maps/Schema.php @@ -226,9 +226,16 @@ protected function mapByProperties(array $props, SubmissionFile $submissionFile) $output[$prop] = $submissionFile->getData($prop); } - $publicationId = $submissionFile->getData('assocId') ? Repo::galley()->get($submissionFile->getData('assocId'))?->getData('publicationId') : null; - $publicationLocales = $publicationId ? Repo::publication()->get($publicationId)?->getLanguages() ?? [] : []; - $locales = array_values(array_unique(array_merge($this->context->getSupportedSubmissionMetadataLocales(), $publicationLocales, [$submissionFile->getData('locale')]))); + $publicationLocales = !($assocId = $submissionFile->getData('assocId')) + ? [$submissionFile->getData('locale')] + : Repo::submission() + ->get($submissionFile->getData('submissionId')) + ->getData('publications') + ->first(fn ($p) => collect($p->getData(Application::get()->getName() === 'omp' ? 'publicationFormats' : 'galleys')) + ->contains(fn ($item) => $item->getId() === $assocId)) + ->getLanguages(); + + $locales = array_values(array_unique(array_merge($this->context->getSupportedSubmissionMetadataLocales(), $publicationLocales))); $output = $this->schemaService->addMissingMultilingualValues( $this->schema, diff --git a/controllers/wizard/fileUpload/form/SubmissionFilesMetadataForm.php b/controllers/wizard/fileUpload/form/SubmissionFilesMetadataForm.php index 71a2c370338..868492f9680 100644 --- a/controllers/wizard/fileUpload/form/SubmissionFilesMetadataForm.php +++ b/controllers/wizard/fileUpload/form/SubmissionFilesMetadataForm.php @@ -51,7 +51,12 @@ public function __construct($submissionFile, $stageId, $reviewRound = null, $tem } $submissionLocale = $submissionFile->getData('locale'); - $publicationLocaleNames = Repo::publication()->get(Repo::galley()->get($submissionFile->getData('assocId'))?->getData('publicationId'))?->getLanguageNames() ?? []; + $publicationLocaleNames = Repo::submission() + ->get($submissionFile->getData('submissionId')) + ->getData('publications') + ->first(fn ($p) => collect($p->getData(Application::get()->getName() === 'omp' ? 'publicationFormats' : 'galleys')) + ->contains(fn ($item) => $item->getId() === $submissionFile->getData('assocId'))) + ->getLanguageNames(); $localeNames = Application::get()->getRequest()->getContext()->getSupportedSubmissionMetadataLocaleNames() + $publicationLocaleNames; ksort($localeNames); diff --git a/pages/authorDashboard/PKPAuthorDashboardHandler.php b/pages/authorDashboard/PKPAuthorDashboardHandler.php index 0cbef1726b6..f0cd6fd0110 100644 --- a/pages/authorDashboard/PKPAuthorDashboardHandler.php +++ b/pages/authorDashboard/PKPAuthorDashboardHandler.php @@ -221,6 +221,7 @@ public function setupTemplate($request) $locales = collect($submissionContext->getSupportedSubmissionMetadataLocaleNames() + $latestPublication->getLanguageNames()) ->map(fn (string $name, string $locale) => ['key' => $locale, 'label' => $name]) ->sortBy('key') + ->values() ->toArray(); $submissionApiUrl = $request->getDispatcher()->url($request, PKPApplication::ROUTE_API, $submissionContext->getData('urlPath'), 'submissions/' . $submission->getId()); @@ -392,8 +393,8 @@ protected function getLocalizedForm(\PKP\components\forms\FormComponent $form, P $config['supportedFormLocales'] = collect($context->getSupportedSubmissionMetadataLocaleNames() + $publication->getLanguageNames()) ->map(fn (string $name, string $locale) => ['key' => $locale, 'label' => $name]) - ->values() ->sortBy([fn (array $a, array $b) => $a['key'] === $primaryLocale || $a['key'] < $b['key'] ? -1 : 1]) + ->values() ->toArray(); return $config; diff --git a/pages/workflow/PKPWorkflowHandler.php b/pages/workflow/PKPWorkflowHandler.php index daa589e5716..8841f953560 100644 --- a/pages/workflow/PKPWorkflowHandler.php +++ b/pages/workflow/PKPWorkflowHandler.php @@ -221,6 +221,7 @@ public function index($args, $request) $locales = collect($submissionContext->getSupportedSubmissionMetadataLocaleNames() + $latestPublication->getLanguageNames()) ->map(fn (string $name, string $locale) => ['key' => $locale, 'label' => $name]) ->sortBy('key') + ->values() ->toArray(); $submissionApiUrl = $request->getDispatcher()->url($request, Application::ROUTE_API, $submissionContext->getData('urlPath'), 'submissions/' . $submission->getId()); @@ -844,8 +845,8 @@ protected function getLocalizedForm(\PKP\components\forms\FormComponent $form, P $config['supportedFormLocales'] = collect($context->getSupportedSubmissionMetadataLocaleNames() + $publication->getLanguageNames()) ->map(fn (string $name, string $locale) => ['key' => $locale, 'label' => $name]) - ->values() ->sortBy([fn (array $a, array $b) => $a['key'] === $primaryLocale || $a['key'] < $b['key'] ? -1 : 1]) + ->values() ->toArray(); return $config;