geocode_widget_available_fields

geocode/modules/geocode_widget/includes/geocode_widget.admin.inc, line 54

Versions
6
geocode_widget_available_fields($return_type)

▾ 2 functions call geocode_widget_available_fields()

geocode_widget_admin_widget_settings in geocode/modules/geocode_widget/includes/geocode_widget.admin.inc
Implementation of hook_widget_settings().
geocode_widget_admin_widget_settings in geocode/modules/geocode_widget/includes/geocode_widget.admin.inc
Implementation of hook_widget_settings().

Code

<?php
function geocode_widget_available_fields($return_type) {
  static $fields;
  if (!isset($fields)) {
    $content_fields = $fields = array();

    foreach (content_fields() as $cf) {
      $content_fields[$cf['type']][$cf['field_name']] = $cf;
    }

    foreach (geocode_handler_info() as $name => $handler) {

      // Filter out handlers that don't have compatible return types.
      if (!isset($handler['return types'][$return_type])) continue;
      $handler['return types'] = array(
        $return_type => $handler['return types'][$return_type],
      );

      // Add applicable content fields to a list of candidates.
      foreach ($handler['field types'] as $type) {
        if (isset($content_fields[$type])) {
          foreach ($content_fields[$type] as $cf_name => $cf) {
            if (!isset($fields[$cf_name])) {
              $fields[$cf_name] = $cf;
            }
            $fields[$cf_name]['geocode_handlers'][$name] = $handler;
          }
        }
      }
    }

  }
  return $fields;
}
?>