Remove automatic XML PIP file sorting
authorMatthias Schmidt <gravatronics@live.com>
Sun, 14 Oct 2018 12:45:41 +0000 (14:45 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 14 Oct 2018 12:45:41 +0000 (14:45 +0200)
Automatic sorting causes problems if PIPs assume that the order in the XML file represents an implicit order in which the elements should be shown.

See #2545

29 files changed:
wcfsetup/install/files/lib/system/devtools/pip/TMultiXmlGuiPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php

index 48292293c4232dff578350f33cb5604841178bf7..4c9a42142b0f13a1d1d2435b3b858912f20a0187 100644 (file)
@@ -39,12 +39,11 @@ trait TMultiXmlGuiPackageInstallationPlugin {
                foreach ($this->getProjectXmls() as $xml) {
                        $document = $xml->getDocument();
                        
-                       $newElement = $this->writeEntry($document, $form);
+                       $newElement = $this->createXmlElement($document, $form);
+                       $this->insertNewXmlElement($xml, $newElement);
                        
                        $this->saveObject($newElement);
                        
-                       $this->sortDocument($document);
-                       
                        // TODO: while creating/testing the gui, write into a temporary file
                        // $xml->write($this->getXmlFileLocation($project));
                        $xml->write(substr($xml->getPath(), 0, -4) . '_tmp.xml');
@@ -65,16 +64,14 @@ trait TMultiXmlGuiPackageInstallationPlugin {
                foreach ($this->getProjectXmls() as $xml) {
                        $document = $xml->getDocument();
                        
-                       // remove old element
-                       $element = $this->getElementByIdentifier($xml, $identifier);
-                       DOMUtil::removeNode($element);
-                       
                        // add updated element
-                       $newEntry = $this->writeEntry($document, $form);
+                       $newElement = $this->createXmlElement($document, $form);
                        
-                       $this->saveObject($newEntry, $element);
+                       // replace old element
+                       $element = $this->getElementByIdentifier($xml, $identifier);
+                       DOMUtil::replaceElement($newElement, $element);
                        
-                       $this->sortDocument($document);
+                       $this->saveObject($newEntry, $element);
                        
                        // TODO: while creating/testing the gui, write into a temporary file
                        // $xml->write($this->getXmlFileLocation($project));
index ffabd32be2320a129d6d3acc50d51b471650c16b..102406118ab62047537215500ba1eb93f6072915 100644 (file)
@@ -47,11 +47,10 @@ trait TXmlGuiPackageInstallationPlugin {
                $xml = $this->getProjectXml();
                $document = $xml->getDocument();
                
-               $newElement = $this->writeEntry($document, $form);
+               $newElement = $this->createXmlElement($document, $form);
+               $this->insertNewXmlElement($xml, $newElement);
                
                $this->saveObject($newElement);
-       
-               $this->sortDocument($document);
                
                /** @var DevtoolsProject $project */
                $project = $this->installation->getProject();
@@ -61,6 +60,16 @@ trait TXmlGuiPackageInstallationPlugin {
                $xml->write($project->path . ($project->getPackage()->package === 'com.woltlab.wcf' ? 'com.woltlab.wcf/' : '') . 'tmp_' . static::getDefaultFilename());
        }
        
+       /**
+        * Creates a new XML element for the given document using the data provided
+        * by the given form and return the new dom element.
+        * 
+        * @param       \DOMDocument            $document
+        * @param       IFormDocument           $form
+        * @return      \DOMElement
+        */
+       abstract protected function createXmlElement(\DOMDocument $document, IFormDocument $form);
+       
        /**
         * Edits the entry of this pip with the given identifier based on the data
         * provided by the given form and returns the new identifier of the entry
@@ -74,16 +83,14 @@ trait TXmlGuiPackageInstallationPlugin {
                $xml = $this->getProjectXml();
                $document = $xml->getDocument();
                
-               // remove old element
-               $element = $this->getElementByIdentifier($xml, $identifier);
-               DOMUtil::removeNode($element);
-               
                // add updated element
-               $newEntry = $this->writeEntry($document, $form);
+               $newElement = $this->createXmlElement($document, $form);
                
-               $this->saveObject($newEntry, $element);
+               // replace old element
+               $element = $this->getElementByIdentifier($xml, $identifier);
+               DOMUtil::replaceElement($element, $newElement, false);
                
-               $this->sortDocument($document);
+               $this->saveObject($newElement, $element);
                
                /** @var DevtoolsProject $project */
                $project = $this->installation->getProject();
@@ -92,7 +99,7 @@ trait TXmlGuiPackageInstallationPlugin {
                // $xml->write($this->getXmlFileLocation($project));
                $xml->write($project->path . ($project->getPackage()->package === 'com.woltlab.wcf' ? 'com.woltlab.wcf/' : '') . 'tmp_' . static::getDefaultFilename());
                
-               return $this->getElementIdentifier($newEntry);
+               return $this->getElementIdentifier($newElement);
        }
        
        /**
@@ -268,6 +275,16 @@ XML;
                return $project->path . ($project->getPackage()->package === 'com.woltlab.wcf' ? 'com.woltlab.wcf/' : '') . static::getDefaultFilename();
        }
        
+       /**
+        * Inserts the give new element into the given XML document.
+        * 
+        * @param       XML             $xml            XML document to which the element is added
+        * @param       \DOMElement     $newElement     added new element
+        */
+       protected function insertNewXmlElement(XML $xml, \DOMElement $newElement) {
+               $xml->xpath()->query('/ns:data/ns:import')->item(0)->appendChild($newElement);
+       }
+       
        /**
         * Saves an object represented by an XML element in the database by either
         * creating a new element (if `$oldElement = null`) or updating an existing
@@ -383,151 +400,4 @@ XML;
                
                $this->entryType = $entryType;
        }
-       
-       /**
-        * Sorts the entries of this pip that are represented by the given dom
-        * document to achieve a deterministic order.
-        * 
-        * @param       \DOMDocument    $document
-        */
-       abstract protected function sortDocument(\DOMDocument $document);
-       
-       /**
-        * Sorts the given child nodes of all nodes in the given node list by
-        * applying the given sort function on the child nodes.
-        * 
-        * Internally, the old child nodes are removed and appended again in
-        * the sorted order.
-        * 
-        * @param       \DOMNodeList    $nodeList
-        * @param       callable        $sortFunction
-        */
-       protected function sortChildNodes(\DOMNodeList $nodeList, callable $sortFunction) {
-               /** @var \DOMElement $node */
-               foreach ($nodeList as $node) {
-                       $childNodes = array_filter(iterator_to_array($node->childNodes), function($element) {
-                               return $element instanceof \DOMElement;
-                       });
-                       
-                       usort($childNodes, $sortFunction);
-                       
-                       // remove old nodes
-                       while ($node->hasChildNodes()) {
-                               $node->removeChild($node->firstChild);
-                       }
-                       
-                       // add sorted nodes
-                       foreach ($childNodes as $childNode) {
-                               $node->appendChild($childNode);
-                       }
-               }
-       }
-       
-       /**
-        * Sorts the standard `import` and `delete` blocks and ensures that the
-        * `import` block is before the `delete` block.
-        * 
-        * @param       \DOMDocument    $document
-        */
-       protected function sortImportDelete(\DOMDocument $document) {
-               switch ($document->documentElement->childNodes->length) {
-                       case 0:
-                               throw new \InvalidArgumentException('Empty xml document.');
-                       
-                       case 1:
-                               // nothing to sort
-                               break;
-                       
-                       case 2:
-                               $firstChild = $document->documentElement->firstChild;
-                               $lastChild = $document->documentElement->lastChild;
-                               
-                               if (!($firstChild->nodeName === 'import' && $lastChild->nodeName === 'delete') && !($firstChild->nodeName === 'delete' && $lastChild->nodeName === 'import')) {
-                                       throw new \InvalidArgumentException('Invalid xml given.');
-                               }
-                               
-                               if ($document->documentElement->firstChild->nodeName !== 'import') {
-                                       $firstChild = $document->documentElement->firstChild;
-                                       $document->documentElement->removeChild($firstChild);
-                                       $document->documentElement->appendChild($firstChild);
-                               }
-                               break;
-                       
-                       default:
-                               throw new \InvalidArgumentException('Xml document has more than two direct children.');
-               }
-       }
-       
-       /**
-        * Writes a new entry into the xml structure represented by the given
-        * dom document using the data provided by the given form and return
-        * the new dom element.
-        * 
-        * Note: Inserting at the correct position regarding sorting is irrelevant
-        * as the dom document will be sorted after adding the entry.
-        * 
-        * @param       \DOMDocument            $document
-        * @param       IFormDocument           $form
-        * @return      \DOMElement
-        */
-       abstract protected function writeEntry(\DOMDocument $document, IFormDocument $form);
-       
-       /**
-        * Returns a sort function for DOM elements using the list of attributes
-        * and child elements by whose values the DOM elements are sorted.
-        * 
-        * @param       array   $sortParameters
-        * @return      \Closure
-        */
-       public static function getSortFunction(array $sortParameters) {
-               return function(\DOMElement $element1, \DOMElement $element2) use ($sortParameters) {
-                       foreach ($sortParameters as $sortParameter) {
-                               if (is_array($sortParameter)) {
-                                       $isAttribute = !empty($sortParameter['isAttribute']);
-                                       $name = $sortParameter['name'];
-                                       $missingLast = !empty($sortParameter['missingLast']);
-                               }
-                               else {
-                                       $isAttribute = false;
-                                       $name = $sortParameter;
-                                       $missingLast = true;
-                               }
-                               
-                               $value1 = $value2 = null;
-                               if ($isAttribute) {
-                                       $value1 = $element1->getAttribute($name);
-                                       $value2 = $element2->getAttribute($name);
-                               }
-                               else {
-                                       $value1Node = $element1->getElementsByTagName($name)->item(0);
-                                       if ($value1Node !== null) {
-                                               $value1 = $value1Node->nodeValue;
-                                       }
-                                       
-                                       $value2Node = $element2->getElementsByTagName($name)->item(0);
-                                       if ($value2Node !== null) {
-                                               $value2 = $value2Node->nodeValue;
-                                       }
-                               }
-                               
-                               if ($value1 !== null) {
-                                       if ($value2 !== null) {
-                                               $compare = $value1 <=> $value2;
-                                               
-                                               if ($compare !== 0) {
-                                                       return $compare;
-                                               }
-                                       }
-                                       else {
-                                               return $missingLast ? -1 : 1;
-                                       }
-                               }
-                               else if ($value2 !== null) {
-                                       return $missingLast ? 1 : -1;
-                               }
-                       }
-                       
-                       return -1;
-               };
-       }
 }
index 00ebb2a54aecb2a1a1f63fe56b339a401b21f0a6..c4da644ad908cfee22d6822a6d1510b7ff79dfcd 100644 (file)
@@ -597,18 +597,7 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               // do not sort options and categories as their position in the XML
-               // file implies the order in which they are shown in the frontend
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData()['data'];
                
                switch ($this->entryType) {
@@ -618,15 +607,6 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati
                                
                                $category->appendChild($document->createElement('objecttype', $formData['objecttype']));
                                
-                               $import = $document->getElementsByTagName('import')->item(0);
-                               $categories = $import->getElementsByTagName('categories')->item(0);
-                               if ($categories === null) {
-                                       $categories = $document->createElement('categories');
-                                       $import->appendChild($categories);
-                               }
-                               
-                               $categories->appendChild($category);
-                               
                                return $category;
                                
                        case 'options':
@@ -639,15 +619,6 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati
                                        $option->appendChild($document->createElement('categoryname', $formData['categoryname']));
                                }
                                
-                               $import = $document->getElementsByTagName('import')->item(0);
-                               $options = $import->getElementsByTagName('options')->item(0);
-                               if ($options === null) {
-                                       $options = $document->createElement('options');
-                                       $import->appendChild($options);
-                               }
-                               
-                               $options->appendChild($option);
-                               
                                return $option;
                }
                
index 3782a6f97cd4dcac49f57a2166bbe0430e040c6e..1a6b71be25c242e60f2915fcc4350f6ef18a6a25 100644 (file)
@@ -143,10 +143,10 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl
         * @inheritDoc
         * @since       3.2
         */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData()['data'];
                
-               $menuItem = parent::writeEntry($document, $form);
+               $menuItem = parent::createXmlElement($document, $form);
                
                if (isset($formData['icon'])) {
                        $menuItem->appendChild($document->createElement('icon', $formData['icon']));
index 268fd15abe4bf91c15026283e32b3ce9a693879d..dfcb1bf64cf248b2ebb7e8cb007d327e06855e1a 100644 (file)
@@ -198,42 +198,7 @@ class ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInsta
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), function(\DOMElement $element1, \DOMElement $element2) {
-                       $showOrder1 = PHP_INT_MAX;
-                       if ($element1->getElementsByTagName('showorder')->length === 1) {
-                               $showOrder1 = $element1->getElementsByTagName('showorder')->item(0)->nodeValue;
-                       }
-                       
-                       $showOrder2 = PHP_INT_MAX;
-                       if ($element2->getElementsByTagName('showorder')->length === 1) {
-                               $showOrder2 = $element2->getElementsByTagName('showorder')->item(0)->nodeValue;
-                       }
-                       
-                       if ($showOrder1 !== $showOrder2) {
-                               return $showOrder1 > $showOrder2;
-                       }
-                       
-                       return strcmp(
-                               $element1->getAttribute('name'),
-                               $element2->getAttribute('name')
-                       );
-               });
-               $this->sortChildNodes($document->getElementsByTagName('delete'), function(\DOMElement $element1, \DOMElement $element2) {
-                       return strcmp(
-                               $element1->getAttribute('name'),
-                               $element2->getAttribute('name')
-                       );
-               });
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $acpSearchProvider = $document->createElement($this->tagName);
@@ -243,8 +208,6 @@ class ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInsta
                        $acpSearchProvider->appendChild($document->createElement('showorder', (string)$data['showorder']));
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($acpSearchProvider);
-               
                return $acpSearchProvider;
        }
 }
index 026cc5eecd1fb998c54b4ef6c3288a92036d5d31..68e468658cc00085086a6141684aff447a0761ee 100644 (file)
@@ -386,49 +386,7 @@ abstract class AbstractMenuPackageInstallationPlugin extends AbstractXMLPackageI
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $menuStructureData = $this->getMenuStructureData();
-               /** @var ACPMenuItem[][] $menuItemStructure */
-               $menuItemStructure = $menuStructureData['structure'];
-               
-               $this->sortImportDelete($document);
-               
-               // build array containing the ACP menu items saved in the database
-               // in the order as they would be displayed in the ACP
-               $buildPositions = function($parent = '') use ($menuItemStructure, &$buildPositions) {
-                       $positions = [];
-                       foreach ($menuItemStructure[$parent] as $menuItem) {
-                               // only consider menu items of the current package for positions
-                               if ($menuItem->packageID === $this->installation->getPackageID()) {
-                                       $positions[] = $menuItem->menuItem;
-                               }
-                               
-                               if (isset($menuItemStructure[$menuItem->menuItem])) {
-                                       $positions = array_merge($positions, $buildPositions($menuItem->menuItem));
-                               }
-                       }
-                       
-                       return $positions;
-               };
-               
-               // flip positions array so that the keys are the menu item names
-               // and the values become the positions so that the array values
-               // can be used in the sort function
-               $positions = array_flip($buildPositions());
-               
-               $compareFunction = function(\DOMElement $element1, \DOMElement $element2) use ($positions) {
-                       return $positions[$element1->getAttribute('name')] <=> $positions[$element2->getAttribute('name')];
-               };
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $compareFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $compareFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData()['data'];
                
                $menuItem = $document->createElement($this->tagName);
@@ -440,8 +398,6 @@ abstract class AbstractMenuPackageInstallationPlugin extends AbstractXMLPackageI
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($menuItem);
-               
                return $menuItem;
        }
 }
