Projet

Général

Profil

Paste
Télécharger (1,87 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / field_collection / field_collection.admin.inc @ 31a5a6d6

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides the field_collection module admin pages.
6
 */
7

    
8
/**
9
 * Menu callback; list all field collections on this site.
10
 */
11
function field_collections_overview() {
12
  $instances = field_info_instances();
13
  $field_types = field_info_field_types();
14
  $bundles = field_info_bundles();
15
  $header = array(t('Field name'), t('Used in'), array('data' => t('Operations'), 'colspan' => '2'));
16
  $rows = array();
17
  foreach ($instances as $entity_type => $type_bundles) {
18
    foreach ($type_bundles as $bundle => $bundle_instances) {
19
      foreach ($bundle_instances as $field_name => $instance) {
20
        $field = field_info_field($field_name);
21
        if ($field['type'] == 'field_collection') {
22
          $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
23
          $rows[$field_name]['class'] = $field['locked'] ? array('menu-disabled') : array('');
24

    
25
          $rows[$field_name]['data'][0] = $field['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name;
26
          $rows[$field_name]['data'][1][] = l($bundles[$entity_type][$bundle]['label'], $admin_path . '/fields');
27
        }
28
      }
29
    }
30
  }
31
  foreach ($rows as $field_name => $cell) {
32
    $rows[$field_name]['data'][1] = implode(', ', $cell['data'][1]);
33

    
34
    $field_name_url_str = strtr($field_name, array('_' => '-'));
35
    $rows[$field_name]['data'][2] = l(t('manage fields'), 'admin/structure/field-collections/' . $field_name_url_str . '/fields');
36
    $rows[$field_name]['data'][3] = l(t('manage display'), 'admin/structure/field-collections/' . $field_name_url_str . '/display');
37
  }
38
  if (empty($rows)) {
39
    $output = t('No field collections have been defined yet. To do so attach a field collection field to any entity.');
40
  }
41
  else {
42
    // Sort rows by field name.
43
    ksort($rows);
44
    $output = theme('table', array('header' => $header, 'rows' => $rows));
45
  }
46
  return $output;
47
}