You are here

function quail_api_requirements in Quail API 7

Implements hook_requirements().

File

./quail_api.install, line 11
Install file for the quail api.

Code

function quail_api_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    $requirements['quail_library_available'] = array();
    $requirements['quail_library_available']['title'] = $t("Quail Library");
    $requirements['quail_library_available']['value'] = $t("Failed");
    $requirements['quail_library_available']['severity'] = REQUIREMENT_ERROR;
    if (function_exists('libraries_detect')) {
      $library = libraries_detect('quail');
    }
    else {
      $library = FALSE;
    }
    if ($library) {
      $library = libraries_load('quail');
      if (empty($library['loaded'])) {
        if (empty($library['error'])) {
          $requirements['quail_library_available']['value'] = $t('Found but Failed to Load');
          $requirements['quail_library_available']['description'] = $t("Unable to load Quail-Lib.");
        }
        else {
          $requirements['quail_library_available']['value'] = $library['error'];
          $requirements['quail_library_available']['description'] = $library['error message'];
        }
      }
      else {
        $requirements['quail_library_available']['value'] = $library['version'];
        $requirements['quail_library_available']['severity'] = REQUIREMENT_OK;
      }
    }
    else {
      if (empty($library['error'])) {
        $log_message = "Unable to find the Quail php library. ";
        $log_message .= "You can download the Quail library from <a href='@quail_url'>@quail_url</a>. ";
        $log_message .= "Make sure to place the extracted quail library at the appropriate library path, (which is usually in /sites/all/libraries/)";
        $requirements['quail_library_available']['description'] = $t($log_message, array(
          '@quail_url' => "http://code.google.com/p/quail-lib/",
        ));
      }
      else {
        $requirements['quail_library_available']['value'] = $library['error'];
        $requirements['quail_library_available']['description'] = $library['error message'];
      }
    }
  }
  return $requirements;
}