Created
December 9, 2015 14:48
-
-
Save adamjakab/f27cf20f59d2361bd693 to your computer and use it in GitHub Desktop.
WYSIWYG - fix CKEditor version(4+) check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (preg_match('@version:[\'"](?:CKEditor )?([\d\.]+)(?:.+revision:[\'"]([\d]+))?@', $line, $version)) { |
opppps, this is better if you don't want warnings for $version[2] when it is missing
/**
* Detect editor version.
*
* @param $editor
* An array containing editor properties as returned from hook_editor().
*
* @return
* The installed editor version.
*/
function wysiwyg_ckeditor_version($editor) {
$library = $editor['library path'] . '/ckeditor.js';
if (!file_exists($library)) {
return;
}
$library = fopen($library, 'r');
$max_lines = 8;
while ($max_lines && $line = fgets($library, 500)) {
// version:'CKEditor 3.0 SVN',revision:'3665'
// version:'3.0 RC',revision:'3753'
// version:'3.0.1',revision:'4391'
if (preg_match('@version:[\'"](?:CKEditor )?([\d\.]+)(?:.+revision:[\'"]([\d]+))?@', $line, $version)) {
fclose($library);
// Version numbers need to have three parts since 3.0.1.
$version[1] = preg_replace('/^(\d+)\.(\d+)$/', '${1}.${2}.0', $version[1]);
return $version[1] . (isset($version[2]) ? '.' . $version[2] : '');
}
$max_lines--;
}
fclose($library);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is line ~81 in: /wysiwyg/editors/ckeditor.inc module: wysiwyg for Drupal 7