Immediately saves preview image of edited style
authorMatthias Schmidt <gravatronics@live.com>
Thu, 13 Jun 2013 13:10:47 +0000 (15:10 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 13 Jun 2013 13:10:47 +0000 (15:10 +0200)
wcfsetup/install/files/acp/templates/styleAdd.tpl
wcfsetup/install/files/lib/data/style/StyleAction.class.php

index d3fe00353f37eabfb0f6fd30a71fab2dda78f825..0f44d3df99388f33cdec1dfb70d4f00397cf6a92 100644 (file)
@@ -30,7 +30,7 @@
                        'wcf.style.colorPicker.new': '{lang}wcf.style.colorPicker.new{/lang}',
                        'wcf.style.colorPicker.current': '{lang}wcf.style.colorPicker.current{/lang}'
                });
-               new WCF.ACP.Style.ImageUpload(0, '{$tmpHash}');
+               new WCF.ACP.Style.ImageUpload({if $action == 'add'}0{else}{@$style->styleID}{/if}, '{$tmpHash}');
                
                {if $action == 'edit'}
                        new WCF.ACP.Style.CopyStyle({@$style->styleID});
index 7f5fe73bb6404748a8ef49e57974a43ded0b0ef5..ead0f4627535b882f44b2a619fa07ff3c7940acb 100644 (file)
@@ -243,8 +243,16 @@ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction
                        throw new PermissionDeniedException();
                }
                
-               if (!isset($this->parameters['tmpHash']) || empty($this->parameters['tmpHash'])) {
-                       throw new UserInputException('tmpHash');
+               $this->readString('tmpHash');
+               $this->readString('styleID', true);
+               
+               if ($this->parameters['styleID']) {
+                       $styles = StyleHandler::getInstance()->getStyles();
+                       if (!isset($styles[$this->parameters['styleID']])) {
+                               throw new UserInputException('styleID');
+                       }
+                       
+                       $this->style = $styles[$this->parameters['styleID']];
                }
                
                if (count($this->parameters['__files']->getFiles()) != 1) {
@@ -291,9 +299,16 @@ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction
                                        // store extension within session variables
                                        WCF::getSession()->register('stylePreview-'.$this->parameters['tmpHash'], $file->getFileExtension());
                                        
+                                       if ($this->parameters['styleID']) {
+                                               $this->updateStylePreviewImage($this->style);
+                                               
+                                               return array(
+                                                       'url' => WCF::getPath().'images/stylePreview-'.$this->parameters['styleID'].'.'.$file->getFileExtension()
+                                               );
+                                       }
+                                       
                                        // return result
                                        return array(
-                                               'errorType' => '',
                                                'url' => WCF::getPath().'images/stylePreview-'.$this->parameters['tmpHash'].'.'.$file->getFileExtension()
                                        );
                                }