summaryrefslogtreecommitdiffstats
path: root/application/forms/Config/General/ApplicationConfigForm.php
blob: 0e5c700283b791e348d3e0f10962a253ebd94565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */

namespace Icinga\Forms\Config\General;

use Icinga\Application\Icinga;
use Icinga\Data\ResourceFactory;
use Icinga\Web\Form;

/**
 * Configuration form for general application options
 *
 * This form is not used directly but as subform to the {@link GeneralConfigForm}.
 */
class ApplicationConfigForm extends Form
{
    /**
     * {@inheritdoc}
     */
    public function init()
    {
        $this->setName('form_config_general_application');
    }

    /**
     * {@inheritdoc}
     *
     * @return  $this
     */
    public function createElements(array $formData)
    {
        $this->addElement(
            'checkbox',
            'global_show_stacktraces',
            array(
                'value'         => true,
                'label'         => $this->translate('Show Stacktraces'),
                'description'   => $this->translate(
                    'Set whether to show an exception\'s stacktrace by default. This can also'
                    . ' be set in a user\'s preferences with the appropriate permission.'
                )
            )
        );

        $this->addElement(
            'checkbox',
            'global_show_application_state_messages',
            array(
                'value'         => true,
                'label'         => $this->translate('Show Application State Messages'),
                'description'   => $this->translate(
                    "Set whether to show application state messages."
                    . " This can also be set in a user's preferences."
                )
            )
        );

        $this->addElement(
            'text',
            'global_module_path',
            array(
                'label'         => $this->translate('Module Path'),
                'required'      => true,
                'value'         => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()),
                'description'   => $this->translate(
                    'Contains the directories that will be searched for available modules, separated by '
                    . 'colons. Modules that don\'t exist in these directories can still be symlinked in '
                    . 'the module folder, but won\'t show up in the list of disabled modules.'
                )
            )
        );

        $backends = array_keys(ResourceFactory::getResourceConfigs()->toArray());
        $backends = array_combine($backends, $backends);

        $this->addElement(
            'select',
            'global_config_resource',
            array(
                'required'      => true,
                'multiOptions'  => array_merge(
                    ['' => sprintf(' - %s - ', $this->translate('Please choose'))],
                    $backends
                ),
                'disable'       => [''],
                'value'         => '',
                'label'         => $this->translate('Configuration Database')
            )
        );

        return $this;
    }
}