Skip to content

Commit

Permalink
pkp#9425 Fixes omp crash and workflow localized form bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jyhein committed Oct 31, 2023
1 parent cdbe159 commit cc507fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
13 changes: 10 additions & 3 deletions classes/submissionFile/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion pages/authorDashboard/PKPAuthorDashboardHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,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;
Expand Down
2 changes: 1 addition & 1 deletion pages/workflow/PKPWorkflowHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,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;
Expand Down

0 comments on commit cc507fd

Please sign in to comment.