You are here

function ckeditor_get_version in CKEditor - WYSIWYG HTML editor 6

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

Check CKEditor version

2 calls to ckeditor_get_version()
ckeditor_admin_profile_form in includes/ckeditor.admin.inc
Form builder for a normal profile
ckeditor_admin_profile_form_validate in includes/ckeditor.admin.inc
Profile validation.

File

./ckeditor.module, line 107
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(TRUE, TRUE);
  $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;
}