Index: contrib/apachesolr_image/apachesolr_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/contrib/apachesolr_image/apachesolr_image.module,v
retrieving revision 1.1.2.1.2.1
diff -u -p -r1.1.2.1.2.1 apachesolr_image.module
--- contrib/apachesolr_image/apachesolr_image.module	4 May 2008 19:54:02 -0000	1.1.2.1.2.1
+++ contrib/apachesolr_image/apachesolr_image.module	26 Jan 2009 15:52:16 -0000
@@ -1,62 +1,68 @@
 <?php
 // $Id: apachesolr_image.module,v 1.1.2.1.2.1 2008/05/04 19:54:02 drunkenmonkey Exp $
 
+/**
+ * Implementation of hook_apachesolr_update_index().
+ */
 function apachesolr_image_apachesolr_update_index(&$document, $node) {
   if ($node->type == 'image') {
     $areas = array();
+    // A problem here - small images do not get a derived thumbnail.
     $sizes = image_get_derivative_sizes($node->images['_original']);
     foreach ($sizes as $name => $info) {
       $areas[$name] = $info['width'] * $info['height'];
     }
     asort($areas);
-    $image = FALSE;
+    $image_path = FALSE;
     foreach ($areas as $preset => $size) {
-      $image = $node->images[$preset];
+      $image_path = $node->images[$preset];
       break;
     }
-    if ($image) {
-      $index_key = 'ssfield_imagemodule_image';
-      $document->$index_key = $image;
+    if ($image_path) {
+      $document->ssfield_image_relative = $image_path;
+      // TODO - support multi-site too.
+      // $document->ssfield_image_absolute = file_create_url($image_path);
     }
   }
 }
 
 /**
- * Format a single result entry of a search query. This function is normally
- * called by theme_search_page() or hook_search_page().
- *
- * @param $item
- *   A single search result as returned by hook_search(). The result should be
- *   an array with keys "link", "title", "type", "user", "date", and "snippet".
- *   Optionally, "extra" can be an array of extra info to show along with the
- *   result.
- * @param $type
- *   The type of item found, such as "user" or "contentsearch".
- *
- * @ingroup themeable
+ * Implementation of hook_apachesolr_modify_query().
  */
-function phptemplate_search_item($item, $type) {
-  $output = ' <dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>';
-  $info = array();
-  if ($item['type']) {
-    $info[] = check_plain($item['type']);
-  }
-  if ($item['user']) {
-    $info[] = $item['user'];
-  }
-  if ($item['date']) {
-    $info[] = format_date($item['date'], 'small');
-  }
-  if (is_array($item['extra'])) {
-    $info = array_merge($info, $item['extra']);
-  }
-  $break = '';
-  if ($node = $item['node']) {
-    if ($path = $node->ssfield_imagemodule_image) {
-      $item['snippet'] = '<span class="image">'. theme('image', $path, '', '', array('align' => 'left')) .'</span>'. $item['snippet'];
-      $break = '<br clear="all"/>';
+function apachesolr_image_apachesolr_modify_query(&$query, &$params) {
+  // Also retrieve image thumbnail links.
+  $params['fl'] .= ',ssfield_image_relative';
+}
+
+/**
+ * Implementation of hook_apachesolr_process_results().
+ */
+function apachesolr_image_apachesolr_process_results(&$results) {
+  foreach ($results as $index => $item) {
+    if ($item['node']->type == 'image' && !empty($item['node']->ssfield_image_relative)) {
+      $results[$index]['snippet'] = theme('apachesolr_image_snippet', $item);
     }
   }
-  $output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] . $break .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';
-  return $output;
+}
+
+function theme_apachesolr_image_snippet($item){
+ return '<span class="apachesolr-image-result">'. theme('image', $item['node']->ssfield_image_relative, $item['title'], $item['title'], array('align' => 'left')) .'</span>'. $item['snippet'] . '<br clear="all"/>';
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function apachesolr_image_theme() {
+  return array(
+    'apachesolr_image_snippet' => array(
+      'arguments' => array('item' => NULL),
+    ),
+  );
+}
+
+/**
+ * Implementation of hook_enable().
+ */
+function apachesolr_image_enable() {
+  drupal_set_message(t('The ApacheSolr Image integration module will not have any apparent effect until Image type nodes are indexed or re-indexed.'));
 }
