You are here

function charts_graphs_requirements in Charts and Graphs 6.2

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

Implementation of hook_requirements().

File

./charts_graphs.install, line 20
Install file for Charts and Graphs module.

Code

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

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {
    if (count(charts_graphs_apis()) == 0) {
      $requirements['charts_graphs_submodule'] = array(
        'title' => $t('Charts and Graphs charting library'),
        'description' => $t('Charts and Graphs requires at least one charting
          library enabled. Please go to !modules_page and enable at least one
          charting library.', array(
          '!modules_page' => l(t('modules list page'), 'admin/build/modules/list'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('None enabled'),
      );
    }
    $path = dirname(realpath(__FILE__)) . '/';
    $file = $path . 'apis/charts_google_charts';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_google_charts'] = array(
        'title' => $t('Google Charts at old path'),
        'description' => $t("You have Google Charts for Charts and Graphs\n          available at it's old path: %old_path. Please remove it.", array(
          '%old_path' => $file,
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    $file = $path . 'apis/amcharts';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_amcharts'] = array(
        'title' => $t('amCharts at old path'),
        'description' => $t("You have amCharts for Charts and Graphs\n          available at it's old path: %old_path. Please remove it. Remember to\n          copy the downloaded files from the old %downloaded_path path to the\n          new one", array(
          '%old_path' => $file,
          '%downloaded_path' => $file . '/downloaded/',
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    $file = $path . 'apis/charts_openflash';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_openflash'] = array(
        'title' => $t('Open Flash Chart 2 at old path'),
        'description' => $t("You have Open Flash Chart 2 for Charts and Graphs\n          available at it's old path: %old_path. Please remove it.", array(
          '%old_path' => $file,
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    $file = $path . 'apis/charts_bluff';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_bluff'] = array(
        'title' => $t('Bluff at old path'),
        'description' => $t("You have Bluff for Charts and Graphs\n          available at it's old path: %old_path. Please remove it. Remember to\n          copy the downloaded files from the old %downloaded_path path to the\n          new one", array(
          '%old_path' => $file,
          '%downloaded_path' => $file . '/bluff/',
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    if (variable_get('charts_graphs_check_chart_api', 1) && module_exists('chart')) {
      $requirements['charts_graphs_check_chart_api'] = array(
        'title' => $t('Chart API'),
        'description' => $t("You have both !charts_graphs and !chart_api\n          installed. Unless you have different modules that require both the\n          Charts and Graphs module and the Chart API module one of them\n          should be uninstalled. A common module that requires Charts and\n          Graphs is the Views Charts module so if you use the later, you need\n          the first. If you don't want this warning to be shown any more, please\n          set the proper option at !charts_graphs_settings_page.", array(
          '!charts_graphs' => l(t('Charts and Graphs'), 'http://drupal.org/project/charts_graphs'),
          '!chart_api' => l(t('Chart API'), 'http://drupal.org/project/chart'),
          '!charts_graphs_settings_page' => l(t('Charts and Graphs settings page'), 'admin/settings/charts_graphs'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Enabled'),
      );
    }
    if (variable_get('charts_graphs_check_charts', 1) && module_exists('charts')) {
      $requirements['charts_graphs_check_charts'] = array(
        'title' => $t('Charts'),
        'description' => $t("You have both !charts_graphs and !charts\n          installed. Unless you have different modules that require both the\n          Charts and Graphs module and the Charts module one of them\n          should be uninstalled. A common module that requires Charts and\n          Graphs is the Views Charts module so if you use the later, you need\n          the first. If you don't want this warning to be shown any more, please\n          set the proper option at !charts_graphs_settings_page.", array(
          '!charts_graphs' => l(t('Charts and Graphs'), 'http://drupal.org/project/charts_graphs'),
          '!charts' => l(t('Charts'), 'http://drupal.org/project/charts'),
          '!charts_graphs_settings_page' => l(t('Charts and Graphs settings page'), 'admin/settings/charts_graphs'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Enabled'),
      );
    }
  }
  return $requirements;
}