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

IntroductionSection::getNormalToolbar()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 35
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 29
nc 8
nop 0
dl 0
loc 35
rs 9.456
c 0
b 0
f 0
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 IntroductionSection 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()
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'],
89
            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
90
            ['Source'],
91
        ];
92
    }
93
94
    /**
95
     * Get the toolbar configuration when CKEditor is minimized.
96
     *
97
     * @return array
98
     */
99
    protected function getMinimizedToolbar()
100
    {
101
        return [
102
            $this->getNewPageBlock(),
103
            ['Undo', 'Redo'],
104
            [
105
                'Link',
106
                'Image',
107
                'Video',
108
                'Flash',
109
                'Youtube',
110
                'Audio',
111
                'Table',
112
                'Asciimath',
113
                'Asciisvg',
114
            ],
115
            ['BulletedList', 'NumberedList', 'HorizontalRule'],
116
            ['JustifyLeft', 'JustifyCenter', 'JustifyBlock'],
117
            [
118
                'Styles',
119
                'Format',
120
                'Font',
121
                'FontSize',
122
                'Bold',
123
                'Italic',
124
                'Underline',
125
                'TextColor',
126
                'BGColor',
127
                api_get_configuration_value('translate_html') ? 'Language' : '',
128
            ],
129
            [
130
                'ShowBlocks',
131
            ],
132
            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
133
            ['Toolbarswitch', 'Source'],
134
        ];
135
    }
136
137
    /**
138
     * @return array
139
     */
140
    protected function getMaximizedToolbar()
141
    {
142
        return [
143
            $this->getNewPageBlock(),
144
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'inserthtml'],
145
            ['Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'],
146
            ['Link', 'Unlink', 'Anchor', 'Glossary'],
147
            [
148
                'Image',
149
                'Mapping',
150
                'Video',
151
                'Oembed',
152
                'Flash',
153
                'Youtube',
154
                'Audio',
155
                'leaflet',
156
                'Smiley',
157
                'SpecialChar',
158
                'Asciimath',
159
                'Asciisvg',
160
            ],
161
            '/',
162
            ['Table', '-', 'CreateDiv'],
163
            ['BulletedList', 'NumberedList', 'HorizontalRule', '-', 'Outdent', 'Indent', 'Blockquote'],
164
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
165
            [
166
                'Bold',
167
                'Italic',
168
                'Underline',
169
                'Strike',
170
                '-',
171
                'Subscript',
172
                'Superscript',
173
                '-',
174
                'TextColor',
175
                'BGColor',
176
                api_get_configuration_value('translate_html') ? 'Language' : '',
177
            ],
178
            [api_get_setting('allow_spellcheck') == 'true' ? 'Scayt' : ''],
179
            ['Styles', 'Format', 'Font', 'FontSize'],
180
            ['PageBreak', 'ShowBlocks'],
181
            api_get_setting('enabled_wiris') == 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
182
            ['Toolbarswitch', 'Source'],
183
        ];
184
    }
185
}
186