From 51cbba83bea2c42b2d0f0b95c3dae2373216b078 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 17 Jan 2017 14:39:34 +0100 Subject: [PATCH] Fixed style export, import and update --- com.woltlab.wcf/defaultStyle.tar | Bin 6144 -> 6144 bytes .../lib/acp/form/StyleExportForm.class.php | 2 +- .../lib/data/style/StyleEditor.class.php | 21 ++++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/com.woltlab.wcf/defaultStyle.tar b/com.woltlab.wcf/defaultStyle.tar index 3e3e92329a3c629263e7f2ea43729f4d1aa4c584..c30b05767a69a283cbd527f33a3eb3dcaa314069 100644 GIT binary patch delta 87 zcmZoLXfT-2B57)1#9(M_U~Fz;Xku(^#$aGzU}kJ;z+f<0kTGR5BcleBYC&Rhc4B&} kUt(^mU2=Y|UU_~_Nls#tUU_nwjXq3rvm)~*rbTQ*0Pv$37ytkO delta 52 zcmZoLXfT-2B57h|%3x?@Zf<}l_}OcND! I7qJNe07oSZA^-pY 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) { -- 2.20.1