1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; |
8
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Component\Editor\Toolbar; |
10
|
|
|
|
11
|
|
|
class Basic extends Toolbar |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Default plugins that will be use in all toolbars |
15
|
|
|
* In order to add a new plugin you have to load it in default/layout/head.tpl. |
16
|
|
|
*/ |
17
|
|
|
public array $defaultPlugins = [ |
18
|
|
|
//'adobeair', |
19
|
|
|
//'ajax', |
20
|
|
|
'audio', |
21
|
|
|
'image2_chamilo', |
22
|
|
|
'bidi', |
23
|
|
|
'colorbutton', |
24
|
|
|
'colordialog', |
25
|
|
|
'dialogui', |
26
|
|
|
'dialogadvtab', |
27
|
|
|
'div', |
28
|
|
|
//if you activate this plugin the html, head tags will not be saved |
29
|
|
|
//'divarea', |
30
|
|
|
//'docprops', |
31
|
|
|
'find', |
32
|
|
|
'flash', |
33
|
|
|
'font', |
34
|
|
|
'iframe', |
35
|
|
|
//'iframedialog', |
36
|
|
|
'indentblock', |
37
|
|
|
'justify', |
38
|
|
|
'language', |
39
|
|
|
'lineutils', |
40
|
|
|
'liststyle', |
41
|
|
|
'newpage', |
42
|
|
|
'oembed', |
43
|
|
|
'pagebreak', |
44
|
|
|
'preview', |
45
|
|
|
'print', |
46
|
|
|
'save', |
47
|
|
|
'selectall', |
48
|
|
|
//'sharedspace', |
49
|
|
|
'showblocks', |
50
|
|
|
'smiley', |
51
|
|
|
//'sourcedialog', |
52
|
|
|
//'stylesheetparser', |
53
|
|
|
//'tableresize', |
54
|
|
|
'templates', |
55
|
|
|
//'uicolor', |
56
|
|
|
'video', |
57
|
|
|
'widget', |
58
|
|
|
'wikilink', |
59
|
|
|
'wordcount', |
60
|
|
|
'inserthtml', |
61
|
|
|
//'xml', |
62
|
|
|
'qmarkersrolls', |
63
|
|
|
]; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Plugins this toolbar. |
67
|
|
|
*/ |
68
|
|
|
public array $plugins = []; |
69
|
|
|
private string $toolbarSet; |
70
|
|
|
|
71
|
|
|
public function __construct( |
72
|
|
|
$router, |
73
|
|
|
$toolbar = null, |
74
|
|
|
$config = [], |
75
|
|
|
$prefix = null |
76
|
|
|
) { |
77
|
|
|
$isAllowedToEdit = api_is_allowed_to_edit(); |
78
|
|
|
$isPlatformAdmin = api_is_platform_admin(); |
79
|
|
|
// Adding plugins depending of platform conditions |
80
|
|
|
$plugins = []; |
81
|
|
|
|
82
|
|
|
if ('ismanual' === api_get_setting('show_glossary_in_documents')) { |
83
|
|
|
$plugins[] = 'glossary'; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
if ('true' === api_get_setting('youtube_for_students')) { |
87
|
|
|
$plugins[] = 'youtube'; |
88
|
|
|
} else { |
89
|
|
|
if (api_is_allowed_to_edit() || api_is_platform_admin()) { |
90
|
|
|
$plugins[] = 'youtube'; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
if ('true' === api_get_setting('enabled_googlemaps')) { |
95
|
|
|
$plugins[] = 'leaflet'; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
if ('true' === api_get_setting('math_asciimathML')) { |
99
|
|
|
$plugins[] = 'asciimath'; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if ('true' === api_get_setting('enabled_mathjax')) { |
103
|
|
|
$plugins[] = 'mathjax'; |
104
|
|
|
$config['mathJaxLib'] = api_get_path(WEB_PUBLIC_PATH).'assets/MathJax/MathJax.js?config=TeX-MML-AM_HTMLorMML'; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
if ('true' === api_get_setting('enabled_asciisvg')) { |
108
|
|
|
$plugins[] = 'asciisvg'; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
if ('true' === api_get_setting('enabled_wiris')) { |
112
|
|
|
// Commercial plugin |
113
|
|
|
$plugins[] = 'ckeditor_wiris'; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
if ('true' === api_get_setting('enabled_imgmap')) { |
117
|
|
|
$plugins[] = 'mapping'; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/*if (api_get_setting('block_copy_paste_for_students') == 'true') { |
121
|
|
|
// Missing |
122
|
|
|
}*/ |
123
|
|
|
|
124
|
|
|
if ('true' === api_get_setting('more_buttons_maximized_mode')) { |
125
|
|
|
$plugins[] = 'toolbarswitch'; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
if ('true' === api_get_setting('allow_spellcheck')) { |
129
|
|
|
$plugins[] = 'scayt'; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
if (api_get_configuration_sub_value('ckeditor_vimeo_embed/config') && ($isAllowedToEdit || $isPlatformAdmin)) { |
133
|
|
|
$plugins[] = 'ckeditor_vimeo_embed'; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
if (api_get_configuration_value('ck_editor_block_image_copy_paste')) { |
137
|
|
|
$plugins[] = 'blockimagepaste'; |
138
|
|
|
} |
139
|
|
|
$this->defaultPlugins = array_unique(array_merge($this->defaultPlugins, $plugins)); |
140
|
|
|
$this->toolbarSet = $toolbar; |
141
|
|
|
parent::__construct($router, $toolbar, $config, $prefix); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Get the toolbar config. |
146
|
|
|
*/ |
147
|
|
|
public function getConfig(): array |
148
|
|
|
{ |
149
|
|
|
$config = []; |
150
|
|
|
$customPlugins = ''; |
151
|
|
|
$customPluginsPath = []; |
152
|
|
|
if ('true' === api_get_setting('editor.translate_html')) { |
153
|
|
|
$customPlugins .= ' translatehtml'; |
154
|
|
|
$customPluginsPath['translatehtml'] = api_get_path(WEB_PUBLIC_PATH).'libs/editor/tinymce_plugins/translatehtml/plugin.js'; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
$plugins = [ |
158
|
|
|
'advlist autolink lists link image charmap print preview anchor', |
159
|
|
|
'searchreplace visualblocks code fullscreen', |
160
|
|
|
'insertdatetime media table paste wordcount '.$customPlugins, |
161
|
|
|
]; |
162
|
|
|
|
163
|
|
|
if ($this->getConfigAttribute('fullPage')) { |
164
|
|
|
$plugins[] = 'fullpage'; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
$config['plugins'] = implode(' ', $plugins); |
168
|
|
|
$config['toolbar'] = 'undo redo directionality | bold italic underline strikethrough | insertfile image media template link | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | code codesample | ltr rtl | '.$customPlugins; |
169
|
|
|
|
170
|
|
|
if (!empty($customPluginsPath)) { |
171
|
|
|
$config['external_plugins'] = $customPluginsPath; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
$config['skin_url'] = '/build/libs/tinymce/skins/ui/oxide'; |
175
|
|
|
$config['content_css'] = '/build/libs/tinymce/skins/content/default/content.css'; |
176
|
|
|
$config['branding'] = false; |
177
|
|
|
$config['relative_urls'] = false; |
178
|
|
|
$config['toolbar_mode'] = 'sliding'; |
179
|
|
|
$config['autosave_ask_before_unload'] = true; |
180
|
|
|
$config['toolbar_mode'] = 'sliding'; |
181
|
|
|
|
182
|
|
|
//file_picker_callback : browser, |
183
|
|
|
|
184
|
|
|
$iso = api_get_language_isocode(); |
185
|
|
|
$url = api_get_path(WEB_PATH); |
186
|
|
|
|
187
|
|
|
// Language list: https://www.tiny.cloud/get-tiny/language-packages/ |
188
|
|
|
if ('en_US' !== $iso) { |
189
|
|
|
$config['language'] = $iso; |
190
|
|
|
$config['language_url'] = "$url/libs/editor/langs/$iso.js"; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/*if (isset($this->config)) { |
194
|
|
|
$this->config = array_merge($config, $this->config); |
195
|
|
|
} else { |
196
|
|
|
$this->config = $config; |
197
|
|
|
}*/ |
198
|
|
|
|
199
|
|
|
$this->config = $config; |
200
|
|
|
|
201
|
|
|
//$config['width'] = '100'; |
202
|
|
|
$config['height'] = '300'; |
203
|
|
|
|
204
|
|
|
return $this->config; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return array |
209
|
|
|
*/ |
210
|
|
|
public function getNewPageBlock() |
211
|
|
|
{ |
212
|
|
|
return ['NewPage', 'Templates', '-', 'PasteFromWord', 'inserthtml']; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Get the default toolbar configuration when the setting more_buttons_maximized_mode is false. |
217
|
|
|
* |
218
|
|
|
* @return array |
219
|
|
|
*/ |
220
|
|
|
protected function getNormalToolbar() |
221
|
|
|
{ |
222
|
|
|
return null; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Get the toolbar configuration when CKEditor is minimized. |
227
|
|
|
* |
228
|
|
|
* @return array |
229
|
|
|
*/ |
230
|
|
|
protected function getMinimizedToolbar() |
231
|
|
|
{ |
232
|
|
|
return [ |
233
|
|
|
$this->getNewPageBlock(), |
234
|
|
|
['Undo', 'Redo'], |
235
|
|
|
[ |
236
|
|
|
'Link', |
237
|
|
|
'Image', |
238
|
|
|
'Video', |
239
|
|
|
'Oembed', |
240
|
|
|
'Flash', |
241
|
|
|
'Youtube', |
242
|
|
|
'VimeoEmbed', |
243
|
|
|
'Audio', |
244
|
|
|
'Table', |
245
|
|
|
'Asciimath', |
246
|
|
|
'Asciisvg', |
247
|
|
|
], |
248
|
|
|
['BulletedList', 'NumberedList', 'HorizontalRule'], |
249
|
|
|
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], |
250
|
|
|
['Styles', 'Format', 'Font', 'FontSize', 'Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'], |
251
|
|
|
'true' === api_get_setting('enabled_wiris') ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''], |
252
|
|
|
['Toolbarswitch', 'Source'], |
253
|
|
|
]; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Get the toolbar configuration when CKEditor is maximized. |
258
|
|
|
* |
259
|
|
|
* @return array |
260
|
|
|
*/ |
261
|
|
|
protected function getMaximizedToolbar() |
262
|
|
|
{ |
263
|
|
|
return [ |
264
|
|
|
$this->getNewPageBlock(), |
265
|
|
|
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'inserthtml'], |
266
|
|
|
['Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'], |
267
|
|
|
['Link', 'Unlink', 'Anchor', 'Glossary'], |
268
|
|
|
[ |
269
|
|
|
'Image', |
270
|
|
|
'Mapping', |
271
|
|
|
'Video', |
272
|
|
|
'Oembed', |
273
|
|
|
'Flash', |
274
|
|
|
'Youtube', |
275
|
|
|
'VimeoEmbed', |
276
|
|
|
'Audio', |
277
|
|
|
'leaflet', |
278
|
|
|
'Smiley', |
279
|
|
|
'SpecialChar', |
280
|
|
|
'Asciimath', |
281
|
|
|
'Asciisvg', |
282
|
|
|
], |
283
|
|
|
'/', |
284
|
|
|
['Table', '-', 'CreateDiv'], |
285
|
|
|
['BulletedList', 'NumberedList', 'HorizontalRule', '-', 'Outdent', 'Indent', 'Blockquote'], |
286
|
|
|
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], |
287
|
|
|
['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript', '-', 'TextColor', 'BGColor'], |
288
|
|
|
['true' === api_get_setting('allow_spellcheck') ? 'Scayt' : ''], |
289
|
|
|
['Styles', 'Format', 'Font', 'FontSize'], |
290
|
|
|
['PageBreak', 'ShowBlocks'], |
291
|
|
|
'true' === api_get_setting('enabled_wiris') ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''], |
292
|
|
|
['Toolbarswitch', 'Source'], |
293
|
|
|
]; |
294
|
|
|
} |
295
|
|
|
} |
296
|
|
|
|