You are here

function _better_statistics_include_handlers in Better Statistics 7

Loads all inc files declared using the Statistics API.

This is almost identical to ctools_plugin_api_include(), but modified a bit to return file inclusion data.

Return value

An array containing the API information, including the actual files that each module declares.

2 calls to _better_statistics_include_handlers()
_better_statistics_get_custom_fields_by_module in ./better_statistics.admin.inc
Returns arrays of fields keyed by the module that declares them. In addition, this function will attempt to apply sensible views handlers. This should be the only function used to get declared fields.
_better_statistics_update_fields in ./better_statistics.admin.inc
Determines whether or not accesslog fields should be altered, and if so, performs any necessary database alterations and re-saves the declared fields to the active store variable.

File

./better_statistics.admin.inc, line 670
Admin and config code for the Better Statistics module.

Code

function _better_statistics_include_handlers($reset = FALSE) {
  static $finished = FALSE;

  // Ensure this only runs once.
  if ($finished && !$reset) {
    return $finished;
  }

  // Check for ctools; this dependency was added after the initial relase.
  if (!module_exists('ctools')) {
    drupal_set_message(t('Better Statistics requires the ctools module. Please install and enable ctools.'), 'warning');
    return array();
  }
  ctools_include('plugins');
  $info = ctools_plugin_api_info('better_statistics', 'statistics', BETTER_STATISTICS_API_MIN_VERSION, BETTER_STATISTICS_API_VERSION);
  foreach ($info as $module => &$plugin_info) {
    if (!isset($already_done['better_statistics']['statistics'][$module])) {
      if (isset($plugin_info['statistics file'])) {
        $file = $plugin_info['statistics file'];
      }
      elseif (isset($plugin_info['file'])) {
        $file = $plugin_info['file'];
      }
      else {
        $file = "{$module}.statistics.inc";
      }
      if (file_exists(DRUPAL_ROOT . "/{$plugin_info['path']}/{$file}")) {
        require_once DRUPAL_ROOT . "/{$plugin_info['path']}/{$file}";
        $plugin_info['file_required'] = "{$plugin_info['path']}/{$file}";
      }
      elseif (file_exists(DRUPAL_ROOT . "/{$file}")) {
        require_once DRUPAL_ROOT . "/{$file}";
        $plugin_info['file_required'] = "{$file}";
      }
      $already_done['better_statistics']['statistics'][$module] = TRUE;
    }
  }
  $finished = $info;
  return $finished;
}