You are here

function colorized_gmap_requirements in Colorized google maps block 7

Implements hook_requirements().

File

./colorized_gmap.install, line 11
Contains requirements and uninstall functions for colorized_gmap.

Code

function colorized_gmap_requirements($phase) {
  $requirements = array();
  if ($phase == 'install') {
    if (!function_exists('libraries_get_path')) {
      module_load_include('module', 'libraries');
    }
    $path = libraries_get_path('colorpicker') ? libraries_get_path('colorpicker') : 'sites/all/libraries/colorpicker';
    if (!is_file($path . '/js/colorpicker.js')) {
      $t = get_t();
      $link = l('http://www.eyecon.ro/colorpicker', 'http://www.eyecon.ro/colorpicker', array(
        'absolute' => TRUE,
        'attributes' => array(
          'target' => '_blank',
        ),
      ));
      $description = $t('<h2>Colorized_Gmap is not installed</h2><br /> Missing dependency detected. Please download the colorpicker.zip from !link and unzip the CSS, JS and IMAGES folders to <strong>!path</strong>.<br />Your colorpicker.js file should be in the following folder: <strong>!path/js/colorpicker.js</strong>.', array(
        '!link' => $link,
        '!path' => $path,
      ));
      $requirements['colorized_gmap_missing_files'] = array(
        'title' => 'Required files missing',
        'description' => $description,
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  if ($phase == 'runtime') {
    $colorized_gmap_api_key = variable_get('colorized_gmap_api_key', '');
    if (empty($colorized_gmap_api_key)) {
      $t = get_t();
      $description = $t('Google maps are no longer working without !info. Please visit !get-key page to get API key and follow further instructions. After that, please enter your api key on !settings-page.', array(
        '!info' => l("api key", "http://googlegeodevelopers.blogspot.ru/2016/06/building-for-scale-updates-to-google.html", array(
          'external' => TRUE,
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
        '!get-key' => l('this', 'https://developers.google.com/maps/documentation/javascript/get-api-key', array(
          'external' => TRUE,
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
        '!settings-page' => l('module settings page', '/admin/config/content/colorized_gmap'),
      ));
      $requirements['colorized_gmap_api_key'] = array(
        'title' => 'Google maps API key is missing',
        'value' => '',
        'description' => $description,
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}