From: Matthias Schmidt Date: Wed, 13 Feb 2019 17:47:20 +0000 (+0100) Subject: Fix saving of box and page contents via PIP GUI X-Git-Tag: 5.2.0_Alpha_1~291 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=63d01a4dfed1fa99e37ce7469c90c0f6274621af;p=GitHub%2FWoltLab%2FWCF.git Fix saving of box and page contents via PIP GUI See #2545 --- 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'])) {