You are here

function clientside_validation_requirements in Clientside Validation 7.2

Implements hook_requirements()

File

./clientside_validation.module, line 37
Add client side validation to forms.

Code

function clientside_validation_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime' || $phase == 'update') {

    // Fix dependencies first.
    if ($phase == 'update' && !module_exists('libraries')) {
      return $requirements;
    }
    $t = get_t();
    $lib = libraries_detect('jquery.validate');
    if ($lib['installed']) {
      $requirements['clientside_validation'] = array(
        'title' => $t('Clientside Validation'),
        'value' => $t('jquery.validate found under !path', array(
          '!path' => $lib['library path'] . '/dist/jquery.validate.js',
        )),
        'severity' => REQUIREMENT_OK,
      );
      return $requirements;
    }
    $requirements['clientside_validation'] = array(
      'title' => $t('Clientside Validation'),
      'value' => isset($lib['error message']) ? $t($lib['error message']) : t('jQuery Validate library was not found. !download the library and place in under sites/all/libraries/jquery.validate, so that the library can be found at sites/all/libraries/jquery.validate/dist/jquery.validate.js.', array(
        '!download' => l(t('Download'), 'https://github.com/jzaefferer/jquery-validation/releases'),
      )),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}