function field_views_field_label

cis7 field.views.inc field_views_field_label($field_name)
cle7 field.views.inc field_views_field_label($field_name)
elmsmedia7 field.views.inc field_views_field_label($field_name)
icor7 field.views.inc field_views_field_label($field_name)
meedjum_blog7 field.views.inc field_views_field_label($field_name)
mooc7 field.views.inc field_views_field_label($field_name)

Returns the label of a certain field.

Therefore it looks up in all bundles to find the most used instance.

6 calls to field_views_field_label()
date_views_field_views_data_alter in sites/all/modules/ulmus/date/date_views/date_views.module
Implements hook_field_views_data_alter().
field_collection_field_views_data in sites/all/modules/ulmus/field_collection/views/field_collection.views.inc
Implements hook_field_views_data().
field_views_field_default_views_data in sites/all/modules/ulmus/views/modules/field.views.inc
Default views data implementation for a field.
file_field_views_data_views_data_alter in sites/all/modules/ulmus/views/modules/file.views.inc
Implements hook_field_views_data_views_data_alter().
image_field_views_data_views_data_alter in sites/all/modules/ulmus/views/modules/image.views.inc
Implements hook_field_views_data_views_data_alter().

... See full list

File

sites/all/modules/ulmus/views/modules/field.views.inc, line 65
Provide Views data and handlers for field.module.

Code

function field_views_field_label($field_name) {
  $label_counter = array();
  $all_labels = array();
  // Count the amount of instances per label per field.
  $instances = field_info_instances();
  foreach ($instances as $entity_name => $entity_type) {
    foreach ($entity_type as $bundle) {
      if (isset($bundle[$field_name])) {
        $label_counter[$bundle[$field_name]['label']] = isset($label_counter[$bundle[$field_name]['label']]) ? ++$label_counter[$bundle[$field_name]['label']] : 1;
        $all_labels[$entity_name][$bundle[$field_name]['label']] = TRUE;
      }
    }
  }
  if (empty($label_counter)) {
    return array($field_name, $all_labels);
  }
  // Sort the field lables by it most used label and return the most used one.
  arsort($label_counter);
  $label_counter = array_keys($label_counter);
  return array($label_counter[0], $all_labels);
}