commit 072a47a94ab687829c03d44472a73c2bd5134758
Author: fago <nuppla@zites.net>
Date:   Tue Mar 1 12:16:57 2011 +0100

    fixed patch

diff --git contrib/search_api_views/includes/row.inc contrib/search_api_views/includes/row.inc
new file mode 100644
index 0000000..325612a
--- /dev/null
+++ contrib/search_api_views/includes/row.inc
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @file
+ * Row style plugin for displaying the results as entities.
+ */
+
+/**
+ * Plugin class for displaying Views results with entity_view.
+ */
+class SearchApiViewsRow extends views_plugin_row {
+
+  /**
+   * The entity type of the entity being displayed.
+   */
+  protected $entity_type;
+
+  public function init(&$view, &$display, $options = NULL) {
+    parent::init($view, $display, $options);
+
+    $index_id = substr($view->base_table, 17);
+    $index = search_api_index_load($index_id);
+    $this->entity_type = $index->entity_type;
+  }
+
+  public function option_definition() {
+    $options = parent::option_definition();
+
+    $options['view_mode'] = array('default' => 'full');
+
+    return $options;
+  }
+
+  public function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    $entity_info = entity_get_info($this->entity_type);
+    $options = array();
+    if (!empty($entity_info['view modes'])) {
+      foreach ($entity_info['view modes'] as $mode => $settings) {
+        $options[$mode] = $settings['label'];
+      }
+    }
+
+    if (count($options) > 1) {
+      $form['view_mode'] = array(
+        '#type' => 'select',
+        '#options' => $options,
+        '#title' => t('View mode'),
+        '#default_value' => $this->options['view_mode'],
+      );
+    }
+    else {
+      $form['view_mode'] = array(
+        '#type' => 'value',
+        '#value' => $options ? key($options) : 'full',
+      );
+    }
+  }
+
+  public function render($result) {
+    $entity = $result['search_api_views_entity'];
+    $content = entity_view($this->entity_type, array(entity_id($this->entity_type, $entity) => $entity), $this->options['view_mode']);
+    return drupal_render($content);
+  }
+
+}
diff --git contrib/search_api_views/search_api_views.info contrib/search_api_views/search_api_views.info
index 7808f6e..1fe0641 100644
--- contrib/search_api_views/search_api_views.info
+++ contrib/search_api_views/search_api_views.info
@@ -23,3 +23,4 @@ files[] = includes/handler_filter_options.inc
 files[] = includes/handler_filter_text.inc
 files[] = includes/handler_sort.inc
 files[] = includes/query.inc
+files[] = includes/row.inc
diff --git contrib/search_api_views/search_api_views.views.inc contrib/search_api_views/search_api_views.views.inc
index 7a719a1..47eedc2 100644
--- contrib/search_api_views/search_api_views.views.inc
+++ contrib/search_api_views/search_api_views.views.inc
@@ -231,13 +231,30 @@ function _search_api_views_add_handlers($field, $wrapper) {
  * Implements hook_views_plugins().
  */
 function search_api_views_views_plugins() {
-  return array(
+  $ret = array(
     'query' => array(
       'search_api_views_query' => array(
         'title' => t('Search API Query'),
         'help' => t('Query will be generated and run using the Search API.'),
-        'handler' => 'SearchApiViewsQuery'
+        'handler' => 'SearchApiViewsQuery',
+      ),
+    ),
+    'row' => array(
+      'search_api_views_row' => array(
+        'title' => t('Entity view'),
+        'help' => t('Displays a single entity in a specific view mode (e.g. teaser).'),
+        'handler' => 'SearchApiViewsRow',
+        'uses fields' => FALSE,
+        'uses options' => TRUE,
+        'type' => 'normal',
+        'base' => array(),
       ),
     ),
   );
+
+  foreach (db_query('SELECT machine_name FROM {search_api_index}')->fetchCol() as $id) {
+    $ret['row']['search_api_views_row']['base'][] = 'search_api_index_' . $id;
+  }
+
+  return $ret;
 }
