You are here

function gmap_taxonomy_get_instances in GMap Module 7

Same name and namespace in other branches
  1. 7.2 gmap_taxonomy.module \gmap_taxonomy_get_instances()

Get fields that are using taxonomy_term_reference + gmap taxonomy Helper function to return cached version of fields using taxonomy_term_reference

Return value

Associative array keyed with node type and with values as array of field names.

1 call to gmap_taxonomy_get_instances()
gmap_taxonomy_node_update in ./gmap_taxonomy.module
Implement hook_node_update().

File

./gmap_taxonomy.module, line 252
GMap Taxonomy Markers

Code

function gmap_taxonomy_get_instances() {
  $gmap_taxonomy_fields =& drupal_static(__FUNCTION__);

  // TODO: Could do something with the vid, but probably too much overhead to use it here
  // as field_info_fields() only gives us machine names and gmap_taxonomy_vocabs only gives us vid
  // $gmap_taxonomy_vocabs = variable_get('gmap_taxonomy_vocabs', array());
  if (!isset($gmap_taxonomy_fields)) {
    if ($cache = cache_get('gmap_taxonomy_fields_data')) {
      $gmap_taxonomy_fields = $cache->data;
    }
    else {
      $gmap_taxonomy_fields = array();

      // get all field info
      $fields = field_info_fields();

      // loop through to get the ones of field type taxonomy_term_reference
      foreach ($fields as $field) {
        if ($field['type'] == 'taxonomy_term_reference') {
          foreach ($field['bundles']['node'] as $node_type) {
            $gmap_taxonomy_fields[$node_type][] = $field['field_name'];
          }
        }
      }
      cache_set('gmap_taxonomy_fields_data', $gmap_taxonomy_fields, 'cache', CACHE_TEMPORARY);
    }
  }
  return $gmap_taxonomy_fields;
}