Avoid using template compiler in `ObjectActionFunctionTemplatePlugin`
authorMatthias Schmidt <gravatronics@live.com>
Wed, 24 Mar 2021 12:35:46 +0000 (13:35 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 24 Mar 2021 12:35:46 +0000 (13:35 +0100)
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.

com.woltlab.wcf/templates/headIncludeJavaScript.tpl
wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index a1295130ccadfc2378f1121c4d4c80840fcef8b0..9b70fc5a07883202dff4d5b24db538cf047baffd 100644 (file)
@@ -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}',
index e1043b9d032f9202b6b65ed629d04fa1ef2b8e23..fce0153c6708e0b59eff3b26b001391b0f954da6 100644 (file)
@@ -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}',
index 79180e9a7d838dd401d652bf4f398fa566a66779..932929d4605383687bc405f19074d53fe6f0a52a 100644 (file)
@@ -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.");
                 }
index d206e5b104cf2dc68ff2610772e076c17d5af6e7..79beeeb3e0fe96a4b3e799baa0e303ca359874fd 100644 (file)
@@ -3353,6 +3353,9 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExt
                <item name="wcf.bbcode.spoiler.text"><![CDATA[(Versteckter Text)]]></item>
                <item name="wcf.bbcode.spoiler.simplified"><![CDATA[(Versteckter Text)]]></item>
        </category>
+       <category name="wcf.button">
+               <item name="wcf.button.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} <span class="confirmationObject">{$objectTitle}</span> wirklich löschen?]]></item>
+       </category>
        <category name="wcf.captcha">
                <item name="wcf.captcha.useNoCaptcha"><![CDATA[(Kein Captcha)]]></item>
                <item name="wcf.captcha.com.woltlab.wcf.recaptcha"><![CDATA[reCAPTCHA]]></item>
@@ -3851,7 +3854,6 @@ Dateianhänge:
                <item name="wcf.global.button.close"><![CDATA[Schließen]]></item>
                <item name="wcf.global.button.collapsible"><![CDATA[Auf- und Zuklappen]]></item>
                <item name="wcf.global.button.delete"><![CDATA[Löschen]]></item>
-               <item name="wcf.global.button.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} <span class="confirmationObject">{$objectTitle}</span> wirklich löschen?]]></item>
                <item name="wcf.global.button.disable"><![CDATA[Deaktivieren]]></item>
                <item name="wcf.global.button.disabledI18n"><![CDATA[einsprachig]]></item>
                <item name="wcf.global.button.edit"><![CDATA[Bearbeiten]]></item>
index f617ca28f47b688aef13fd5bb9c799164fd45492..a6a0ce2c14299f33c82b32f005a3d8aa015dc01e 100644 (file)
@@ -3279,6 +3279,9 @@ Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensi
                <item name="wcf.bbcode.spoiler.text"><![CDATA[(Hidden Content)]]></item>
                <item name="wcf.bbcode.spoiler.simplified"><![CDATA[(Hidden Content)]]></item>
        </category>
+       <category name="wcf.button">
+               <item name="wcf.button.delete.confirmMessage"><![CDATA[Do you really want to delete <strong>{$objectTitle}</strong>?]]></item>
+       </category>
        <category name="wcf.captcha">
                <item name="wcf.captcha.useNoCaptcha"><![CDATA[(No Captcha)]]></item>
                <item name="wcf.captcha.com.woltlab.wcf.recaptcha"><![CDATA[reCAPTCHA]]></item>
@@ -3798,7 +3801,6 @@ Attachments:
                <item name="wcf.global.button.close"><![CDATA[Close]]></item>
                <item name="wcf.global.button.collapsible"><![CDATA[Expand and Collapse]]></item>
                <item name="wcf.global.button.delete"><![CDATA[Delete]]></item>
-               <item name="wcf.global.button.delete.confirmMessage"><![CDATA[Do you really want to delete <strong>{$objectTitle}</strong>?]]></item>
                <item name="wcf.global.button.disable"><![CDATA[Disable]]></item>
                <item name="wcf.global.button.disabledI18n"><![CDATA[monolingual]]></item>
                <item name="wcf.global.button.edit"><![CDATA[Edit]]></item>