forked from ExchangeCore/Concrete5-CKEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
214 lines (197 loc) · 8.22 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
namespace Concrete\Package\CommunityCkeditor;
use Concrete\Core\Editor\Plugin;
use Concrete\Core\Foundation\Service\ProviderList;
use Concrete\Core\Package\Package;
use Core;
class Controller extends Package
{
protected $pkgHandle = 'community_ckeditor';
protected $appVersionRequired = '5.7.5';
protected $pkgVersion = '0.1.1';
public function getPackageName()
{
return t('Community CKEditor');
}
public function getPackageDescription()
{
return t('Overrides the default concrete5 editor with CKEditor');
}
public function install()
{
parent::install();
$this->setupDefaultPlugins();
}
public function on_start()
{
$this->overrideEditor();
}
protected function overrideEditor()
{
$assetList = \AssetList::getInstance();
$assetList->register(
'javascript',
'editor/ckeditor',
'vendor/ckeditor/ckeditor.js',
array(),
$this->pkgHandle
);
$assetList->register(
'javascript',
'editor/ckeditor/jquery_adapter',
'vendor/ckeditor/adapters/jquery.js',
array(),
$this->pkgHandle
);
$assetList->registerGroup(
'editor/ckeditor',
array(
array('javascript', 'editor/ckeditor'),
array('javascript', 'editor/ckeditor/jquery_adapter')
)
);
$providers = new ProviderList(\Core::getFacadeRoot());
$providers->registerProvider('Concrete\Package\CommunityCkeditor\Src\Editor\EditorServiceProvider');
$this->registerInlinePlugin();
$this->registerInternalPlugins();
}
protected function registerInlinePlugin()
{
$assetList = \AssetList::getInstance();
$assetList->register(
'javascript',
'editor/ckeditor/concrete5inline',
'assets/concrete5inline/register.js',
array(),
$this->pkgHandle
);
$assetList->register(
'css',
'editor/ckeditor/concrete5inline',
'assets/concrete5inline/styles.css',
array(),
$this->pkgHandle
);
$assetList->registerGroup(
'editor/ckeditor/concrete5inline',
array(
array('javascript', 'editor/ckeditor/concrete5inline'),
array('css', 'editor/ckeditor/concrete5inline')
)
);
$plugin = new Plugin();
$plugin->setKey('concrete5inline');
$plugin->setName(t('Concrete5 Inline'));
$plugin->requireAsset('editor/ckeditor/concrete5inline');
Core::make('editor')->getPluginManager()->register($plugin);
}
protected function registerInternalPlugins()
{
$pluginList = array(
array('key' => 'about', 'name' => t('About')),
array('key' => 'a11yhelp', 'name' => t('Accessibility Help')),
array('key' => 'basicstyles', 'name' => t('Basic Styles')),
array('key' => 'bidi', 'name' => t('BiDi (Text Direction)')),
array('key' => 'blockquote', 'name' => t('Blockquote')),
array('key' => 'clipboard', 'name' => t('Clipboard')),
array('key' => 'colorbutton', 'name' => t('Color Button')),
array('key' => 'colordialog', 'name' => t('Color Dialog')),
array('key' => 'contextmenu', 'name' => t('Context Menu')),
array('key' => 'dialogadvtab', 'name' => t('Advanced Tab for Dialogs')),
array('key' => 'div', 'name' => t('Div Container Manager')),
array('key' => 'elementspath', 'name' => t('Elements Path')),
array('key' => 'enterkey', 'name' => t('Enter Key')),
array('key' => 'entities', 'name' => t('Escape HTML Entities')),
//array('key' => 'filebrowser', 'name' => t('File Browser')), todo: implement concrete5 file manager
array('key' => 'find', 'name' => t('Find / Replace')),
array('key' => 'flash', 'name' => t('Flash Dialog')),
array('key' => 'floatingspace', 'name' => t('Floating Space')),
array('key' => 'font', 'name' => t('Font Size and Famiy')),
array('key' => 'format', 'name' => t('Format')),
array('key' => 'forms', 'name' => t('Form Elements')),
array('key' => 'horizontalrule', 'name' => t('Horizontal Rule')),
array('key' => 'htmlwriter', 'name' => t('HTML Output Writer')),
array('key' => 'iframe', 'name' => t('IFrame Dialog')),
array('key' => 'image', 'name' => t('Image')), //todo: integrate/replace with concrete5 file manager
array('key' => 'indentblock', 'name' => t('Indent Block')),
array('key' => 'indentlist', 'name' => t('Indent List')),
array('key' => 'justify', 'name' => t('Justify')),
array('key' => 'language', 'name' => t('Language')),
array('key' => 'link', 'name' => t('Link')), //todo: integrate/replace with sitemap support
array('key' => 'list', 'name' => t('List')),
array('key' => 'liststyle', 'name' => t('List Style')),
array('key' => 'magicline', 'name' => t('Magic Line')),
array('key' => 'maximize', 'name' => t('Maximize')),
array('key' => 'newpage', 'name' => t('New Page')),
array('key' => 'pagebreak', 'name' => t('Page Break')),
array('key' => 'pastetext', 'name' => t('Paste As Plain Text')),
array('key' => 'pastefromword', 'name' => t('Paste from Word')),
array('key' => 'preview', 'name' => t('Preview')),
array('key' => 'removeformat', 'name' => t('Remove Format')),
array('key' => 'resize', 'name' => t('Editor Resize')),
array('key' => 'scayt', 'name' => t('SpellCheckAsYouType (SCAYT)')),
array('key' => 'selectall', 'name' => t('Select All')),
array('key' => 'showblocks', 'name' => t('Show Blocks')),
array('key' => 'showborders', 'name' => t('Show Table Borders')),
array('key' => 'smiley', 'name' => t('Insert Smiley')),
array('key' => 'sourcearea', 'name' => t('Source Editing Area')),
array('key' => 'specialchar', 'name' => t('Special Characters')),
array('key' => 'stylescombo', 'name' => t('Styles Combo')),
array('key' => 'tab', 'name' => t('Tab Key Handling')),
array('key' => 'table', 'name' => t('Table')),
array('key' => 'tabletools', 'name' => t('Table Tools')),
array('key' => 'templates', 'name' => t('Content Templates')),
array('key' => 'toolbar', 'name' => t('Editor Toolbar')),
array('key' => 'undo', 'name' => t('Undo')),
array('key' => 'wsc', 'name' => t('WebSpellChecker')),
array('key' => 'wysiwygarea', 'name' => t('IFrame Editing Area')),
);
foreach ($pluginList as $plugin) {
$editorPlugin = new Plugin();
$editorPlugin->setKey($plugin['key']);
$editorPlugin->setName($plugin['name']);
Core::make('editor')->getPluginManager()->register($editorPlugin);
}
}
protected function setupDefaultPlugins()
{
$this->getConfig()->save(
'plugins',
array(
'a11yhelp',
'basicstyles',
'colorbutton',
'colordialog',
'contextmenu',
'dialogadvtab',
'elementspath',
'enterkey',
'entities',
'floatingspace',
'font',
'format',
'htmlwriter',
'image',
'indentblock',
'indentlist',
'justify',
'link',
'list',
'liststyle',
'magicline',
'removeformat',
'resize',
'showblocks',
'showborders',
'sourcearea',
'stylescombo',
'tab',
'table',
'tabletools',
'toolbar',
'undo',
'wysiwygarea'
)
);
}
}