From 2f06a43eece9669e8886a83385b73b00fd48e829 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 13 Jun 2013 15:10:47 +0200 Subject: [PATCH] Immediately saves preview image of edited style --- .../install/files/acp/templates/styleAdd.tpl | 2 +- .../lib/data/style/StyleAction.class.php | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/styleAdd.tpl b/wcfsetup/install/files/acp/templates/styleAdd.tpl index d3fe00353f..0f44d3df99 100644 --- a/wcfsetup/install/files/acp/templates/styleAdd.tpl +++ b/wcfsetup/install/files/acp/templates/styleAdd.tpl @@ -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}); diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index 7f5fe73bb6..ead0f46275 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -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() ); } -- 2.20.1