You are here

function ckeditor_codemirror_requirements in CKEditor CodeMirror 7

Same name and namespace in other branches
  1. 8.2 ckeditor_codemirror.install \ckeditor_codemirror_requirements()
  2. 8 ckeditor_codemirror.install \ckeditor_codemirror_requirements()

Implements hook_requirements().

File

./ckeditor_codemirror.install, line 11
Install, update and uninstall functions for the CKEditor CodeMirror module.

Code

function ckeditor_codemirror_requirements($phase) {
  if ($phase != 'runtime') {
    return array();
  }
  $return = array();

  // Ensure translations don't break at install time.
  $t = get_t();

  // If the library is installed.
  if (($library = libraries_detect('ckeditor.codemirror')) && !empty($library['installed'])) {
    $return['ckeditor_codemirror_library'] = array(
      'title' => $t('CKEditor CodeMirror'),
      'severity' => REQUIREMENT_OK,
      'value' => $t('CKEditor CodeMirror plugin %version installed at %path.', array(
        '%path' => $library['library path'],
        '%version' => $library['version'],
      )),
    );
  }
  else {
    $return['ckeditor_codemirror_library'] = array(
      'title' => $t('CKEditor CodeMirror'),
      'severity' => REQUIREMENT_ERROR,
      'value' => $t('CKEditor CodeMirror plugin was not found. Download <a href="@link">the latest version of library</a> and place it in the libraries directory (sites/all/libraries/ckeditor.codemirror).', array(
        '@link' => 'https://github.com/w8tcha/CKEditor-CodeMirror-Plugin/releases',
      )),
    );
  }
  return $return;
}