You are here

function auto_height_requirements in jQuery Auto Height 8

Same name and namespace in other branches
  1. 7.2 auto_height.install \auto_height_requirements()
  2. 7 auto_height.install \auto_height_requirements()

Implements hook_requirements().

File

./auto_height.install, line 11
Install, update, and uninstall functions for the jQuery Auto Height module.

Code

function auto_height_requirements($phase) {
  $requirements = array();

  // Check if plugin exists
  if ($phase == 'install') {
    $path = DRUPAL_ROOT . '/libraries/autoheight/jquery.autoheight.js';
    $installed = file_exists($path);
    if (!$installed) {

      // display a warning message..
      drupal_set_message(t('The jQuery AutoHeight plugin is missing. <a href="https://raw.githubusercontent.com/monocult/jquery-autoheight/master/jquery.autoheight.js" rel="external">Download the plugin</a> and place it in /libraries/autoheight/jquery.autoheight.js'), 'warning');
    }
  }
  else {
    if ($phase == 'runtime') {
      $path = DRUPAL_ROOT . '/libraries/autoheight/jquery.autoheight.js';
      $installed = file_exists($path);
      if (!$installed) {
        $requirements['auto_height'] = array(
          'title' => t('jQuery AutoHeight plugin'),
          'value' => t('Missing'),
          'description' => t('<a href=":url" rel="external">Download the plugin</a> and place it in :library', array(
            ':url' => AUTOHEIGHT_PLUGIN_URL,
            ':library' => AUTOHEIGHT_LIBRARY_PATH,
          )),
          'severity' => REQUIREMENT_WARNING,
        );
      }
      else {
        $requirements['auto_height'] = array(
          'title' => t('jQuery AutoHeight plugin'),
          'value' => t('Installed'),
          'severity' => REQUIREMENT_OK,
        );
      }
    }
  }
  return $requirements;
}