Adds the option of a template that is also included for the extra buttons
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 26 Jun 2024 08:54:59 +0000 (10:54 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 26 Jun 2024 08:54:59 +0000 (10:54 +0200)
Use `unsafe:` instead of `@`

com.woltlab.wcf/templates/shared_fileProcessorFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php

index 4c603cc03d2f388701174b44d44c78a14159ffb3..42045031ec17fa277441540f7d85e1ba6aab3d8b 100644 (file)
 
        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}
 </script>
index ed6e4a8f6f0174f3706c8d08e022fa93ab8df01e..44b54ebda28c804b04e29d863eda734453f2f62c 100644 (file)
@@ -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;