commit 66dda5a2b9f4b922e8158904dc18a14db093119f
Author: fago <nuppla@zites.net>
Date:   Wed Jun 1 18:33:43 2011 +0200

    views integration

diff --git a/field_collection.module b/field_collection.module
index 055ef0a..643689e 100644
--- a/field_collection.module
+++ b/field_collection.module
@@ -745,6 +745,16 @@ function field_collection_field_delete_field($field) {
 }
 
 /**
+ * Implements hook_views_api().
+ */
+function field_collection_views_api() {
+  return array(
+    'api' => '3.0-alpha1',
+    'path' => drupal_get_path('module', 'field_collection') . '/views',
+  );
+}
+
+/**
  * Implements hook_features_pipe_component_alter() for fields.
  */
 function field_collection_features_pipe_field_alter(&$pipe, $data, $export) {
diff --git a/views/field_collection.views.inc b/views/field_collection.views.inc
new file mode 100644
index 0000000..a361061
--- /dev/null
+++ b/views/field_collection.views.inc
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Implements hook_field_views_data().
+ *
+ * Views integration for field-collection fields. Adds a relationship to the
+ * default field data.
+ *
+ * @see field_views_field_default_views_data()
+ */
+function field_collection_field_views_data($field) {
+  $data = field_views_field_default_views_data($field);
+
+  foreach ($data as $table_name => $table_data) {
+    foreach ($table_data as $field_name => $field_data) {
+      // Only operate on the "field_api_field_name"_value column.
+      if (strrpos($field_name, '_value') === (strlen($field_name) - strlen('_value'))) {
+        $data[$table_name][$field_name]['relationship'] = array(
+          'handler' => 'views_handler_relationship',
+          'base' => 'field_collection_item',
+          'base field' => 'item_id',
+          'label' => t('field-collection item from !field_name', array('!field_name' => $field['field_name'])),
+        );
+      }
+    }
+  }
+  return $data;
+}
