You are here

function ckeditor_requirements in CKEditor - WYSIWYG HTML editor 7

Same name and namespace in other branches
  1. 6 ckeditor.install \ckeditor_requirements()

Implementation of hook_requirements().

This hook will issue warnings if:

  • The CKEditor source files are not found.
  • The CKEditor source files are out of date.
  • Quick upload and/or the built-in file browser are used and $cookie_domain is not set.

File

./ckeditor.install, line 214

Code

function ckeditor_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    module_load_include('module', 'ckeditor');
    module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
    $requirements['ckeditor'] = array(
      'title' => t('CKEditor'),
      'value' => t('Unknown'),
    );
    $requirements['ckeditor']['severity'] = REQUIREMENT_OK;
    if (!_ckeditor_requirements_isinstalled()) {
      $sourcepath = ckeditor_path('local');
      $requirements['ckeditor']['description'] = t('CKEditor was not found in <code>%sourcepath</code>.', array(
        '%sourcepath' => $sourcepath,
      ));
      $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
    }
    elseif (($installed_version = _ckeditor_requirements_getinstalledversion()) === NULL) {
      $requirements['ckeditor']['description'] = t('CKEditor version could not be determined.');
      $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
    }
    else {
      $profile_name = _ckeditor_requirements_ckfinder_filebrowser_enabled();
      if ($profile_name !== FALSE) {
        if (!_ckeditor_requirements_cookiedomainset()) {
          $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
          $requirements['ckeditor']['description'] = t('You are using a feature that requires <code>$cookie_domain</code> to be set, but it is not set in your <code>settings.php</code> file (CKFinder is enabled in the !profile profile).', array(
            '!profile' => l($profile_name, 'admin/config/content/ckeditor/edit/' . urlencode($profile_name)),
          ));
        }
        elseif ($error = _ckeditor_requirements_ckfinder_config_check($profile_name)) {
          $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
          $requirements['ckeditor']['description'] = $error;
        }
      }
    }
    if (($installed_version = _ckeditor_requirements_getinstalledversion()) !== NULL && $installed_version != '%VERSION%' && $installed_version != '<URL>' && -1 == version_compare($installed_version, '3.1 SVN')) {
      $requirements['ckeditor']['description'] = t('Some features are disabled because you are using an older version of CKEditor. Please upgrade to CKEditor 3.1 (or higher).');
      $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
    }
    if (!empty($installed_version)) {
      if ($installed_version == '%VERSION%') {
        $requirements['ckeditor']['value'] = 'GIT version';
      }
      else {
        if ($installed_version == '<URL>') {
          $requirements['ckeditor']['value'] = 'Unknown version. CKEditor is loaded from a remote URL.';
          $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
        }
        else {
          $requirements['ckeditor']['value'] = $installed_version;
        }
      }
    }
    else {
      $requirements['ckeditor']['value'] = t('Not found');
    }
  }
  return $requirements;
}