You are here

function ckwordcount_requirements in CKEditor Wordcount 8

Same name and namespace in other branches
  1. 2.x ckwordcount.install \ckwordcount_requirements()

Implements hook_requirements().

File

./ckwordcount.install, line 11
Ckeditor Word Count Module.

Code

function ckwordcount_requirements($phase) {
  $requirements = [];
  if ($phase == 'install' || $phase == 'runtime') {
    $plugin_detected = file_exists(DRUPAL_ROOT . '/libraries/wordcount/plugin.js') || file_exists(DRUPAL_ROOT . '/libraries/ckeditor-wordcount-plugin/wordcount/plugin.js');
    if ($plugin_detected) {
      $requirements['wordcount'] = [
        'title' => t('CKEditor Wordcount'),
        'value' => t('Plugin detected'),
        'severity' => REQUIREMENT_OK,
      ];
    }
    else {
      $requirements['wordcount'] = [
        'title' => t('CKEditor Wordcount'),
        'value' => t('Plugin not detected'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('You will need the CKEditor plugin for counting words and characters before enabling this module. <a href=":plugin_url">Get the plugin here</a>.', [
          ':plugin_url' => 'http://ckeditor.com/addon/wordcount',
        ]),
      ];
    }
  }
  return $requirements;
}