diff --git a/src/Model/Table/SettingsProviderTable.php b/src/Model/Table/SettingsProviderTable.php index a8cc779..d70b2d2 100644 --- a/src/Model/Table/SettingsProviderTable.php +++ b/src/Model/Table/SettingsProviderTable.php @@ -51,6 +51,8 @@ class SettingsProviderTable extends AppTable 'Application' => [ 'General' => [ 'Essentials' => [ + '_description' => __('Ensentials settings required for the application to run normally.'), + '_icon' => 'user-cog', 'app.baseurl' => [ 'name' => __('Base URL'), 'type' => 'string', @@ -200,6 +202,9 @@ class SettingsProviderTable extends AppTable private function mergeSettingsIntoSettingConfiguration(array $settingConf, array $settings, string $path=''): array { foreach ($settingConf as $key => $value) { + if ($this->isSettingMetaKey($key)) { + continue; + } if ($this->isLeaf($value)) { if (isset($settings[$key])) { $settingConf[$key]['value'] = $settings[$key]; @@ -218,6 +223,9 @@ class SettingsProviderTable extends AppTable public function flattenSettingsConfiguration(array $settingsProvider, $flattenedSettings=[]): array { foreach ($settingsProvider as $key => $value) { + if ($this->isSettingMetaKey($key)) { + continue; + } if ($this->isLeaf($value)) { $flattenedSettings[$key] = $value; } else { @@ -237,6 +245,9 @@ class SettingsProviderTable extends AppTable { $notices = []; foreach ($settingsProvider as $key => $value) { + if ($this->isSettingMetaKey($key)) { + continue; + } if ($this->isLeaf($value)) { if (!empty($value['error'])) { if (empty($notices[$value['severity']])) { @@ -320,6 +331,11 @@ class SettingsProviderTable extends AppTable } return $functionResult; } + + function isSettingMetaKey($key) + { + return substr($key, 0, 1) == '_'; + } } function testValidator($value, $validator) diff --git a/src/View/Helper/BootstrapHelper.php b/src/View/Helper/BootstrapHelper.php index 05ce6fe..e763a13 100644 --- a/src/View/Helper/BootstrapHelper.php +++ b/src/View/Helper/BootstrapHelper.php @@ -75,6 +75,12 @@ class BootstrapHelper extends Helper return $bsButton->button(); } + public function icon($icon, $options=[]) + { + $bsIcon = new BoostrapIcon($icon, $options); + return $bsIcon->icon(); + } + public function badge($options) { $bsBadge = new BoostrapBadge($options); @@ -733,9 +739,10 @@ class BoostrapButton extends BootstrapGeneric { private function genIcon() { - return $this->genNode('span', [ - 'class' => ['mr-1', "fa fa-{$this->options['icon']}"], + $bsIcon = new BoostrapIcon($this->options['icon'], [ + 'class' => ['mr-1'] ]); + return $bsIcon->icon(); } private function genContent() @@ -784,6 +791,40 @@ class BoostrapBadge extends BootstrapGeneric { } } +class BoostrapIcon extends BootstrapGeneric { + private $icon = ''; + private $defaultOptions = [ + 'class' => [], + ]; + + function __construct($icon, $options=[]) { + $this->icon = $icon; + $this->processOptions($options); + } + + private function processOptions($options) + { + $this->options = array_merge($this->defaultOptions, $options); + $this->checkOptionValidity(); + } + + public function icon() + { + return $this->genIcon(); + } + + private function genIcon() + { + $html = $this->genNode('span', [ + 'class' => array_merge( + is_array($this->options['class']) ? $this->options['class'] : [$this->options['class']], + ["fa fa-{$this->icon}"] + ), + ]); + return $html; + } +} + class BoostrapModal extends BootstrapGeneric { private $defaultOptions = [ 'size' => '', diff --git a/templates/element/Settings/panel.php b/templates/element/Settings/panel.php index a556df1..c49d996 100644 --- a/templates/element/Settings/panel.php +++ b/templates/element/Settings/panel.php @@ -10,9 +10,22 @@ if (isLeaf($panelSettings)) { $panelHTML = "
{$singleSetting}
"; } else { $panelID = getResolvableID($sectionName, $panelName); - $panelHTML .= sprintf('

%s

', $panelID, $panelID, h($panelName)); + $panelHTML .= sprintf('

%s%s

', + $panelID, + $panelID, + !empty($panelSettings['_icon']) ? $this->Bootstrap->icon($panelSettings['_icon'], ['class' => 'mr-1']) : '', + h($panelName) + ); + if (!empty($panelSettings['_description'])) { + $panelHTML .= $this->Bootstrap->genNode('div', [ + 'class' => ['mb-1',], + ], h($panelSettings['_description'])); + } $groupIssueSeverity = false; foreach ($panelSettings as $singleSettingName => $singleSetting) { + if (substr($singleSettingName, 0, 1) == '_') { + continue; + } $singleSettingHTML = $this->element('Settings/fieldGroup', [ 'panelName' => $panelName, 'panelSettings' => $panelSettings,