From: Alexander Ebert Date: Tue, 17 Jan 2017 13:39:34 +0000 (+0100) Subject: Fixed style export, import and update X-Git-Tag: 3.0.1~27 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=51cbba83bea2c42b2d0f0b95c3dae2373216b078;p=GitHub%2FWoltLab%2FWCF.git Fixed style export, import and update --- diff --git a/com.woltlab.wcf/defaultStyle.tar b/com.woltlab.wcf/defaultStyle.tar index 3e3e92329a..c30b05767a 100644 Binary files a/com.woltlab.wcf/defaultStyle.tar and b/com.woltlab.wcf/defaultStyle.tar differ diff --git a/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php index 12b9eebbe7..914265b962 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php @@ -118,7 +118,7 @@ class StyleExportForm extends AbstractForm { // export style $styleEditor = new StyleEditor($this->style); - $styleEditor->export($this->exportTemplates, $this->exportImages, $this->style->packageName); + $styleEditor->export($this->exportTemplates, $this->exportImages, ($this->exportAsPackage ? $this->style->packageName : '')); // call saved event $this->saved(); diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index aa6d36d637..6cc3ffffbf 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -19,6 +19,7 @@ use wcf\system\language\LanguageFactory; use wcf\system\package\PackageArchive; use wcf\system\style\StyleCompiler; use wcf\system\Regex; +use wcf\system\style\StyleHandler; use wcf\system\WCF; use wcf\util\DateUtil; use wcf\util\FileUtil; @@ -144,7 +145,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $data = [ 'name' => '', 'description' => [], 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, 'license' => '', 'authorName' => '', 'authorURL' => '', 'templates' => '', 'images' => '', - 'variables' => '', 'date' => '0000-00-00', 'imagesPath' => '' + 'variables' => '', 'date' => '0000-00-00', 'imagesPath' => '', 'packageName' => '' ]; $categories = $xpath->query('/ns:style/*'); @@ -201,6 +202,10 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $data['name'] = $element->nodeValue; break; + case 'packageName': + $data['packageName'] = $element->nodeValue; + break; + case 'version': if (!Package::isValidVersion($element->nodeValue)) { throw new SystemException("style version '".$element->nodeValue."' is invalid"); @@ -313,9 +318,15 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject 'copyright' => $data['copyright'], 'license' => $data['license'], 'authorName' => $data['authorName'], - 'authorURL' => $data['authorURL'] + 'authorURL' => $data['authorURL'], + 'packageName' => $data['packageName'] ]; + // check if there is an untainted style with the same package name + if ($style === null && !empty($styleData['packageName'])) { + $style = StyleHandler::getInstance()->getStyleByName($styleData['packageName'], true); + } + // import images if (!empty($data['images']) && $data['imagesPath'] != 'images/') { // create images folder if necessary @@ -519,6 +530,8 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject unset($styleData['styleName']); $variables = $style->getVariables(); + if (!isset($styleData['variables']['individualScss'])) $styleData['variables']['individualScss'] = ''; + if (!isset($styleData['variables']['overrideScss'])) $styleData['variables']['overrideScss'] = ''; $individualScss = Style::splitLessVariables($variables['individualScss']); $variables['individualScss'] = Style::joinLessVariables($styleData['variables']['individualScss'], $individualScss['custom']); @@ -606,6 +619,9 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $index = ($index === null ? 2 : ($index + 1)); } while (true); + + // this should never happen + throw new \LogicException(); } /** @@ -642,6 +658,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject // general block $xml->startElement('general'); $xml->writeElement('stylename', $this->styleName); + $xml->writeElement('packageName', $this->packageName); // style description foreach ($styleDescriptions as $languageCode => $value) {