2021-07-26 11:16:52 +02:00
|
|
|
<?php
|
|
|
|
$settingId = str_replace('.', '_', $settingName);
|
|
|
|
|
|
|
|
$dependsOnHtml = '';
|
|
|
|
if (!empty($setting['dependsOn'])) {
|
2022-11-24 12:50:11 +01:00
|
|
|
$dependsOnHtml = $this->Bootstrap->node('span', [
|
2021-07-26 11:16:52 +02:00
|
|
|
'class' => [
|
2021-09-17 17:51:45 +02:00
|
|
|
'ms-1',
|
2021-07-26 11:16:52 +02:00
|
|
|
'd-inline-block',
|
|
|
|
'depends-on-icon'
|
|
|
|
],
|
|
|
|
'style' => 'min-width: 0.75em;',
|
|
|
|
'title' => __('This setting depends on the validity of: {0}', h($setting['dependsOn'])),
|
2022-11-24 12:50:11 +01:00
|
|
|
], $this->Bootstrap->node('sup', [
|
2021-07-26 11:16:52 +02:00
|
|
|
'class' => $this->FontAwesome->getClass('info'),
|
|
|
|
]));
|
|
|
|
}
|
2022-11-24 12:50:11 +01:00
|
|
|
$label = $this->Bootstrap->node('label', [
|
2021-09-17 17:51:45 +02:00
|
|
|
'class' => ['form-label', 'fw-bolder', 'mb-0'],
|
2021-07-26 11:16:52 +02:00
|
|
|
'for' => $settingId
|
2021-07-30 09:23:19 +02:00
|
|
|
], sprintf('<a id="lb-%s" href="#lb-%s" class="text-reset text-decoration-none">%s</a>', h($settingId), h($settingId), h($setting['name'])) . $dependsOnHtml);
|
2021-07-26 11:16:52 +02:00
|
|
|
|
|
|
|
$description = '';
|
|
|
|
if (!empty($setting['description']) && (empty($setting['type']) || $setting['type'] != 'boolean')) {
|
2022-11-24 12:50:11 +01:00
|
|
|
$description = $this->Bootstrap->node('small', [
|
2021-07-26 11:16:52 +02:00
|
|
|
'class' => ['form-text', 'text-muted', 'mt-0'],
|
|
|
|
'id' => "{$settingId}Help"
|
|
|
|
], h($setting['description']));
|
|
|
|
}
|
|
|
|
$textColor = 'text-warning';
|
|
|
|
if (!empty($setting['severity'])) {
|
|
|
|
$textColor = "text-{$this->get('variantFromSeverity')[$setting['severity']]}";
|
|
|
|
}
|
2022-11-24 12:50:11 +01:00
|
|
|
$validationError = $this->Bootstrap->node('div', [
|
2021-07-26 11:16:52 +02:00
|
|
|
'class' => ['d-block', 'invalid-feedback', $textColor],
|
|
|
|
], (!empty($setting['error']) ? h($setting['errorMessage']) : ''));
|
|
|
|
|
|
|
|
$input = $this->element('Settings/field', [
|
|
|
|
'setting' => $setting,
|
|
|
|
'settingName' => $settingName,
|
|
|
|
]);
|
|
|
|
|
2021-09-28 09:23:02 +02:00
|
|
|
$inputGroupSave = $this->Bootstrap->button([
|
|
|
|
'icon' => 'times',
|
|
|
|
'variant' => 'secondary',
|
|
|
|
'class' => ['btn-setting-action', 'btn-reset-setting', 'd-none'],
|
|
|
|
]);
|
|
|
|
$inputGroupSave .= $this->Bootstrap->button([
|
|
|
|
'text' => __('save'),
|
|
|
|
'variant' => 'success',
|
|
|
|
'class' => ['btn-setting-action', 'btn-save-setting', 'd-none'],
|
|
|
|
]);
|
2022-11-24 12:50:11 +01:00
|
|
|
$inputGroup = $this->Bootstrap->node('div', [
|
2021-07-26 11:16:52 +02:00
|
|
|
'class' => ['input-group'],
|
|
|
|
], implode('', [$input, $inputGroupSave]));
|
|
|
|
|
2022-11-24 12:50:11 +01:00
|
|
|
$container = $this->Bootstrap->node('div', [
|
2021-09-17 17:51:45 +02:00
|
|
|
'class' => ['setting-group', 'row', 'mb-2']
|
2021-07-26 11:16:52 +02:00
|
|
|
], implode('', [$label, $inputGroup, $description, $validationError]));
|
|
|
|
|
|
|
|
echo $container;
|
|
|
|
?>
|