You are here

function ckeditor_get_version in CKEditor - WYSIWYG HTML editor 7

Same name and namespace in other branches
  1. 6 ckeditor.module \ckeditor_get_version()

Check CKEditor version

3 calls to ckeditor_get_version()
ckeditor_admin_profile_form in includes/ckeditor.admin.inc
Form builder for a profile
ckeditor_admin_profile_form_validate in includes/ckeditor.admin.inc
Form validation for a profile.
ckeditor_default_skin in includes/ckeditor.lib.inc
Return default skin for CKEditor

File

./ckeditor.module, line 216
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_get_version($main_version = FALSE) {
  static $ckeditor_version = FALSE;
  if ($ckeditor_version !== FALSE) {
    if (!$main_version) {
      return $ckeditor_version;
    }
    $version = explode('.', $ckeditor_version);
    return trim($version[0]);
  }
  $editor_path = ckeditor_path('local', TRUE);
  if ($editor_path == '<URL>') {
    $url = ckeditor_path('url', TRUE);
    $matches = array();
    if (preg_match("|cdn.ckeditor.com/(\\d(\\.\\d+)+.*)/|i", $url, $matches)) {
      $ckeditor_version = $matches[1];
      return $matches[1];
    }
    return $ckeditor_version = NULL;
  }
  $jspath = $editor_path . '/ckeditor.js';
  $configcontents = @file_get_contents($jspath);
  if (!$configcontents) {
    return $ckeditor_version = NULL;
  }
  $matches = array();
  if (preg_match('#,version:[\'\\"]{1}(.*?)[\'\\"]{1},#', $configcontents, $matches)) {
    $ckeditor_version = $matches[1];
    if ($ckeditor_version == '%VERSION%') {
      $ckeditor_version = '4.0.0';
    }
    if (!$main_version) {
      return $ckeditor_version;
    }
    $version = explode('.', $ckeditor_version);
    return trim($version[0]);
  }
  return $ckeditor_version = NULL;
}