index 951db47d73eb7936513c0f62aa370b39b95ce822..dbd82802961a43de1e7428b59f808186257ce7eb 100644 (file)
@@ -29,6 +29,7 @@ use wcf\system\Regex;
 use wcf\system\WCF;
 use wcf\util\DirectoryUtil;
 use wcf\util\StringUtil;
+use wcf\util\XML;
 
 /**
  * Abstract implementation of a package installation plugin for options.
@@ -942,107 +943,9 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               // `<categories>` before `<options>`
-               $compareFunction = function(\DOMElement $element1, \DOMElement $element2) {
-                       if ($element1->nodeName === 'categories') {
-                               return -1;
-                       }
-                       else if ($element2->nodeName === 'categories') {
-                               return 1;
-                       }
-                       
-                       return 0;
-               };
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $compareFunction);
-               
-               $xpath = new \DOMXPath($document);
-               $xpath->registerNamespace('ns', $document->documentElement->getAttribute('xmlns'));
-               
-               // sort categories
-               $categoryOrder = array_flip(array_keys($this->getSortedCategories()));
-               
-               $this->sortChildNodes(
-                       $xpath->query('/ns:data/ns:import/ns:categories'),
-                       function(\DOMElement $category1, \DOMElement $category2) use ($categoryOrder) {
-                               return $categoryOrder[$category1->getAttribute('name')] <=> $categoryOrder[$category2->getAttribute('name')];
-                       }
-               );
-               
-               // sort options
-               $this->sortChildNodes(
-                       $xpath->query('/ns:data/ns:import/ns:options'),
-                       function(\DOMElement $option1, \DOMElement $option2) use ($categoryOrder) {
-                               $category1 = $option1->getElementsByTagName('categoryname')->item(0)->nodeValue;
-                               $category2 = $option2->getElementsByTagName('categoryname')->item(0)->nodeValue;
-                               
-                               if ($category1 !== 'hidden') {
-                                       if ($category2 !== 'hidden') {
-                                               $cmp = $categoryOrder[$category1] <=> $categoryOrder[$category2];
-                                               
-                                               if ($cmp === 0) {
-                                                       $showOrder1 = $option1->getElementsByTagName('showorder')->item(0);
-                                                       $showOrder2 = $option2->getElementsByTagName('showorder')->item(0);
-                                                       
-                                                       if ($showOrder1 !== null) {
-                                                               if ($showOrder2 !== null) {
-                                                                       return $showOrder1->nodeValue <=> $showOrder2->nodeValue;
-                                                               }
-                                                               
-                                                               return -1;
-                                                       }
-                                                       else if ($showOrder2 !== null) {
-                                                               return 1;
-                                                       }
-                                                       
-                                                       return strcmp($option1->nodeValue, $option2->nodeValue);
-                                               }
-                                               
-                                               return $cmp;
-                                       }
-                                       
-                                       return -1;
-                               }
-                               else if ($category2 !== 'hidden') {
-                                       return 1;
-                               }
-                               
-                               return strcmp($option1->nodeValue, $option2->nodeValue);
-                       }
-               );
-               
-               // sort deleted elements
-               $this->sortChildNodes($document->getElementsByTagName('delete'), function(\DOMElement $element1, \DOMElement $element2) use ($categoryOrder) {
-                       if ($element1->nodeName === 'optioncategory') {
-                               if ($element2->nodeName === 'optioncategory') {
-                                       return $categoryOrder[$element1->getAttribute('name')] <=> $categoryOrder[$element2->getAttribute('name')];
-                               }
-                               else {
-                                       return -1;
-                               }
-                       }
-                       else if ($element2->nodeName === 'optioncategory') {
-                               return 1;
-                       }
-                       
-                       // two options
-                       return strcmp($element1->nodeName, $element2->nodeName);
-               });
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData()['data'];
                
-               $xpath = new \DOMXPath($document);
-               $xpath->registerNamespace('ns', $document->documentElement->getAttribute('xmlns'));
-               
                switch ($this->entryType) {
                        case 'categories':
                                $category = $document->createElement('category');
@@ -1092,12 +995,40 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag
                                        }
                                }
                                
-                               $xpath->query('/ns:data/ns:import/ns:options')->item(0)->appendChild($option);
-                               
                                return $option;
                        
                        default:
                                throw new \LogicException('Unreachable');
                }
        }
+       
+       /**
+        * @inheritDoc
+        * @since       3.2
+        */
+       protected function insertNewXmlElement(XML $xml, \DOMElement $newElement) {
+               switch ($this->entryType) {
+                       case 'categories':
+                               $categories = $xml->xpath()->query('/ns:data/ns:import/ns:categories')->item(0);
+                               if ($categories === null) {
+                                       $categories = $xml->getDocument()->createElement('categories');
+                                       $xml->xpath()->query('/ns:data/ns:import')->item(0)->appendChild($categories);
+                               }
+                               
+                               $categories->appendChild($newElement);
+                               
+                               break;
+                       
+                       case 'options':
+                               $options = $xml->xpath()->query('/ns:data/ns:import/ns:options')->item(0);
+                               if ($options === null) {
+                                       $categories = $xml->getDocument()->createElement('options');
+                                       $xml->xpath()->query('/ns:data/ns:import')->item(0)->appendChild($categories);
+                               }
+                               
+                               $options->appendChild($newElement);
+                               
+                               break;
+               }
+       }
 }
