Skip to content

Commit a5cd85d

Browse files
committed
Use new version
1 parent 29bdd09 commit a5cd85d

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

plugins/CKEditorPlugin.php

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
<?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+
* */
622

723
class CKEditorPlugin extends phplistPlugin
824
{
@@ -27,6 +43,12 @@ public function editor($fieldName, $content): string
2743
$licenseKey = getConfig('ckeditor_license_key');
2844
$licenseKeyScript = "licenseKey: '$licenseKey'";
2945
$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+
}
3052

3153
$script = $this->editorScript($fieldName, $width, $height, $licenseKeyScript, $editorUrl);
3254
$fieldName = htmlspecialchars($fieldName);
@@ -140,4 +162,10 @@ public function display($action)
140162
break;
141163
}
142164
}
165+
166+
public function getCkeditorVersion($url) {
167+
preg_match('/ckeditor5\/([\d\.]+)\//', $url, $matches);
168+
return $matches[1] ?? null;
169+
}
170+
143171
}

0 commit comments

Comments
 (0)