You are here

function ctools_entity_field_content_type_content_types in Chaos Tool Suite (ctools) 7

Return all field content types available.

1 call to ctools_entity_field_content_type_content_types()
ctools_entity_field_content_type_content_type in plugins/content_types/entity_context/entity_field.inc
Just one subtype.
1 string reference to 'ctools_entity_field_content_type_content_types'
ctools_flush_field_caches in ./ctools.module
Clear field related caches.

File

plugins/content_types/entity_context/entity_field.inc, line 31

Code

function ctools_entity_field_content_type_content_types() {
  $types =& drupal_static(__FUNCTION__, array());
  if (!empty($types)) {
    return $types;
  }
  $cache_key = 'ctools_entity_field_content_type_content_types';
  if ($cache = cache_get($cache_key)) {
    $types = $cache->data;
    if (!empty($types)) {
      return $types;
    }
  }

  // This will hold all the individual field content types.
  $context_types = array();
  $entities = entity_get_info();
  $description = t('Field on the referenced entity.');
  $styles = t('Formatter Styles');
  $categories = array();
  foreach ($entities as $entity_type => $entity) {
    $category = t(ucfirst($entity_type));
    $categories[$entity_type] = $category;
    foreach ($entity['bundles'] as $type => $bundle) {
      foreach (field_info_instances($entity_type, $type) as $field_name => $field) {
        if (!isset($types[$entity_type . ':' . $field_name])) {
          $label = t($field['label']);
          $types[$entity_type . ':' . $field_name] = array(
            'category' => $category,
            'icon' => 'icon_field.png',
            'title' => t('Field: @widget_label (@field_name)', array(
              '@widget_label' => $label,
              '@field_name' => $field_name,
            )),
            'description' => $description,
            'edit form' => array(
              'ctools_entity_field_content_type_formatter_options' => array(
                'default' => TRUE,
                'title' => t('Formatter options for: @widget_label (@field_name)', array(
                  '@widget_label' => $label,
                  '@field_name' => $field_name,
                )),
              ),
              'ctools_entity_field_content_type_formatter_styles' => $styles,
            ),
          );
        }
        $context_types[$entity_type . ':' . $field_name]['types'][$type] = $bundle['label'];
      }
    }
  }

  // Create the required context for each field related to the bundle types.
  foreach ($types as $key => $field_content_type) {
    list($entity_type, $field_name) = explode(':', $key, 2);
    $types[$key]['required context'] = new ctools_context_required($categories[$entity_type], $entity_type, array(
      'type' => array_keys($context_types[$key]['types']),
    ));
    unset($context_types[$key]['types']);
  }
  cache_set($cache_key, $types);
  return $types;
}