Fix default value handling in box PIP entry creation
authorMatthias Schmidt <gravatronics@live.com>
Sun, 14 Oct 2018 08:49:59 +0000 (10:49 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 14 Oct 2018 08:49:59 +0000 (10:49 +0200)
… and sort visibility exceptions by name in the XML file.

See #2545

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

index ea0a2d136f7bf7a6eb12c28332ed57db0185141a..c9c1372727029c867512794c34aa5938ecdd8481 100644 (file)
@@ -801,8 +801,7 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                $optionals = [
                        'objectType' => '',
                        'cssClassName' => '',
-                       'showHeader' => 1,
-                       'visibleEverywhere' => 1
+                       'showHeader' => 0
                ];
                foreach ($optionals as $field => $defaultValue) {
                        if (isset($data[$field]) && $data[$field] !== $defaultValue) {
@@ -811,14 +810,20 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                }
                
                if (!empty($data['visibilityExceptions'])) {
+                       $box->appendChild($document->createElement('visibleEverywhere', (string)($data['visibleEverywhere'] ?? 0)));
+                       
                        $visibilityExceptions = $document->createElement('visibilityExceptions');
                        
+                       sort($data['visibilityExceptions']);
                        foreach ($data['visibilityExceptions'] as $page) {
                                $visibilityExceptions->appendChild($document->createElement('page', $page));
                        }
                        
                        $box->appendChild($visibilityExceptions);
                }
+               else if (!empty($data['visibleEverywhere'])) {
+                       $box->appendChild($document->createElement('visibleEverywhere', (string)$data['visibleEverywhere']));
+               }
                
                foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
                        $content = null;