From: Alexander Ebert Date: Sun, 26 Apr 2015 18:27:19 +0000 (+0200) Subject: Fixed copying style not copying image path X-Git-Tag: 2.1.4~42^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3ddc6107b4a2e9b02ad98c08bbbbec9e51d7a88d;p=GitHub%2FWoltLab%2FWCF.git Fixed copying style not copying image path --- diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index 8e120a3307..f16eb2b68c 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -511,6 +511,47 @@ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction } } + // copy images + if ($this->styleEditor->imagePath && is_dir(WCF_DIR . $this->styleEditor->imagePath)) { + $path = FileUtil::removeTrailingSlash($this->styleEditor->imagePath); + $newPath = ''; + $i = 2; + while (true) { + $newPath = "{$path}-{$i}/"; + if (!file_exists(WCF_DIR . $newPath)) { + break; + } + + $i++; + } + + if (!FileUtil::makePath(WCF_DIR . $newPath)) { + $newPath = ''; + } + + if ($newPath) { + $src = FileUtil::addTrailingSlash(WCF_DIR . $this->styleEditor->imagePath); + $dst = WCF_DIR . $newPath; + + $dir = opendir($src); + while (($file = readdir($dir)) !== false) { + if ($file != '.' && $file != '..' && !is_dir($file)) { + @copy($src . $file, $dst . $file); + } + } + closedir($dir); + } + + $sql = "UPDATE wcf".WCF_N."_style + SET imagePath = ? + WHERE styleID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + $newPath, + $newStyle->styleID + )); + } + StyleCacheBuilder::getInstance()->reset(); return array(