-
Notifications
You must be signed in to change notification settings - Fork 7
/
field_collection.admin.inc
51 lines (47 loc) · 1.88 KB
/
field_collection.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @file
* Provides the field_collection module admin pages.
*/
/**
* Menu callback; list all field collections on this site.
*/
function field_collections_overview() {
$instances = field_info_instances();
$field_types = field_info_field_types();
$bundles = field_info_bundles();
$header = array(
t('Field name'),
t('Used in'),
array('data' => t('Operations'), 'colspan' => '2'),
);
$rows = array();
foreach ($instances as $entity_type => $type_bundles) {
foreach ($type_bundles as $bundle => $bundle_instances) {
foreach ($bundle_instances as $field_name => $instance) {
$field = field_info_field($field_name);
if ($field['type'] == 'field_collection') {
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
$rows[$field_name]['class'] = $field['locked'] ? array('menu-disabled') : array('');
$rows[$field_name]['data'][0] = $field['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name;
$rows[$field_name]['data'][1][] = l($bundles[$entity_type][$bundle]['label'], $admin_path . '/fields');
}
}
}
}
foreach ($rows as $field_name => $cell) {
$rows[$field_name]['data'][1] = implode(', ', $cell['data'][1]);
$field_name_url_str = strtr($field_name, array('_' => '-'));
$rows[$field_name]['data'][2] = l(t('manage fields'), 'admin/structure/field-collections/' . $field_name_url_str . '/fields');
$rows[$field_name]['data'][3] = l(t('manage display'), 'admin/structure/field-collections/' . $field_name_url_str . '/display');
}
if (empty($rows)) {
$output = t('No field collections have been defined yet. To do so attach a field collection field to any entity.');
}
else {
// Sort rows by field name.
ksort($rows);
$output = theme('table', array('header' => $header, 'rows' => $rows));
}
return $output;
}