Fixes template handling during style export
authorMatthias Schmidt <gravatronics@live.com>
Wed, 18 Dec 2013 17:44:06 +0000 (18:44 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 18 Dec 2013 17:44:06 +0000 (18:44 +0100)
Fixes #1595

wcfsetup/install/files/lib/data/style/StyleEditor.class.php

index 5de7012b2d487ee2fc1732abc807e6b5f77959bb..1add0db2cb4c6399a9d23a547a47155550da02fe 100644 (file)
@@ -2,11 +2,13 @@
 namespace wcf\data\style;
 use wcf\data\language\LanguageList;
 use wcf\data\package\Package;
+use wcf\data\package\PackageCache;
 use wcf\data\template\group\TemplateGroup;
 use wcf\data\template\group\TemplateGroupAction;
 use wcf\data\template\TemplateEditor;
 use wcf\data\DatabaseObjectEditor;
 use wcf\data\IEditableCachedObject;
+use wcf\system\application\ApplicationHandler;
 use wcf\system\cache\builder\StyleCacheBuilder;
 use wcf\system\exception\SystemException;
 use wcf\system\image\ImageHandler;
@@ -656,7 +658,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        
                        // append templates to tar
                        // get templates
-                       $sql = "SELECT          template.*, package.package, package.packageDir
+                       $sql = "SELECT          template.*, package.package
                                FROM            wcf".WCF_N."_template template
                                LEFT JOIN       wcf".WCF_N."_package package
                                ON              (package.packageID = template.packageID)
@@ -665,9 +667,17 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        $statement->execute(array($this->templateGroupID));
                        while ($row = $statement->fetchArray()) {
                                $packageDir = 'com.woltlab.wcf';
-                               if (!empty($row['packageDir'])) $packageDir = $row['package'];
                                
-                               $filename = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $row['packageDir'] . 'templates/' . $templateGroup->templateGroupFolderName)) . $row['templateName'] . '.tpl';
+                               if ($row['application'] != 'wcf') {
+                                       $application = ApplicationHandler::getInstance()->getApplication($row['application']);
+                                       $packageDir = $row['package'];
+                               }
+                               else {
+                                       $application = ApplicationHandler::getInstance()->getWCF();
+                               }
+                               $package = PackageCache::getInstance()->getPackage($application->packageID);
+                               
+                               $filename = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->packageDir . 'templates/' . $templateGroup->templateGroupFolderName)) . $row['templateName'] . '.tpl';
                                $templatesTar->add($filename, $packageDir, dirname($filename));
                        }