index 635a8926180fa49f6baf772ddcb92bebbae36d1f..45c7823674e689c82117539f2da3192ff4a94cfe 100644 (file)
@@ -494,25 +494,7 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $compareFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $compareFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $compareFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $bbcode = $document->createElement($this->tagName);
@@ -559,8 +541,6 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($bbcode);
-               
                return $bbcode;
        }
 }
index c9c1372727029c867512794c34aa5938ecdd8481..0562465403ad8e2983acc0691876015796980830 100644 (file)
@@ -759,25 +759,7 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'identifier'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData();
                $data = $formData['data'];
                
@@ -871,8 +853,6 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($box);
-               
                return $box;
        }
 }
index e1c1b2bb0061ce5d6ac9363bc28885f83b29a97f..0ded11205c06911132f263082fdb9f3c09723adc 100644 (file)
@@ -293,27 +293,7 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       'actionclassname',
-                       'showorder',
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData();
                $data = $formData['data'];
                
@@ -333,8 +313,6 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall
                        $pages->appendChild($document->createElement('page', $page));
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($clipboardAction);
-               
                return $clipboardAction;
        }
 }
index 110eb2bec0b802db5569f50afdf69df58ab0ce0a..acbc37655fac24cd5dcbda346a77b494b8714086 100644 (file)
@@ -155,28 +155,13 @@ class CoreObjectPackageInstallationPlugin extends AbstractXMLPackageInstallation
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction(['objectname']);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $coreObject = $document->createElement($this->tagName);
                
                $coreObject->appendChild($document->createElement('objectname', $data['objectname']));
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($coreObject);
-               
                return $coreObject;
        }
 }
