function field_tools_field_references_overview in Field tools 7
Same name and namespace in other branches
- 8 field_tools.admin.inc \field_tools_field_references_overview()
Page callback for the field references overview list.
@todo Make this all singing and dancing with some sort of visual representation of the relationships.
1 string reference to 'field_tools_field_references_overview'
- field_tools_menu in ./
field_tools.module - Implements hook_menu().
File
- ./
field_tools.admin.inc, line 82 - Contains admin callbacks for the Field tools module.
Code
function field_tools_field_references_overview() {
$output = '';
$entity_info = entity_get_info();
$field_types = field_info_field_types();
$fields = field_info_fields();
$rows = array();
foreach ($fields as $field_name => $field) {
// TODO: also deal with taxonomy term ref, product ref.
if (!in_array($field['type'], array(
'entityreference',
'taxonomy_term_reference',
))) {
continue;
}
$row = array();
// Column: field name.
$row[] = l($field_name, 'admin/reports/fields/field/' . $field_name);
// Column: field type.
$row[] = $field_types[$field['type']]['label'];
// Column: field instances.
$row[] = field_tools_field_instances_list($field);
// Column: target entity type.
switch ($field['type']) {
case 'taxonomy_term_reference':
$target_type = 'taxonomy_term';
break;
case 'entityreference':
$target_type = $field['settings']['target_type'];
}
// switch
$row[] = $entity_info[$target_type]['label'];
// Column: target bundles.
switch ($field['type']) {
case 'taxonomy_term_reference':
$vocabulary = $field['settings']['allowed_values'][0]['vocabulary'];
$row[] = l($entity_info['taxonomy_term']['bundles'][$vocabulary]['label'], _field_ui_bundle_admin_path('taxonomy_term', $vocabulary));
break;
case 'entityreference':
switch ($field['settings']['handler']) {
case 'base':
// Base handler: select bundles.
if (empty($field['settings']['handler_settings']['target_bundles'])) {
// Nothing means all bundles.
$row[] = t("All bundles");
}
else {
$target_bundles = $field['settings']['handler_settings']['target_bundles'];
$items = array();
foreach ($target_bundles as $target_bundle) {
$bundle_label = $entity_info[$target_type]['bundles'][$target_bundle]['label'];
$items[$bundle_label] = l($bundle_label, _field_ui_bundle_admin_path($target_type, $target_bundle));
}
ksort($items);
$row[] = theme('item_list', array(
'items' => $items,
));
}
break;
default:
$row[] = "**other handler**";
}
// switch entref handler
break;
}
// switch field type
$rows[] = $row;
}
$header = array(
t('Field name'),
t('Type'),
t('Instances'),
t('Target entity type'),
t('Target bundles'),
);
$output .= theme('table', array(
'rows' => $rows,
'header' => $header,
));
return $output;
}