2015-11-26 15:52:15 +01:00
|
|
|
<?php
|
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
|
|
|
|
|
|
|
namespace Icinga\Forms\Config\General;
|
|
|
|
|
|
|
|
use Icinga\Application\Icinga;
|
|
|
|
use Icinga\Application\Logger;
|
|
|
|
use Icinga\Web\Form;
|
2015-12-22 13:00:01 +01:00
|
|
|
use Icinga\Web\StyleSheet;
|
2015-11-26 15:52:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration form for theming options
|
|
|
|
*
|
|
|
|
* This form is not used directly but as subform for the {@link GeneralConfigForm}.
|
|
|
|
*/
|
|
|
|
class ThemingConfigForm extends Form
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->setName('form_config_general_theming');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function createElements(array $formData)
|
|
|
|
{
|
2015-12-22 13:00:01 +01:00
|
|
|
$themes = Icinga::app()->getThemes();
|
|
|
|
$themes[''] = $themes[StyleSheet::DEFAULT_THEME] . ' (' . $this->translate('default') . ')';
|
|
|
|
unset($themes[StyleSheet::DEFAULT_THEME]);
|
2015-11-26 15:52:15 +01:00
|
|
|
$this->addElement(
|
|
|
|
'select',
|
|
|
|
'themes_default',
|
|
|
|
array(
|
|
|
|
'description' => $this->translate('The default theme', 'Form element description'),
|
|
|
|
'label' => $this->translate('Default Theme', 'Form element label'),
|
2015-12-22 13:00:01 +01:00
|
|
|
'multiOptions' => $themes,
|
|
|
|
'value' => ''
|
2015-11-26 15:52:15 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->addElement(
|
|
|
|
'checkbox',
|
|
|
|
'themes_disabled',
|
|
|
|
array(
|
|
|
|
'description' => $this->translate(
|
|
|
|
'Check this box for disallowing users to change the theme. If a default theme is set, it will be'
|
|
|
|
. ' used nonetheless',
|
|
|
|
'Form element description'
|
|
|
|
),
|
2015-12-22 13:00:01 +01:00
|
|
|
'label' => $this->translate('Users Can\'t Change Theme', 'Form element label')
|
2015-11-26 15:52:15 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getValues($suppressArrayNotation = false)
|
|
|
|
{
|
|
|
|
$values = parent::getValues($suppressArrayNotation);
|
2015-12-22 13:00:01 +01:00
|
|
|
if ($values['themes_default'] === '') {
|
2015-11-26 15:52:15 +01:00
|
|
|
$values['themes_default'] = null;
|
|
|
|
}
|
|
|
|
if (! $values['themes_disabled']) {
|
|
|
|
$values['themes_disabled'] = null;
|
|
|
|
}
|
|
|
|
return $values;
|
|
|
|
}
|
|
|
|
}
|