From 13be5e885f85a5a878d9e2d8337af74c2ed8bbc1 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 13 Oct 2012 20:26:48 +0200 Subject: [PATCH] Style export now uses XMLWriter --- .../lib/data/style/StyleEditor.class.php | 86 +++++++++---------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index c7fe4bb007..230cbd0748 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -1,5 +1,7 @@ \n"; + $xml->startElement('files'); + $xml->writeElement('variables', 'variables.xml'); + if ($templates) $xml->writeElement('templates', 'templates.tar'); + if ($images) $xml->writeElement('images', 'images.tar'); + if ($icons) $xml->writeElement('icons', 'icons.tar'); + $xml->endElement(); + // append style info file to style tar - $styleTar->addString(self::INFO_FILE, $string); + $styleTar->addString(self::INFO_FILE, $xml->endDocument()); unset($string); // create variable list - $string = "\n\n"; + $xml->beginDocument('variables', 'http://www.woltlab.com', 'http://www.woltlab.com/XSD/maelstrom/styleVariables.xsd'); // get variables $sql = "SELECT variable.variableName, value.variableValue @@ -595,12 +596,11 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->styleID)); while ($row = $statement->fetchArray()) { - $string .= "\t\n"; + $xml->writeElement('variable', $row['variableValue'], array('name' => $row['variableName'])); } - $string .= ""; // append variable list to style tar - $styleTar->addString('variables.xml', $string); + $styleTar->addString('variables.xml', $xml->endDocument()); unset($string); if ($templates && $this->templateGroupID) { @@ -703,28 +703,26 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $packageTar->add($styleTarName, '', dirname($styleTarName)); // create package.xml - $string = "\n\n"; - - $string .= "\t\n"; - $string .= "\t\tstyleName)."]]>\n"; - $string .= "\t\tstyleDescription)."]]>\n"; - $string .= "\t\tstyleVersion)."]]>\n"; - $string .= "\t\tstyleDate)."]]>\n"; - $string .= "\t\n"; + $xml->beginDocument('package', 'http://www.woltlab.com', 'http://www.woltlab.com/XSD/maelstrom/package.xsd', array('name' => $packageName)); - $string .= "\t\n"; - $string .= "\t\tauthorName)."]]>\n"; - if ($this->authorURL) $string .= "\t\tauthorURL)."]]>\n"; - $string .= "\t\n"; + $xml->startElement('packageinformation'); + $xml->writeElement('packagename', $this->styleName); + $xml->writeElement('packagedescription', $this->styleDescription); + $xml->writeElement('version', $this->styleVersion); + $xml->writeElement('date', $this->styleDate); + $xml->endElement(); - $string .= "\t\n"; - $string .= "\t\t".basename($styleTarName)."\n"; - $string .= "\t\n"; + $xml->startElement('authorinformation'); + $xml->writeElement('author', $this->authorName); + if ($this->authorURL) $xml->writeElement('authorurl', $this->authorURL); + $xml->endElement(); - $string .= "\n"; + $xml->startElement('instructions', array('name' => 'install')); + $xml->writeElement('instruction', basename($styleTarName), array('type' => 'style')); + $xml->endElement(); // append package info file to package tar - $packageTar->addString(PackageArchive::INFO_FILE, $string); + $packageTar->addString(PackageArchive::INFO_FILE, $xml->endDocument()); $packageTar->create(); readfile($packageTarName); -- 2.20.1