index 0e225b154a40918a9b6c26ee9a957d53a681e51b..3e237ab21f262a06a790808d0333e2806d5c68f3 100644 (file)
@@ -334,26 +334,7 @@ class CronjobPackageInstallationPlugin extends AbstractXMLPackageInstallationPlu
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ],
-                       'classname'
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData();
                $formData = $form->getData()['data'];
                
@@ -408,8 +389,6 @@ class CronjobPackageInstallationPlugin extends AbstractXMLPackageInstallationPlu
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($cronjob);
-               
                return $cronjob;
        }
 }
index d1e1ac856694ec9381daa25db6219ad94b361138..2af03334ce85655e113040a57749bbc49b4fa7cc 100644 (file)
@@ -328,25 +328,7 @@ class EventListenerPackageInstallationPlugin extends AbstractXMLPackageInstallat
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $eventListener = $document->createElement($this->tagName);
@@ -362,8 +344,6 @@ class EventListenerPackageInstallationPlugin extends AbstractXMLPackageInstallat
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($eventListener);
-               
                return $eventListener;
        }
 }
index 0b24b98a5f2d2733c1cf2a61775583ad346f96b7..e422ea05ffb86b01e321dfd44f66e49fd0a4d519 100644 (file)
@@ -725,23 +725,7 @@ XML;
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->childNodes, $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('category'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $languageCode = $document->documentElement->getAttribute('languagecode');
index b6cfab01dd350ca8f558c9ca810717da85c5718a..ab795b2881e5634ac40cb8db947afdca8d58ed1d 100644 (file)
@@ -225,25 +225,7 @@ class MediaProviderPackageInstallationPlugin extends AbstractXMLPackageInstallat
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $provider = $document->createElement($this->tagName);
@@ -267,8 +249,6 @@ class MediaProviderPackageInstallationPlugin extends AbstractXMLPackageInstallat
                        $provider->appendChild($document->createElement('className', $data['className']));
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($provider);
-               
                return $provider;
        }
 }
