geocode_geocode_handler_info

geocode/geocode.module, line 53

Versions
6
geocode_geocode_handler_info()

Implementation of our own hook_geocode_handler_info().

Code

<?php
function geocode_geocode_handler_info() {
  $handlers = array();

  // A default geocoding handler.
  $handlers['geocode_google'] = array(
    'title' => t('Google API'),
    'callback' => 'geocode_handler_google',
    'module' => 'geocode',
    'file' => 'geocode.inc',
    'file path' => drupal_get_path('module', 'geocode') .'/includes',
    'field types' => array('postal_field', 'postal', 'text'),
    'return types' => array(
      'geo' => array('point'),
      'postal' => array('postal'),
      'text' => array('country', 'city', 'state', 'zip'),
    ),
  );

  // Based on availablilty, include handlers that leverage installed modules.
  // This is for some out-of-the-box interoperability, but should be supplanted
  // by modules implementing hook_geocode_hander_info() on their own.
  $dir = drupal_get_path('module', 'geocode') . '/includes/modules/';
  foreach (file_scan_directory($dir, '\.inc$') as $file) {
    if (module_exists($module = $file->name)) {
      $func = $module . '_geocode_handler_info';

      // Call hook_geocode_handler_info() if the module doesn't account for it.
      if (!function_exists($func) && !function_exists($func .'_alter')) {
        require $dir . $module .'.inc';
        $handlers = array_merge($handlers, $func());
      }
    }
  }

  return $handlers;
}
?>