function field_tools_field_instances_list in Field tools 8
Same name and namespace in other branches
- 7 field_tools.admin.inc \field_tools_field_instances_list()
Helper to format a nested list of field instances, grouped by entity type.
@todo: make this a theme function?
Parameters
$field: A field definition array.
Return value
A nested list of entities and bundles that this field has instances on.
3 calls to field_tools_field_instances_list()
- field_tools_field_edit_form in ./
field_tools.admin.inc - Form to edit all instances of a field.
- field_tools_field_overview in ./
field_tools.admin.inc - Page callback for the field overview list.
- field_tools_field_references_overview in ./
field_tools.admin.inc - Page callback for the field references overview list.
File
- ./
field_tools.admin.inc, line 993 - NOTICE: THIS FILE IS OBSOLETE. IT IS BEING KEPT UNTIL ALL FUNCTIONALITY IS PORTED TO DRUPAL 8.
Code
function field_tools_field_instances_list($field) {
$entity_info = entity_get_info();
$items_entities = array();
foreach ($field['bundles'] as $entity_type => $field_bundle_names) {
// Fields may exist for entities that no longer do.
if (!isset($entity_info[$entity_type])) {
continue;
}
$items_bundles = array();
foreach ($field_bundle_names as $bundle) {
if (!isset($entity_info[$entity_type]['bundles'][$bundle])) {
continue;
}
// @todo: sort these.
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
$bundle_label = $entity_info[$entity_type]['bundles'][$bundle]['label'];
$items_bundles[$bundle_label] = $admin_path ? l($bundle_label, $admin_path . '/fields/' . $field['field_name']) : $bundle_label;
}
ksort($items_bundles);
$entity_label = $entity_info[$entity_type]['label'];
$items_entities[$entity_label] = $entity_label . theme('item_list', array(
'items' => $items_bundles,
));
}
ksort($items_entities);
return theme('item_list', array(
'items' => $items_entities,
));
}