index 30594957704d2f73081f6471157efbced74bf7d6..e0d6dbe2b1f64ed126fb315e232fa5325a680f50 100644 (file)
@@ -530,24 +530,7 @@ class MenuItemPackageInstallationPlugin extends AbstractXMLPackageInstallationPl
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               // do not support imported menu items automatically
-               
-               $this->sortChildNodes($document->getElementsByTagName('delete'), static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'identifier'
-                       ]
-               ]));
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData();
                $data = $formData['data'];
                
@@ -574,8 +557,6 @@ class MenuItemPackageInstallationPlugin extends AbstractXMLPackageInstallationPl
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($menuItem);
-               
                return $menuItem;
        }
 }
index 3dfc2229d6eb9ef4cd7bbc6e8e3d3294f9070930..32df39d2caa8bd472419d2081e823dd4f7249a53 100644 (file)
@@ -520,25 +520,7 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'identifier'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData();
                
                if ($formData['data']['identifier'] === 'com.woltlab.wcf.MainMenu') {
@@ -578,8 +560,6 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        $menu->appendChild($box);
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($menu);
-               
                return $menu;
        }
 }
index 0362ac6b9677eece82ed6ee8b204cb8731ba01ca..8098bee288e948a72fc2d646b6150faf337f23ae 100644 (file)
@@ -209,23 +209,7 @@ class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageIn
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), static::getSortFunction(['name']));
-               $this->sortChildNodes($document->getElementsByTagName('delete'), static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]));
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $definition = $document->createElement($this->tagName);
@@ -235,9 +219,6 @@ class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageIn
                        $definition->appendChild($document->createElement('interfacename', $data['interfacename']));
                }
                
