1
1
<?php
2
-
3
- if (!defined ('PHPLISTINIT ' )) {
4
- die ('Access denied ' );
5
- }
2
+ /**
3
+ * CKEditorPlugin for phplist.
4
+ *
5
+ * This file is a part of CKEditorPlugin.
6
+ *
7
+ * This plugin is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ * This plugin is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * @category phplist
17
+ *
18
+ * @author Duncan Cameron
19
+ * @copyright 2013-2018 Duncan Cameron
20
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, Version 3
21
+ * */
6
22
7
23
class CKEditorPlugin extends phplistPlugin
8
24
{
@@ -27,6 +43,12 @@ public function editor($fieldName, $content): string
27
43
$ licenseKey = getConfig ('ckeditor_license_key ' );
28
44
$ licenseKeyScript = "licenseKey: ' $ licenseKey' " ;
29
45
$ editorUrl = getConfig ('ckeditor_url ' ) ? getConfig ('ckeditor_url ' ) : self ::CDN ;
46
+ $ configVersion = $ this ->getCkeditorVersion ($ editorUrl );
47
+ $ cdnVersion = $ this ->getCkeditorVersion (self ::CDN );
48
+
49
+ if (version_compare ($ configVersion , $ cdnVersion , '< ' )) {
50
+ $ editorUrl = self ::CDN ;
51
+ }
30
52
31
53
$ script = $ this ->editorScript ($ fieldName , $ width , $ height , $ licenseKeyScript , $ editorUrl );
32
54
$ fieldName = htmlspecialchars ($ fieldName );
@@ -140,4 +162,10 @@ public function display($action)
140
162
break ;
141
163
}
142
164
}
165
+
166
+ public function getCkeditorVersion ($ url ) {
167
+ preg_match ('/ckeditor5\/([\d\.]+)\// ' , $ url , $ matches );
168
+ return $ matches [1 ] ?? null ;
169
+ }
170
+
143
171
}
0 commit comments