You are here

function superfish_requirements in Superfish 6

Same name and namespace in other branches
  1. 8 superfish.install \superfish_requirements()
  2. 7 superfish.install \superfish_requirements()

Implements hook_requirements().

File

./superfish.install, line 26
Install, update and uninstall functions for the Superfish module.

Code

function superfish_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {

    // Ensure translations do not break at install time.
    $t = get_t();

    // Ensure the Superfish library is present.
    $requirements['superfish']['title'] = $t('Superfish library');
    if (module_exists('libraries') && function_exists('libraries_get_libraries')) {
      $library = libraries_get_libraries();
      $superfish_installed = isset($library['superfish']) ? TRUE : FALSE;
    }
    elseif (file_exists('sites/all/libraries/superfish/superfish.js')) {
      $superfish_installed = TRUE;
    }
    else {
      $superfish_installed = FALSE;
    }
    if ($superfish_installed) {
      $requirements['superfish']['value'] = $t('Installed');
      $requirements['superfish']['severity'] = REQUIREMENT_OK;
    }
    else {
      $requirements['superfish']['value'] = $t('Not installed');
      $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
      $requirements['superfish']['description'] = $t('Please download the Superfish library from !link.', array(
        '!link' => l('http://drupal.org/project/superfish', 'http://drupal.org/project/superfish'),
      ));
    }

    // Check the uploaded Superfish library version.
    if (superfish_library_version() != '1.2-beta2') {
      $requirements['superfish']['value'] = $t('Not supported');
      $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
      $requirements['superfish']['description'] = $t('The Superfish library requires an update. You can find the update instructions on !link.', array(
        '!link' => l('http://drupal.org/project/superfish', 'http://drupal.org/project/superfish'),
      ));
    }
  }
  return $requirements;
}