-               $import = $document->getElementsByTagName('import')->item(0);
-               $import->appendChild($definition);
-               
                return $definition;
        }
 }
index ae6bcef24f993e25be4de940b9dfe7c727c960fb..c44546a1e408abca15d8ab3fe180bde7b914b3f0 100644 (file)
@@ -695,52 +695,7 @@ XML;
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), static::getSortFunction(['definitionname', 'name']));
-               
-               $this->sortChildNodes($document->getElementsByTagName('import')->item(0)->childNodes, function(\DOMElement $element1, \DOMElement $element2) {
-                       // force `definitionname` to be at the first position
-                       if ($element1->nodeName === 'definitionname') {
-                               return -1;
-                       }
-                       else if ($element2->nodeName === 'definitionname') {
-                               return 1;
-                       }
-                       // force `name` to be at the second position
-                       else if ($element1->nodeName === 'name') {
-                               return -1;
-                       }
-                       else if ($element2->nodeName === 'name') {
-                               return 1;
-                       }
-                       // force `classname` to be at the third position
-                       else if ($element1->nodeName === 'classname') {
-                               return -1;
-                       }
-                       else if ($element2->nodeName === 'classname') {
-                               return 1;
-                       }
-                       else {
-                               // the rest is sorted by node name
-                               return strcmp($element1->nodeName, $element2->nodeName);
-                       }
-               });
-               
-               $this->sortChildNodes($document->getElementsByTagName('delete'), static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]));
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $type = $document->createElement($this->tagName);
                foreach ($form->getData()['data'] as $key => $value) {
                        if ($key === 'definitionID') {
@@ -758,8 +713,6 @@ XML;
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($type);
-               
                return $type;
        }
        
index cc3ec00f1370947dea95bf4e9c4a2f4e630b423d..55396d3ea1ddbc669ee8066b12631630627289e2 100644 (file)
@@ -249,7 +249,7 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP
         * @since       3.2
         */
        protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
-               $option = parent::writeEntry($document, $form);
+               $option = parent::createXmlElement($document, $form);
                
                $formData = $form->getData()['data'];
                
index 7202fe7ec6014cfb0dd1c38372b7c6c3c98b68d3..30a43f2914cf33c8fef3eeb74cb58bdef0a0f18e 100644 (file)
@@ -179,34 +179,11 @@ class PIPPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
+               $data = $form->getData()['data'];
                
-               $sortFunction = static::getSortFunction([
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
-               /** @var TextFormField $className */
-               $className = $form->getNodeById('className');
-               /** @var TextFormField $pluginName */
-               $pluginName = $form->getNodeById('pluginName');
-               
-               $pip = $document->createElement($this->tagName, $className->getSaveValue());
-               $pip->setAttribute('name', $pluginName->getSaveValue());
-               
-               $document->getElementsByTagName('import')->item(0)->appendChild($pip);
+               $pip = $document->createElement($this->tagName, $data['className']);
+               $pip->setAttribute('name', $data['name']);
                
                return $pip;
        }
index 393f400bbeca1361804c0f66d6e1dcb339e3d486..a0ca0960ae2298b07f211a4e187b5818db689d20 100644 (file)
@@ -750,25 +750,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = function(\DOMElement $element1, \DOMElement $element2) {
-                       return strcmp(
-                               $element1->getAttribute('identifier'),
-                               $element2->getAttribute('identifier')
-                       );
-               };
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData();
                $data = $formData['data'];
                
@@ -832,8 +814,6 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($page);
-               
                return $page;
        }
 }
