You are here

function jquery_touchpunch_requirements in jQuery UI Touch Punch 7

Implements hook_requirements().

File

./jquery_touchpunch.install, line 11
Intallation hooks.

Code

function jquery_touchpunch_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    $library = libraries_detect('jquery.ui.touch-punch');
    $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
    $error_message = isset($library['error message']) ? $library['error message'] : '';
    if ($library['installed']) {
      $description = $t('Installed variants') . ' : ';
      foreach ($library['variants'] as $variant_name => $variant) {
        if ($variant['installed']) {
          $description .= $variant_name . ', ';
        }
      }
      $requirements['jquery.ui.touch-punch'] = array(
        'title' => $t('jQuery UI Touch Punch'),
        'value' => $library['version'],
        'severity' => REQUIREMENT_OK,
        'description' => substr($description, 0, -2),
      );
    }
    else {
      $requirements['jquery.ui.touch-punch'] = array(
        'title' => $t('jQuery UI Touch Punch'),
        'value' => $t('@e', array(
          '@e' => $error_type,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => jquery_touchpunch_error_message($error_message, $library),
      );
    }
  }
  return $requirements;
}