Fixed import of previously saved options
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jul 2013 11:13:34 +0000 (13:13 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jul 2013 11:13:34 +0000 (13:13 +0200)
wcfsetup/install/files/lib/acp/form/OptionImportForm.class.php

index 962a26d8ca20332cc84c3d268ba22f55f921f6ec..e072287a711339389f7b6a38acc05d63914921de 100755 (executable)
@@ -63,24 +63,11 @@ class OptionImportForm extends AbstractForm {
                        }
                        
                        try {
-                               $xml = new XML($this->optionImport['tmp_name']);
-                               $optionsXML = $xml->getElementTree('options');
-                               foreach ($optionsXML['children'] as $option) {
-                                       $name = $value = '';
-                                       foreach ($option['children'] as $optionData) {
-                                               switch ($optionData['name']) {
-                                                       case 'name':
-                                                               $name = $optionData['cdata'];
-                                                               break;
-                                                       case 'value':
-                                                               $value = $optionData['cdata'];
-                                                               break;
-                                               }
-                                       }
-                                       
-                                       if (!empty($name)) {
-                                               $this->options[$name] = $value;
-                                       }
+                               $xml = new XML();
+                               $xml->load($this->optionImport['tmp_name']);
+                               $xpath = $xml->xpath();
+                               foreach ($xpath->query('/options/option') as $option) {
+                                       $this->options[ $xpath->query('name', $option)->item(0)->nodeValue ] = $xpath->query('value', $option)->item(0)->nodeValue;
                                }
                        }
                        catch (SystemException $e) {