Completed
Push — master ( 2fc9bb...067f55 )
by Julito
09:35
created

IntroductionSection::getMinimizedToolbar()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 28
nc 2
nop 0
dl 0
loc 35
rs 9.472
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
        }
29
30
        $config['extraPlugins'] = $this->getPluginsToString();
31
        $config['fullPage'] = true;
32
33
        return $config;
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getConditionalPlugins()
40
    {
41
        $plugins = [];
42
43
        if (api_get_setting('show_glossary_in_documents') === 'ismanual') {
44
            $plugins[] = 'glossary';
45
        }
46
47
        return $plugins;
48
    }
49
50
    /**
51
     * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false.
52
     *
53
     * @return array
54
     */
55
    protected function getNormalToolbar()
56
    {
57
        return [
58
            ['Maximize', 'PasteFromWord', '-', 'Undo', 'Redo'],
59
            ['Link', 'Unlink', 'Anchor', 'inserthtml', 'Glossary'],
60
            [
61
                'Image',
62
                'Video',
63
                'Flash',
64
                'Oembed',
65
                'Youtube',
66
                'Audio',
67
                'Asciimath',
68
                'Asciisvg',
69
            ],
70
            ['Table', 'SpecialChar'],
71
            [
72
                'Outdent',
73
                'Indent',
74
                '-',
75
                'TextColor',
76
                'BGColor',
77
                '-',
78
                'NumberedList',
79
                'BulletedList',
80
                '-',
81
                api_get_configuration_value('translate_html') ? 'Language' : '',
82
                api_get_setting('allow_spellcheck') === 'true' ? 'Scayt' : '',
83
            ],
84
            '/',
85
            ['Styles', 'Format', 'Font', 'FontSize'],
86
            ['Bold', 'Italic', 'Underline'],
87
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
88
            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
89
            ['Source'],
90
        ];
91
    }
92
93
    /**
94
     * Get the toolbar configuration when CKEditor is minimized.
95
     *
96
     * @return array
97
     */
98
    protected function getMinimizedToolbar()
99
    {
100
        return [
101
            $this->getNewPageBlock(),
102
            ['Undo', 'Redo'],
103
            [
104
                'Link',
105
                'Image',
106
                'Video',
107
                'Flash',
108
                'Youtube',
109
                'Audio',
110
                'Table',
111
                'Asciimath',
112
                'Asciisvg',
113
            ],
114
            ['BulletedList', 'NumberedList', 'HorizontalRule'],
115
            ['JustifyLeft', 'JustifyCenter', 'JustifyBlock'],
116
            ['Styles',
117
                'Format',
118
                'Font',
119
                'FontSize',
120
                'Bold',
121
                'Italic',
122
                'Underline',
123
                'TextColor',
124
                'BGColor',
125
            ],
126
            [
127
                'Language',
128
                'ShowBlocks',
129
                'Source',
130
            ],
131
            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
132
            ['Toolbarswitch'],
133
        ];
134
    }
135
}
136