From 4bc4dc339bbdf72089656ee91ef6a09945ae5780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Rie=C3=9F?= Date: Tue, 19 May 2026 09:41:13 +0200 Subject: [PATCH] Use array for class list --- .../forms/Config/Security/CspConfigForm.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/application/forms/Config/Security/CspConfigForm.php b/application/forms/Config/Security/CspConfigForm.php index 1c7af79b1..57f824161 100644 --- a/application/forms/Config/Security/CspConfigForm.php +++ b/application/forms/Config/Security/CspConfigForm.php @@ -137,11 +137,15 @@ class CspConfigForm extends CompatForm ); $disabledState = $this->getPopulatedValue('use_custom_csp') === '1'; - $disabledClass = $disabledState ? 'csp-disabled' : ''; + + $formHintClassList = ['csp-form-hint']; + if ($disabledState) { + $formHintClassList[] = 'csp-disabled'; + } $this->add(HtmlElement::create( 'p', - ['class' => ['csp-form-hint', $disabledClass]], + ['class' => $formHintClassList], $this->translate( 'Enabling CSP will block some requests and prevent some functionality from working as expected.' ), @@ -156,13 +160,13 @@ class CspConfigForm extends CompatForm } else { $this->add(HtmlElement::create( 'h3', - ['class' => ['csp-form-hint', $disabledClass]], + ['class' => $formHintClassList], $this->translate('Allowed Sources'), )); $this->add(HtmlElement::create( 'p', - ['class' => ['csp-form-hint', $disabledClass]], + ['class' => $formHintClassList], $this->translate( 'Sources that are used in the generation of the CSP-Header.' ), @@ -170,7 +174,7 @@ class CspConfigForm extends CompatForm $this->add(HtmlElement::create( 'h4', - ['class' => "csp-form-hint $disabledClass"], + ['class' => $formHintClassList], $this->translate('System'), )); @@ -468,8 +472,13 @@ class CspConfigForm extends CompatForm return; } + $classList = ['csp-config-table']; + if (! $enabled) { + $classList[] = 'csp-disabled'; + } + $table = new Table(); - $table->addAttributes(Attributes::create(['class' => ['csp-config-table', $enabled ? '' : 'csp-disabled']])); + $table->addAttributes(Attributes::create(['class' => $classList])); $headerRow = Table::tr(); foreach ($header as $h) { $headerRow->add(Table::th($h));