You are here

function datatables_requirements in DataTables 7

Same name and namespace in other branches
  1. 6 datatables.install \datatables_requirements()
  2. 7.2 datatables.install \datatables_requirements()

Implements hook_requirements().

File

./datatables.install, line 11
Installation file for Datatables module.

Code

function datatables_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    $requirements['datatables']['title'] = 'DataTables';
    $requirements['datatables']['value'] = NULL;
    if (file_exists(drupal_get_path('module', 'datatables') . '/dataTables/media/js/jquery.dataTables.js')) {
      $requirements['datatables']['severity'] = REQUIREMENT_OK;
    }
    elseif (module_exists('libraries') && file_exists(libraries_get_path('datatables') . '/media/js/jquery.dataTables.js')) {
      $requirements['datatables']['severity'] = REQUIREMENT_OK;
    }
    else {

      // Required datatables library wasn't found. Abort installation.
      $requirements['datatables']['value'] = $t('Not found');

      // Provide a download link to the DataTables jQuery Plugin.
      $requirements['datatables']['description'] = $t('The <a href="!datatables">DataTables</a> plugin is missing. <a href="!download">Download</a> and extract it to your <em>datatables</em> module directory. See <a href="!readme">README.txt</a> for more info.', array(
        '!datatables' => 'http://datatables.net/',
        '!download' => 'http://datatables.net/releases/DataTables-1.9.0.zip',
        '!readme' => 'http://drupalcode.org/project/datatables.git/blob_plain/refs/heads/7.x-1.x:/README.txt',
      ));
      $requirements['datatables']['severity'] = REQUIREMENT_ERROR;
    }
  }
  return $requirements;
}