Passed
Push — master ( 1cdc43...510ee8 )
by Julito
09:15
created

Documents::getMaximizedToolbar()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 43
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 37
c 0
b 0
f 0
nc 8
nop 0
dl 0
loc 43
rs 9.328
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
5
6
/**
7
 * Documents toolbar configuration.
8
 *
9
 * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
10
 */
11
class Documents extends Basic
12
{
13
    public $plugins = [];
14
15
    /**
16
     * Get the toolbar config.
17
     *
18
     * @return array
19
     */
20
    public function getConfig()
21
    {
22
        $config = [];
23
24
        if (api_get_setting('more_buttons_maximized_mode') !== 'true') {
25
            $config['toolbar'] = $this->getNormalToolbar();
26
        } else {
27
            $config['toolbar_minToolbar'] = $this->getMinimizedToolbar();
28
            $config['toolbar_maxToolbar'] = $this->getMaximizedToolbar();
29
        }
30
31
        $config['extraPlugins'] = $this->getPluginsToString();
32
        $config['fullPage'] = true;
33
34
        return $config;
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function getConditionalPlugins()
41
    {
42
        $plugins = [];
43
44
        if (api_get_setting('show_glossary_in_documents') === 'ismanual') {
45
            $plugins[] = 'glossary';
46
        }
47
48
        return $plugins;
49
    }
50
51
    /**
52
     * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false.
53
     *
54
     * @return array
55
     */
56
    protected function getNormalToolbar(): array
57
    {
58
        return [
59
            ['Maximize', 'PasteFromWord', '-', 'Undo', 'Redo'],
60
            ['Link', 'Unlink', 'Anchor', 'inserthtml', 'Glossary'],
61
            [
62
                'Image',
63
                'Video',
64
                'Flash',
65
                'Oembed',
66
                'Youtube',
67
                'Audio',
68
                'Asciimath',
69
                'Asciisvg',
70
            ],
71
            ['Table', 'SpecialChar'],
72
            [
73
                'Outdent',
74
                'Indent',
75
                '-',
76
                'TextColor',
77
                'BGColor',
78
                '-',
79
                'NumberedList',
80
                'BulletedList',
81
                '-',
82
                api_get_configuration_value('translate_html') ? 'Language' : '',
83
                api_get_setting('allow_spellcheck') === 'true' ? 'Scayt' : '',
84
            ],
85
            '/',
86
            ['Styles', 'Format', 'Font', 'FontSize'],
87
            ['Bold', 'Italic', 'Underline'],
88
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
89
            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
90
            ['Source'],
91
        ];
92
    }
93
94
    /**
95
     * @return array
96
     */
97
    protected function getMaximizedToolbar()
98
    {
99
        return [
100
            $this->getNewPageBlock(),
101
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'inserthtml'],
102
            ['Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'],
103
            ['Link', 'Unlink', 'Anchor', 'Glossary'],
104
            [
105
                'Image',
106
                'Mapping',
107
                'Video',
108
                'Oembed',
109
                'Flash',
110
                'Youtube',
111
                'Audio',
112
                'leaflet',
113
                'Smiley',
114
                'SpecialChar',
115
                'Asciimath',
116
                'Asciisvg',
117
            ],
118
            '/',
119
            ['Table', '-', 'CreateDiv'],
120
            ['BulletedList', 'NumberedList', 'HorizontalRule', '-', 'Outdent', 'Indent', 'Blockquote'],
121
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
122
            [
123
                'Bold',
124
                'Italic',
125
                'Underline',
126
                'Strike',
127
                '-',
128
                'Subscript',
129
                'Superscript',
130
                '-',
131
                'TextColor',
132
                'BGColor',
133
                api_get_configuration_value('translate_html') ? 'Language' : '',
134
            ],
135
            [api_get_setting('allow_spellcheck') == 'true' ? 'Scayt' : ''],
136
            ['Styles', 'Format', 'Font', 'FontSize'],
137
            ['PageBreak', 'ShowBlocks'],
138
            api_get_setting('enabled_wiris') == 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
139
            ['Toolbarswitch', 'Source'],
140
        ];
141
    }
142
143
    /**
144
     * Get the toolbar configuration when CKEditor is minimized.
145
     *
146
     * @return array
147
     */
148
    protected function getMinimizedToolbar(): array
149
    {
150
        return [
151
            $this->getNewPageBlock(),
152
            ['Undo', 'Redo'],
153
            [
154
                'Link',
155
                'Image',
156
                'Video',
157
                'Flash',
158
                'Youtube',
159
                'Audio',
160
                'Table',
161
                'Asciimath',
162
                'Asciisvg',
163
            ],
164
            ['BulletedList', 'NumberedList', 'HorizontalRule'],
165
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
166
            ['Styles',
167
                'Format',
168
                'Font',
169
                'FontSize',
170
                'Bold',
171
                'Italic',
172
                'Underline',
173
                'TextColor',
174
                'BGColor',
175
            ],
176
            [
177
                api_get_configuration_value('translate_html') ? 'Language' : '',
178
                'ShowBlocks',
179
            ],
180
            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
181
            ['Toolbarswitch', 'Source'],
182
        ];
183
    }
184
}
185