You are here

function bootstrap_library_requirements in Bootstrap Library 7

Same name and namespace in other branches
  1. 8 bootstrap_library.install \bootstrap_library_requirements()

Implements hook_requirements().

File

./bootstrap_library.module, line 12
Primarily Drupal hooks.

Code

function bootstrap_library_requirements($phase) {

  // Create an array to hold Bootstrap requirements
  $requirements = array();

  // Check requirements during the runtime phase
  if ($phase == 'runtime') {

    // Check if the Bootstrap library is installed
    if (($library = libraries_detect('bootstrap')) && !empty($library['installed'])) {
      $requirements['boostrap_library_library'] = array(
        'title' => t('Bootstrap plugin'),
        'value' => t('Installed'),
        'severity' => REQUIREMENT_OK,
      );
    }
    else {
      $requirements['boostrap_library_library'] = array(
        'title' => t('Bootstrap plugin'),
        'value' => t('Not installed'),
        'description' => $library['error message'],
        'severity' => REQUIREMENT_ERROR,
      );
    }

    // Check if the site is running >= jQuery 1.7
    $library = drupal_get_library('system', 'jquery');
    if (version_compare($library['version'], '1.7', '>=')) {
      $requirements['boostrap_library_jquery'] = array(
        'title' => t('Bootstrap version'),
        'value' => t('jQuery @version', array(
          '@version' => $library['version'],
        )),
        'severity' => REQUIREMENT_OK,
      );
    }
    else {
      $destination = drupal_get_destination();
      $requirements['boostrap_library_jquery'] = array(
        'title' => t('Bootstrap version'),
        'value' => t('jQuery @version', array(
          '@version' => $library['version'],
        )),
        'description' => t('Bootstrap requires jQuery 1.7 or greater. Configure <a href="@jquery_update">jQuery Update</a>.', array(
          '@jquery_update' => url('admin/config/development/jquery_update', array(
            'query' => $destination,
          )),
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}