index f9bd5e8c465754000bdd52f77efcb35ef0fb53ec..3d8605cb4d02f5bf8e0f8d56e11c004079530751 100644 (file)
@@ -262,33 +262,14 @@ class SmileyPackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $compareFunction = static::getSortFunction([
-                       'showOrder',
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $compareFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $compareFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
-               $bbcode = $document->createElement($this->tagName);
-               $bbcode->setAttribute('name', $data['name']);
+               $smiley = $document->createElement($this->tagName);
+               $smiley->setAttribute('name', $data['name']);
                
                foreach (['title', 'path', 'path2x'] as $element) {
-                       $bbcode->appendChild($document->createElement($element, $data[$element]));
+                       $smiley->appendChild($document->createElement($element, $data[$element]));
                }
                
                if ($data['aliases'] !== '') {
@@ -296,15 +277,13 @@ class SmileyPackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                        $aliases->appendChild($document->createCDATASection(
                                StringUtil::escapeCDATA(StringUtil::unifyNewlines($data['aliases']))
                        ));
-                       $bbcode->appendChild($aliases);
+                       $smiley->appendChild($aliases);
                }
                
                if ($data['showorder'] !== null) {
-                       $bbcode->appendChild($document->createElement('showorder', $data['showorder']));
+                       $smiley->appendChild($document->createElement('showorder', $data['showorder']));
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($bbcode);
-               
-               return $bbcode;
+               return $smiley;
        }
 }
index 71ce08378c016d90eebf0aee17997576e1f489a2..2dae6cf65626b02bf2b937563f53deb9167b95a1 100644 (file)
@@ -423,20 +423,7 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction(['templatename', 'eventname', 'environment']);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $listener = $document->createElement($this->tagName);
@@ -450,8 +437,6 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal
                $templateCode->appendChild($document->createCDATASection(StringUtil::unifyNewlines(StringUtil::escapeCDATA($data['templatecode']))));
                $listener->appendChild($templateCode);
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($listener);
-               
                return $listener;
        }
 }
