You are here

function wysiwyg_ckeditor_version in Wysiwyg 6.2

Same name and namespace in other branches
  1. 5.2 editors/ckeditor.inc \wysiwyg_ckeditor_version()
  2. 7.2 editors/ckeditor.inc \wysiwyg_ckeditor_version()

Detect editor version.

Parameters

$editor: An array containing editor properties as returned from hook_editor().

Return value

The installed editor version.

2 string references to 'wysiwyg_ckeditor_version'
hook_INCLUDE_editor in ./wysiwyg.api.php
Define a Wysiwyg editor library.
wysiwyg_ckeditor_editor in editors/ckeditor.inc
Plugin implementation of hook_editor().

File

editors/ckeditor.inc, line 162
Editor integration functions for CKEditor.

Code

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'
    // version:"4.0",revision:"769d96134b"
    if (preg_match('@version:[\'"](?:CKEditor )?([\\d\\.]+)(?:.+revision:[\'"]([[:xdigit:]]+))?@', $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] . '.' . $version[2];
    }
    $max_lines--;
  }
  fclose($library);
}