You are here

function eva_field_extra_fields in EVA: Entity Views Attachment 7

Implements hook_field_extra_fields().

File

./eva.module, line 19

Code

function eva_field_extra_fields() {
  $extras = array();
  $views = eva_get_views();
  foreach ($views as $entity => $data) {
    foreach ($data as $view) {
      if (!empty($view['bundles'])) {
        $bundles = $view['bundles'];
      }
      else {
        $entity_info = entity_get_info($entity);
        $bundles = array_keys($entity_info['bundles']);
      }
      foreach ($bundles as $bundle) {
        $context = $view['show_on'];
        $extras[$entity][$bundle][$context][$view['name'] . '_' . $view['display']] = array(
          'label' => empty($view['title']) ? $view['name'] : $view['title'],
          'description' => $view['title'],
          'weight' => 10,
        );

        // Provide a separate extra field for the exposed form if there is any.
        if ($context == 'display' && !empty($view['exposed form']) && !empty($view['exposed form split'])) {
          $extras[$entity][$bundle][$context][$view['name'] . '_' . $view[$context] . '_' . 'form'] = array(
            'label' => (empty($view['title']) ? $view['name'] : $view['title']) . ' (' . t('Exposed form') . ')',
            'description' => t('The exposed filter form of the view.'),
            'weight' => 9,
          );
        }
      }
    }
  }
  return $extras;
}