From: Matthias Schmidt Date: Sat, 20 Mar 2021 12:22:53 +0000 (+0100) Subject: Fix code formatting in ObjectActionFunctionTemplatePlugin X-Git-Tag: 5.4.0_Alpha_1~132^2~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=491793169f5a83964b2cbc91d05b2ed0137c7d18;p=GitHub%2FWoltLab%2FWCF.git Fix code formatting in ObjectActionFunctionTemplatePlugin --- 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 90685ff7c9..f8b79778cc 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php @@ -9,7 +9,7 @@ use wcf\util\StringUtil; /** * Template function plugin which generate delete and toggle buttons for objects to be used in * combination with `WoltLabSuite/Core/Ui/Object/Action`. - * + * * TODO: More information and examples * * @author Matthias Schmidt @@ -24,7 +24,7 @@ class ObjectActionFunctionTemplatePlugin implements IFunctionTemplatePlugin 'delete', 'toggle', ]; - + /** * @inheritDoc */ @@ -34,7 +34,7 @@ class ObjectActionFunctionTemplatePlugin implements IFunctionTemplatePlugin throw new \InvalidArgumentException("Missing 'action' argument."); } $action = $tagArgs['action']; - if (!in_array($action, static::SUPPORTED_ACTIONS)) { + if (!\in_array($action, static::SUPPORTED_ACTIONS)) { throw new \InvalidArgumentException("Unsupported action '{$action}'."); } @@ -48,7 +48,7 @@ class ObjectActionFunctionTemplatePlugin implements IFunctionTemplatePlugin } foreach ($tagArgs as $key => $value) { if (\preg_match('~^parameter.+$~', $key)) { - $additionalAttributes .= sprintf( + $additionalAttributes .= \sprintf( ' data-object-action-%s="%s"', \strtolower(\preg_replace( '~([A-Z])~', @@ -74,15 +74,16 @@ class ObjectActionFunctionTemplatePlugin implements IFunctionTemplatePlugin 'objectTitle' => $tagArgs['objectTitle'], ] )); - } - else if (isset($tagArgs['confirmMessage'])) { - $confirmMessage = StringUtil::encodeHTML($tplObj->fetchString( - $tplObj->getCompiler()->compileString( - $tagArgs['confirmMessage'], - $language->get($tagArgs['confirmMessage']) - )['template'])); - } - else { + } elseif (isset($tagArgs['confirmMessage'])) { + $confirmMessage = StringUtil::encodeHTML( + $tplObj->fetchString( + $tplObj->getCompiler()->compileString( + $tagArgs['confirmMessage'], + $language->get($tagArgs['confirmMessage']) + )['template'] + ) + ); + } else { throw new \InvalidArgumentException("Missing 'objectTitle' or 'confirmMessage' argument for 'delete' action."); } @@ -91,14 +92,14 @@ class ObjectActionFunctionTemplatePlugin implements IFunctionTemplatePlugin return << HTML; - + break; - + case 'toggle': if (!isset($tagArgs['isDisabled'])) { throw new \InvalidArgumentException("Missing 'isDisabled' argument for 'toggle' action."); } - + $icon = 'fa-check-square-o'; $title = $language->getDynamicVariable('wcf.global.button.disable'); if ($tagArgs['isDisabled']) { @@ -106,11 +107,11 @@ HTML; $title = $language->getDynamicVariable('wcf.global.button.enable'); } $title = StringUtil::encodeHTML($title); - + return << HTML; - + default: throw new \LogicException("Unreachable."); }