Chamilo
Search…
Customizing the online editor
In Chamilo 1.10 and later, we use CKeditor as a WYSIWYG (What You See Is What You Get) or “online” HTML editor. This was not the case with Chamilo 1.9, which still used the now-dead FCKeditor.
Sometimes, you might want to customize the editor for some particular item in Chamilo. This can be done, for existing custom element types, in the src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/ directory.
There, you’ll find a series of files of the following form:
1
/* For licensing terms, see /license.txt */
2
3
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
4
5
/**
6
* Messages toolbar configuration
7
*
8
* @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
9
*/
10
class Messages extends Basic
11
{
12
/**
13
* Get the toolbar config
14
* @return array
15
*/
16
public function getConfig()
17
{
18
if (api_get_setting('more_buttons_maximized_mode') != 'true') {
19
$config['toolbar'] = $this→getNormalToolbar();
20
} else {
21
$config['toolbar_minToolbar'] = $this→getMinimizedToolbar();
22
$config['toolbar_maxToolbar'] = $this→getMaximizedToolbar();
23
}
24
25
$config['fullPage'] = true;
26
//$config['height'] = '200';
27
return $config;
28
}
29
30
/**
31
* Get the toolbar configuration when CKEditor is maximized
32
* @return array
33
*/
34
protected function getMaximizedToolbar()
35
{
36
return [
37
['NewPage', 'Templates', '-', 'Preview', 'Print'],
38
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
39
['Undo', 'Redo', '-', 'SelectAll', 'Find', '-','RemoveFormat'],
40
['Link', 'Unlink', 'Anchor', 'Glossary'],
41
[ 'Image', 'Mapping', 'Video', 'Oembed', 'Youtube', 'Flash', 'Audio', 'leaflet', 'Smiley', 'SpecialChar', 'Inserthtml', 'Asciimath', 'Asciisvg' ],
42
'/',
43
['Table', '-', 'CreateDiv'],
44
['BulletedList', 'NumberedList', 'HorizontalRule', '-','Outdent', 'Indent', 'Blockquote'],
45
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
46
['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript', '-', 'TextColor', 'BGColor'],
47
[api_get_setting('allow_spellcheck') == 'true' ? 'Scayt' : ''],
48
['Styles', 'Format', 'Font', 'FontSize'],
49
['PageBreak', 'ShowBlocks', 'Source'],
50
['Toolbarswitch']
51
];
52
}
53
54
/**
55
* Get the default toolbar configuration when the setting
56
* more_buttons_maximized_mode is false
57
* @return array
58
*/
59
protected function getNormalToolbar()
60
{
61
return [
62
['Link', 'Unlink'],
63
['Image', 'Video', 'Flash', 'Oembed', 'Youtube', 'Audio'],
64
['Table', 'Smiley'],
65
['TextColor', 'BGColor'],
66
['Source'],
67
'/',
68
['Font', 'FontSize'],
69
['Bold', 'Italic', 'Underline'],
70
['JustifyLeft', 'JustifyCenter', '-', 'NumberedList', 'BulletedList']
71
];
72
}
73
/**
74
* Get the toolbar configuration when CKEditor is minimized
75
* @return array
76
*/
77
protected function getMinimizedToolbar()
78
{
79
return [
80
$this→getNewPageBlock(),
81
['Undo', 'Redo'],
82
['Link', 'Image', 'Video', 'Flash', 'Audio', 'Table','Asciimath', 'Asciisvg'],
83
['BulletedList', 'NumberedList', 'HorizontalRule'],
84
['JustifyLeft', 'JustifyCenter'],
85
['Format', 'Font', 'Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'],
86
['Toolbarswitch']
87
];
88
}
89
}
Copied!
As you can probably appreciate, the structure is simply:
  • a class extending the “Basic” class for the editor
  • a getConfig() method to get some global configuration (like size of the area)
  • a getMaximizedToolbar() method that defines the options to be shown when maximized
  • a getNormalToolbar() method that defines the options to be shown when normal
  • a getMinimizedToolbar() method that defines the options to be shown when minimized
If you want to change one of the tools offered in the toolbars for a specific case, just change it here.
Note, however, that this customization is not part of the normally-accepted customizations, so you will have to keep it on record somewhere to be able to apply it again when the next version comes out.
Export as PDF
Copy link