Fixed style import
authorMarcel Werk <burntime@woltlab.com>
Thu, 9 May 2013 22:29:38 +0000 (00:29 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 9 May 2013 22:29:38 +0000 (00:29 +0200)
Fixes #1266

wcfsetup/install/files/lib/acp/form/StyleImportForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 30ab01af77dab617d2744608c932e26f9c2fa045..1b64ee66cac915df205d24526162dc4d77f4f384 100644 (file)
@@ -62,11 +62,12 @@ class StyleImportForm extends AbstractForm {
                        throw new UserInputException('source', 'uploadFailed');
                }
                
-               // get filename
-               $this->source['name'] = FileUtil::getTemporaryFilename('style_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->source['name'])));
-               
-               if (!@move_uploaded_file($this->source['tmp_name'], $this->source['name'])) {
-                       throw new UserInputException('source', 'uploadFailed');
+               try {
+                       $this->style = StyleEditor::import($this->source['tmp_name']);
+               }
+               catch (\Exception $e) {
+                       @unlink($this->source['tmp_name']);
+                       throw new UserInputException('source', 'importFailed');
                }
        }
        
@@ -76,14 +77,7 @@ class StyleImportForm extends AbstractForm {
        public function save() {
                parent::save();
                
-               try {
-                       $this->style = StyleEditor::import($this->source['name']);
-               }
-               catch (\Exception $e) {
-                       @unlink($this->source['name']);
-               }
-               
-               @unlink($this->source['name']);
+               @unlink($this->source['tmp_name']);
                $this->saved();
                
                WCF::getTPL()->assign('success', true);
index 83ada744280d13d778158fbfaf9e9751a7cae3aa..3249586ef103cb1a49702849cb5c6e8cd3f1518c 100644 (file)
                <item name="wcf.acp.style.import.source"><![CDATA[Datenquelle]]></item>
                <item name="wcf.acp.style.import.source.upload"><![CDATA[Stil hochladen]]></item>
                <item name="wcf.acp.style.import.source.upload.description"><![CDATA[Geben Sie eine Stil-Datei von Ihrem lokalen Rechner an.]]></item>
+               <item name="wcf.acp.style.import.source.error.importFailed"><![CDATA[Der Stil konnte nicht importiert werden. Es handelt sich nicht um eine gültige Stil-Datei.]]></item>
                <item name="wcf.acp.style.license"><![CDATA[Lizenz]]></item>
                <item name="wcf.acp.style.list"><![CDATA[Stile auflisten]]></item>
                <item name="wcf.acp.style.packageName"><![CDATA[Paketbezeichner]]></item>
index dbe285b0d2fa2502dc623125cbb8c1803817da1d..65193576e6c7632e748cda3ecdddd8c461f95aff 100644 (file)
                <item name="wcf.acp.style.import.source"><![CDATA[Data Source]]></item>
                <item name="wcf.acp.style.import.source.upload"><![CDATA[Upload Style]]></item>
                <item name="wcf.acp.style.import.source.upload.description"><![CDATA[Upload a style from your local machine.]]></item>
+               <item name="wcf.acp.style.import.source.error.importFailed"><![CDATA[TODO: Der Stil konnte nicht importiert werden. Es handelt sich nicht um eine gültige Stil-Datei.]]></item>
                <item name="wcf.acp.style.license"><![CDATA[License]]></item>
                <item name="wcf.acp.style.list"><![CDATA[List Styles]]></item>
                <item name="wcf.acp.style.packageName"><![CDATA[Package Identifier]]></item>