From 63d01a4dfed1fa99e37ce7469c90c0f6274621af Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 13 Feb 2019 18:47:20 +0100 Subject: [PATCH] Fix saving of box and page contents via PIP GUI See #2545 --- .../BoxPackageInstallationPlugin.class.php | 32 +++++++++++++------ .../PagePackageInstallationPlugin.class.php | 18 ++++++++++- 2 files changed, 40 insertions(+), 10 deletions(-) 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 6b1b4e6e35..b190e6c33f 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php @@ -739,18 +739,32 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin } $content = []; - if (isset($data['content'])) { - $content['content'] = $data['content']; - unset($data['content']); - } - if (isset($data['title'])) { - $content['title'] = $data['title']; - unset($data['title']); + + foreach (['title', 'content'] as $contentProperty) { + if (!empty($data[$contentProperty])) { + foreach ($data[$contentProperty] as $languageID => $value) { + $languageCode = LanguageFactory::getInstance()->getLanguage($languageID)->languageCode; + + if (!isset($content[$languageCode])) { + $content[$languageCode] = []; + } + + $content[$languageCode][$contentProperty] = $value; + } + } + + unset($data[$contentProperty]); } - if (!empty($content)) { - $data['content'] = $content; + foreach ($content as $languageCode => $values) { + foreach (['title', 'content'] as $contentProperty) { + if (!isset($values[$contentProperty])) { + $content[$languageCode][$contentProperty] = ''; + } + } } + + $data['content'] = $content; } return $data; diff --git a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php index adce82cf07..15c41f0111 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -741,12 +741,28 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin foreach (['title', 'content', 'customURL', 'metaDescription', 'metaKeywords'] as $contentProperty) { if (!empty($data[$contentProperty])) { - $content[$contentProperty] = $data[$contentProperty]; + foreach ($data[$contentProperty] as $languageID => $value) { + $languageCode = LanguageFactory::getInstance()->getLanguage($languageID)->languageCode; + + if (!isset($content[$languageCode])) { + $content[$languageCode] = []; + } + + $content[$languageCode][$contentProperty] = $value; + } } unset($data[$contentProperty]); } + foreach ($content as $languageCode => $values) { + foreach (['title', 'content', 'customURL', 'metaDescription', 'metaKeywords'] as $contentProperty) { + if (!isset($values[$contentProperty])) { + $content[$languageCode][$contentProperty] = ''; + } + } + } + $data['content'] = $content; if (isset($data['parent'])) { -- 2.20.1