You are here

blockreference.install in Block reference 7

Same filename and directory in other branches
  1. 6 blockreference.install
  2. 7.2 blockreference.install

Block reference install file.

File

blockreference.install
View source
<?php

/**
 * @file
 * Block reference install file.
 */

/**
 * Implements hook_requirements().
 */
function blockreference_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();
  $drupal_version = '7.14';
  if (version_compare(VERSION, $drupal_version) < 0) {
    $requirements['drupal'] = array(
      'title' => $t('Drupal'),
      'value' => VERSION,
      'description' => $t('Your Drupal installation is too old. Block reference requires at least Drupal %version.', array(
        '%version' => $drupal_version,
      )),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  if ($phase == 'runtime') {
    module_load_include('inc', 'field', 'field.info');
    module_load_include('inc', 'field', 'field.crud');
    $has_select_sort = FALSE;
    $instances = field_info_instances();
    foreach ($instances as $entity_type) {
      foreach ($entity_type as $bundle) {
        foreach ($bundle as $instance) {
          if ($instance['widget']['type'] == 'blockreference_select_sort') {
            $has_select_sort = TRUE;
            break 3;
          }
        }
      }
    }
    if ($has_select_sort) {
      $requirements['blockreference'] = array(
        'title' => $t('Block reference'),
        'description' => $t('Block reference select lists (with drag-and-drop sort) are deprecated.  Please use the <a href="!field_collection">Field collection</a> module.', array(
          '!field_collection' => 'http://www.drupal.org/project/field_collection',
        )),
        'severity' => REQUIREMENT_WARNING,
        'value' => '',
      );
    }
  }
  return $requirements;
}

Functions