You are here

function form_styler_requirements in jQuery form styler 7.2

Same name and namespace in other branches
  1. 7 form_styler.install \form_styler_requirements()

Implements hook_requirements().

File

./form_styler.install, line 11
Contains install and update functions for form_styler.

Code

function form_styler_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    $plugin_min_version = '1.7.6';
    $plugin_name = $t('jQuery form styler plugin');
    $library = libraries_detect('jquery_form_styler');
    if (empty($library['installed'])) {
      $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
      $error_message = isset($library['error message']) ? $library['error message'] : '';
      $description = '!error You need to download the !form_styler, extract the' . ' archive, rename it to "jquery_form_styler" and place the plugin ' . 'directory in the %path directory on your server.';
      $options = array(
        '!error' => $error_message,
        '!form_styler' => l($plugin_name, $library['download url']),
        '%path' => 'sites/all/libraries',
      );
      $requirements['jquery_form_styler_plugin'] = array(
        'title' => $plugin_name,
        'value' => $t('@e: At least @a', array(
          '@e' => $error_type,
          '@a' => $plugin_min_version,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t($description, $options),
      );
    }
    elseif (version_compare($library['version'], $plugin_min_version, '>=')) {
      $requirements['jquery_form_styler_plugin'] = array(
        'title' => $plugin_name,
        'severity' => REQUIREMENT_OK,
        'value' => $library['version'],
      );
    }
    else {
      $description = 'You need to download a later version of the !form_styler ' . 'and replace the old version located in the %path directory on your' . ' server.';
      $options = array(
        '!form_styler' => l($plugin_name, $library['download url']),
        '%path' => $library['library path'],
      );
      $requirements['jquery_form_styler_plugin'] = array(
        'title' => $plugin_name,
        'value' => $t('At least @a', array(
          '@a' => $plugin_min_version,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t($description, $options),
      );
    }
  }
  return $requirements;
}