From 6b8a30ec1ff4a1973da6a8cb369bb3254ba84a4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 23 Jul 2020 10:48:52 +0200 Subject: [PATCH] DRY up upload list list definitions in StyleAddForm --- .../files/lib/acp/form/StyleAddForm.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 9c1c23de0d..0ae2284856 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -234,8 +234,8 @@ class StyleAddForm extends AbstractForm { } } - protected function rebuildUploadFields() { - $fields = [ + protected function getUploadFields() { + return [ 'image' => [ ], 'image2x' => [ ], 'pageLogo' => [ 'allowSvgImage' => true ], @@ -243,9 +243,11 @@ class StyleAddForm extends AbstractForm { 'coverPhoto' => [ ], 'favicon' => [ ], ]; - + } + + protected function rebuildUploadFields() { $handler = UploadHandler::getInstance(); - foreach ($fields as $name => $options) { + foreach ($this->getUploadFields() as $name => $options) { if ($handler->isRegisteredFieldId($name)) { $handler->unregisterUploadField($name); } @@ -322,7 +324,7 @@ class StyleAddForm extends AbstractForm { if (isset($_POST['scrollOffsets']) && is_array($_POST['scrollOffsets'])) $this->scrollOffsets = ArrayUtil::toIntegerArray($_POST['scrollOffsets']); $this->uploads = []; - foreach (['image', 'image2x', 'pageLogo', 'pageLogoMobile', 'coverPhoto', 'favicon'] as $field) { + foreach (array_keys($this->getUploadFields()) as $field) { $removedFiles = UploadHandler::getInstance()->getRemovedFiledByFieldId($field); if (!empty($removedFiles)) { $this->uploads[$field] = null; -- 2.20.1