Fix saving of box and page contents via PIP GUI
authorMatthias Schmidt <gravatronics@live.com>
Wed, 13 Feb 2019 17:47:20 +0000 (18:47 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 13 Feb 2019 17:47:20 +0000 (18:47 +0100)
See #2545

wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php

index 6b1b4e6e3540ca48181516d9ae93f61b7064f340..b190e6c33fcd388da46c9f90d47bf6a29baa5779 100644 (file)
@@ -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;
index adce82cf0708821238be46dcb719a7da2c490c74..15c41f011114a5454b3ec2d822c107ac4b82f125 100644 (file)
@@ -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'])) {