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>
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;
#[\Override]
public function getHtmlVariables()
{
- $this->addActionButton(
- 'delete',
- 'wcf.form.field.fileProcessor.action.delete',
- FontAwesomeIcon::fromValues('trash')
- );
return [
'fileProcessorHtmlElement' => FileProcessor::getInstance()->getHtmlElement(
$this->getFileProcessor(),
* 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;