You are here

function feeds_requirements in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds.install \feeds_requirements()

Implements hook_requirements().

File

./feeds.install, line 11
Schema definitions install/update/uninstall hooks.

Code

function feeds_requirements($phase) {
  $t = get_t();
  $requirements = array();
  module_load_include('module', 'feeds');

  // Check if we have any SimplePie importers.
  $needs_simplepie = FALSE;
  foreach (feeds_importer_load_all() as $importer) {
    if ($importer->config['parser']['plugin_key'] === 'FeedsSimplePieParser') {
      $needs_simplepie = TRUE;
      break;
    }
  }
  if (!$needs_simplepie) {
    return $requirements;
  }
  $requirements['simplepie'] = array(
    'title' => $t('SimplePie'),
    'value' => $t('Installed'),
    'description' => $t('The SimplePie library is required for Feeds SimplePie Parser.'),
    'severity' => REQUIREMENT_OK,
  );
  if (!feeds_simplepie_exists()) {
    $requirements['simplepie']['value'] = $t('Not installed');
    $folder = drupal_get_path('module', 'feeds') . '/libraries';
    if (module_exists('libraries')) {
      $folder = 'sites/all/libraries/simplepie';
    }
    $args = array(
      '!url' => 'http://simplepie.org/downloads/',
      '%folder' => $folder,
      '%file' => 'simplepie.compiled.php',
    );
    $requirements['simplepie']['description'] .= $t('<br />Download the compiled, single-file version of the library from the <a href="!url">SimplePie download page</a>, place it into %folder and rename it to %file.', $args);
    $requirements['simplepie']['severity'] = REQUIREMENT_ERROR;
  }
  return $requirements;
}