From e4861de1ca8192832eb62cefae5987330f9f2727 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 24 Mar 2021 13:35:46 +0100 Subject: [PATCH] Avoid using template compiler in `ObjectActionFunctionTemplatePlugin` Language items in `wcf.global.` do not support template scripting by default. Instead of "manually" adding support for template scripting for this specific case, the relevant language item has been moved to a different language item category. --- .../templates/headIncludeJavaScript.tpl | 2 +- .../install/files/acp/templates/header.tpl | 2 +- ...jectActionFunctionTemplatePlugin.class.php | 26 +++++++------------ wcfsetup/install/lang/de.xml | 4 ++- wcfsetup/install/lang/en.xml | 4 ++- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index a1295130cc..9b70fc5a07 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -74,7 +74,7 @@ window.addEventListener('pageshow', function(event) { 'wcf.global.button.close': '{jslang}wcf.global.button.close{/jslang}', 'wcf.global.button.collapsible': '{jslang}wcf.global.button.collapsible{/jslang}', 'wcf.global.button.delete': '{jslang}wcf.global.button.delete{/jslang}', - 'wcf.global.button.delete.confirmMessage': '{jslang __literal=true}wcf.global.button.delete.confirmMessage{/jslang}', + 'wcf.button.delete.confirmMessage': '{jslang __literal=true}wcf.button.delete.confirmMessage{/jslang}', 'wcf.global.button.disable': '{jslang}wcf.global.button.disable{/jslang}', 'wcf.global.button.disabledI18n': '{jslang}wcf.global.button.disabledI18n{/jslang}', 'wcf.global.button.edit': '{jslang}wcf.global.button.edit{/jslang}', diff --git a/wcfsetup/install/files/acp/templates/header.tpl b/wcfsetup/install/files/acp/templates/header.tpl index e1043b9d03..fce0153c67 100644 --- a/wcfsetup/install/files/acp/templates/header.tpl +++ b/wcfsetup/install/files/acp/templates/header.tpl @@ -92,7 +92,7 @@ 'wcf.global.button.close': '{jslang}wcf.global.button.close{/jslang}', 'wcf.global.button.collapsible': '{jslang}wcf.global.button.collapsible{/jslang}', 'wcf.global.button.delete': '{jslang}wcf.global.button.delete{/jslang}', - 'wcf.global.button.delete.confirmMessage': '{jslang __literal=true}wcf.global.button.delete.confirmMessage{/jslang}', + 'wcf.button.delete.confirmMessage': '{jslang __literal=true}wcf.button.delete.confirmMessage{/jslang}', 'wcf.global.button.disable': '{jslang}wcf.global.button.disable{/jslang}', 'wcf.global.button.disabledI18n': '{jslang}wcf.global.button.disabledI18n{/jslang}', 'wcf.global.button.edit': '{jslang}wcf.global.button.edit{/jslang}', diff --git a/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php index 79180e9a7d..932929d460 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php @@ -20,7 +20,7 @@ use wcf\util\StringUtil; * attributes of the button * * One of the following aguments for `delete` action is required: - * - `objectTitle`: name of the object used in the `wcf.global.button.delete.confirmMessage` + * - `objectTitle`: name of the object used in the `wcf.button.delete.confirmMessage` * confirmation language item * - `confirmMessage`: confirmation message or confirmation language item * @@ -89,24 +89,18 @@ class ObjectActionFunctionTemplatePlugin implements IFunctionTemplatePlugin switch ($action) { case 'delete': if (isset($tagArgs['objectTitle'])) { - $confirmMessage = StringUtil::encodeHTML($tplObj->fetchString( - $tplObj->getCompiler()->compileString( - 'wcf.global.button.delete.confirmMessage', - $language->get('wcf.global.button.delete.confirmMessage') - )['template'], - [ - 'objectTitle' => $tagArgs['objectTitle'], - ] - )); - } elseif (isset($tagArgs['confirmMessage'])) { $confirmMessage = StringUtil::encodeHTML( - $tplObj->fetchString( - $tplObj->getCompiler()->compileString( - $tagArgs['confirmMessage'], - $language->get($tagArgs['confirmMessage']) - )['template'] + $language->getDynamicVariable( + 'wcf.button.delete.confirmMessage', + [ + 'objectTitle' => $tagArgs['objectTitle'], + ] ) ); + } elseif (isset($tagArgs['confirmMessage'])) { + $confirmMessage = StringUtil::encodeHTML( + $language->getDynamicVariable($tagArgs['confirmMessage']) + ); } else { throw new \InvalidArgumentException("Missing 'objectTitle' or 'confirmMessage' argument for 'delete' action."); } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index d206e5b104..79beeeb3e0 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3353,6 +3353,9 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExt + + {$objectTitle} wirklich löschen?]]> + @@ -3851,7 +3854,6 @@ Dateianhänge: - {$objectTitle} wirklich löschen?]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index f617ca28f4..a6a0ce2c14 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3279,6 +3279,9 @@ Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensi + + {$objectTitle}?]]> + @@ -3798,7 +3801,6 @@ Attachments: - {$objectTitle}?]]> -- 2.20.1