From 9c7c2bd6b19bef8450652d0513c596d6dbbb4348 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 22 Dec 2015 14:10:47 +0100 Subject: [PATCH] Show correct default theme in configuration dialogs --- .../forms/Config/General/ThemingConfigForm.php | 9 +++++---- application/forms/PreferenceForm.php | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/application/forms/Config/General/ThemingConfigForm.php b/application/forms/Config/General/ThemingConfigForm.php index 31ee2109b..bc1f82fa0 100644 --- a/application/forms/Config/General/ThemingConfigForm.php +++ b/application/forms/Config/General/ThemingConfigForm.php @@ -31,16 +31,17 @@ class ThemingConfigForm extends Form public function createElements(array $formData) { $themes = Icinga::app()->getThemes(); - $themes[''] = $themes[StyleSheet::DEFAULT_THEME] . ' (' . $this->translate('default') . ')'; - unset($themes[StyleSheet::DEFAULT_THEME]); + $themes[StyleSheet::DEFAULT_THEME] .= ' (' . $this->translate('default') . ')'; + $this->addElement( 'select', 'themes_default', array( 'description' => $this->translate('The default theme', 'Form element description'), + 'disabled' => count($themes) < 2, 'label' => $this->translate('Default Theme', 'Form element label'), 'multiOptions' => $themes, - 'value' => '' + 'value' => StyleSheet::DEFAULT_THEME ) ); @@ -66,7 +67,7 @@ class ThemingConfigForm extends Form public function getValues($suppressArrayNotation = false) { $values = parent::getValues($suppressArrayNotation); - if ($values['themes_default'] === '') { + if ($values['themes_default'] === '' || $values['themes_default'] === StyleSheet::DEFAULT_THEME) { $values['themes_default'] = null; } if (! $values['themes_disabled']) { diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index ed6c76ac5..efb9a4aa3 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -96,7 +96,10 @@ class PreferenceForm extends Form $webPreferences = $this->preferences->get('icingaweb', array()); foreach ($this->getValues() as $key => $value) { - if ($value === '' || $value === 'autodetect') { + if ($value === '' + || $value === 'autodetect' + || ($key === 'theme' && $value === Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME)) + ) { if (isset($webPreferences[$key])) { unset($webPreferences[$key]); } @@ -155,12 +158,11 @@ class PreferenceForm extends Form { if (! (bool) Config::app()->get('themes', 'disabled', false)) { $themes = Icinga::app()->getThemes(); - $defaultTheme = Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME); - if (isset($themes[$defaultTheme])) { - $themes[''] = $themes[$defaultTheme] . ' (' . $this->translate('default') . ')'; - unset($themes[$defaultTheme]); - } if (count($themes) > 1) { + $defaultTheme = Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME); + if (isset($themes[$defaultTheme])) { + $themes[$defaultTheme] .= ' (' . $this->translate('default') . ')'; + } $this->addElement( 'select', 'theme', @@ -168,7 +170,7 @@ class PreferenceForm extends Form 'label' => $this->translate('Theme', 'Form element label'), 'multiOptions' => $themes, 'value' => $this->preferences->getValue( - 'icingaweb', 'theme', '' + 'icingaweb', 'theme', $defaultTheme ) ) );