index 596bd7347d7321cf1af2de3ec834368a005db1f6..56c487e54ac483a64bad1c1445a97a5a8e858ba4 100644 (file)
@@ -317,8 +317,8 @@ class UserGroupOptionPackageInstallationPlugin extends AbstractOptionPackageInst
         * @inheritDoc
         * @since       3.2
         */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
-               $option = parent::writeEntry($document, $form);
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
+               $option = parent::createXmlElement($document, $form);
                
                $formData = $form->getData()['data'];
                
index f03d663e75189fd8d3651a6dc90cb8803159043e..037e311dccb5b51c9b3c9c5fdaeca8b17ac1f25e 100644 (file)
@@ -145,10 +145,10 @@ class UserMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationP
         * @inheritDoc
         * @since       3.2
         */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $formData = $form->getData()['data'];
                
-               $menuItem = parent::writeEntry($document, $form);
+               $menuItem = parent::createXmlElement($document, $form);
                
                if (!empty($formData['classname'])) {
                        $menuItem->appendChild($document->createElement('classname', $formData['classname']));
index b3acec99e678ec2e114e555aea2e19463384b77d..3455c4049ad66d3cead33e6747b3c30a76031638 100644 (file)
@@ -352,20 +352,7 @@ class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageI
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction(['objecttype', 'name']);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $event = $document->createElement($this->tagName);
@@ -390,8 +377,6 @@ class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageI
                        }
                }
                
-               $document->getElementsByTagName('import')->item(0)->appendChild($event);
-               
                return $event;
        }
 }
index d07ffdb53c1da4dd7ec53667c3f5621fec49209f..0e03663cd296da5036f37d1690b5851696e6250f 100644 (file)
@@ -369,8 +369,8 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
         * @inheritDoc
         * @since       3.2
         */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
-               $option = parent::writeEntry($document, $form);
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
+               $option = parent::createXmlElement($document, $form);
                
                $formData = $form->getData()['data'];
                
index a51ab44af002642cb8691aa50e837ae218e8f290..fceba3f7cc6868055edcabb89c1a83f436aabd58 100644 (file)
@@ -226,26 +226,7 @@ class UserProfileMenuPackageInstallationPlugin extends AbstractXMLPackageInstall
         * @inheritDoc
         * @since       3.2
         */
-       protected function sortDocument(\DOMDocument $document) {
-               $this->sortImportDelete($document);
-               
-               $sortFunction = static::getSortFunction([
-                       'showorder',
-                       [
-                               'isAttribute' => 1,
-                               'name' => 'name'
-                       ]
-               ]);
-               
-               $this->sortChildNodes($document->getElementsByTagName('import'), $sortFunction);
-               $this->sortChildNodes($document->getElementsByTagName('delete'), $sortFunction);
-       }
-       
-       /**
-        * @inheritDoc
-        * @since       3.2
-        */
-       protected function writeEntry(\DOMDocument $document, IFormDocument $form) {
+       protected function createXmlElement(\DOMDocument $document, IFormDocument $form) {
                $data = $form->getData()['data'];
                
                $userProfileMenuItem = $document->createElement($this->tagName);
@@ -263,9 +244,6 @@ class UserProfileMenuPackageInstallationPlugin extends AbstractXMLPackageInstall
                        }
                }
                
-               $import = $document->getElementsByTagName('import')->item(0);
-               $import->appendChild($userProfileMenuItem);
-               
                return $userProfileMenuItem;
        }
 }