From 23b77fc9c93b866423f32b4c5d5104b8a5bf9f05 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 26 Jun 2024 10:54:59 +0200 Subject: [PATCH] Adds the option of a template that is also included for the extra buttons Use `unsafe:` instead of `@` --- .../shared_fileProcessorFormField.tpl | 13 ++++++++----- .../field/FileProcessorFormField.class.php | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/com.woltlab.wcf/templates/shared_fileProcessorFormField.tpl b/com.woltlab.wcf/templates/shared_fileProcessorFormField.tpl index 4c603cc03d..42045031ec 100644 --- a/com.woltlab.wcf/templates/shared_fileProcessorFormField.tpl +++ b/com.woltlab.wcf/templates/shared_fileProcessorFormField.tpl @@ -23,15 +23,18 @@ require(["WoltLabSuite/Core/Form/Builder/Field/Controller/FileProcessor"], ({ FileProcessor }) => { new FileProcessor( - '{@$field->getPrefixedId()|encodeJS}', + '{unsafe:$field->getPrefixedId()|encodeJS}', {if $field->isSingleFileUpload()}true{else}false{/if}, {if $imageOnly}true{else}false{/if}, [{implode from=$actionButtons item=actionButton}{ - title: '{@$actionButton['title']|encodeJS}', - icon: {if $actionButton['icon'] === null}undefined - {else}'{@$actionButton['icon']->toHtml()|encodeJS}'{/if}, - actionName: '{@$actionButton['actionName']|encodeJS}', + title: '{unsafe:$actionButton['title']|encodeJS}', + icon: {if $actionButton['icon'] === null}undefined{else}'{unsafe:$actionButton['icon']->toHtml()|encodeJS}'{/if}, + actionName: '{unsafe:$actionButton['actionName']|encodeJS}', }{/implode} ], ); }); + + {foreach from=$actionButtons item=actionButton} + {include application=$actionButton['application'] file=$actionButton['template']} + {/foreach} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php index ed6e4a8f6f..44b54ebda2 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php @@ -9,7 +9,6 @@ use wcf\system\file\processor\FileProcessor; use wcf\system\file\processor\IFileProcessor; use wcf\system\form\builder\field\validation\FormFieldValidationError; use wcf\system\form\builder\TObjectTypeFormNode; -use wcf\system\style\FontAwesomeIcon; use wcf\system\style\IFontAwesomeIcon; use wcf\util\ArrayUtil; use wcf\util\ImageUtil; @@ -64,11 +63,6 @@ final class FileProcessorFormField extends AbstractFormField #[\Override] public function getHtmlVariables() { - $this->addActionButton( - 'delete', - 'wcf.form.field.fileProcessor.action.delete', - FontAwesomeIcon::fromValues('trash') - ); return [ 'fileProcessorHtmlElement' => FileProcessor::getInstance()->getHtmlElement( $this->getFileProcessor(), @@ -183,12 +177,19 @@ final class FileProcessorFormField extends AbstractFormField * Adds an action button to the file processor. * If the button is clicked, the event `fileProcessorCustomAction` will be triggered. */ - public function addActionButton(string $actionName, string $title, ?IFontAwesomeIcon $icon = null): self - { + public function addActionButton( + string $actionName, + string $title, + string $application, + string $template, + ?IFontAwesomeIcon $icon = null + ): self { $this->actionButtons[] = [ 'actionName' => $actionName, 'title' => $title, - 'icon' => $icon + 'icon' => $icon, + 'application' => $application, + 'template' => $template, ]; return $this; -- 2.20.1