Use array for class list

This commit is contained in:
Alexander Rieß 2026-05-19 09:41:13 +02:00
parent ceeeee3447
commit 4bc4dc339b

View file

@ -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));