From 1bfc18bcb632c74fcc9851996b40ad29ffb42455 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 22 Aug 2016 17:57:08 +0200 Subject: [PATCH] Fix determination of box name during installation Use same code as for pages --- .../BoxPackageInstallationPlugin.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php index 7cfd9dedca..6939388536 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php @@ -128,6 +128,21 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin throw new SystemException("Unknown box position '{$position}' for box '{$identifier}'"); } + // pick the display name by choosing the default language, or 'en' or '' (empty string) + $defaultLanguageCode = LanguageFactory::getInstance()->getDefaultLanguage()->getFixedLanguageCode(); + if (isset($data['elements']['name'][$defaultLanguageCode])) { + // use the default language + $name = $data['elements']['name'][$defaultLanguageCode]; + } + else if (isset($data['elements']['name']['en'])) { + // use the value for English + $name = $data['elements']['name']['en']; + } + else { + // fallback to the display name without/empty language attribute + $name = $data['elements']['name']['']; + } + $ignoreMissingContent = false; switch ($boxType) { /** @noinspection PhpMissingBreakStatementInspection */ @@ -200,7 +215,7 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin return [ 'identifier' => $identifier, 'content' => $content, - 'name' => $this->getI18nValues($data['elements']['name'], true), + 'name' => $name, 'boxType' => $boxType, 'position' => $position, 'showOrder' => $this->getItemOrder($position), -- 2.20.1