Show correct default theme in configuration dialogs

This commit is contained in:
Eric Lippmann 2015-12-22 14:10:47 +01:00
parent 447ebeb0b6
commit 9c7c2bd6b1
2 changed files with 14 additions and 11 deletions

View File

@ -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']) {

View File

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