? SolrPhpClient
Index: Solr_Base_Query.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/Solr_Base_Query.php,v
retrieving revision 1.1.4.40.2.1
diff -u -p -r1.1.4.40.2.1 Solr_Base_Query.php
--- Solr_Base_Query.php	13 Aug 2009 14:58:34 -0000	1.1.4.40.2.1
+++ Solr_Base_Query.php	17 Aug 2009 17:17:34 -0000
@@ -137,8 +137,8 @@ class Solr_Base_Query implements Drupal_
     $this->id = ++self::$idCount;
   }
 
-  public function add_filter($field, $value, $exclude = FALSE) {
-    $this->fields[] = array('#exclude' => $exclude, '#name' => $field, '#value' => trim($value));
+  public function add_filter($field, $value, $exclude = FALSE, $callbacks = array()) {
+    $this->fields[] = array('#exclude' => $exclude, '#name' => $field, '#value' => trim($value), '#callbacks' => $callbacks);
   }
 
   /**
@@ -212,7 +212,7 @@ class Solr_Base_Query implements Drupal_
     // We have to re-parse the filters.
     $this->parse_filters();
   }
-  
+
   /**
    * Set keywords in this query.
    *
@@ -222,7 +222,7 @@ class Solr_Base_Query implements Drupal_
   function set_keys($keys) {
     $this->keys = $keys;
   }
-  
+
   /**
    * Get this query's keywords.
    */
@@ -372,7 +372,9 @@ class Solr_Base_Query implements Drupal_
       }
       $progressive_crumb[] = $this->make_filter($field);
       $options = array('query' => 'filters=' . rawurlencode(implode(' ', $progressive_crumb)));
-      if ($themed = theme("apachesolr_breadcrumb_" . $name, $field['#value'], $field['#exclude'])) {
+      $breadcrumb_name = "apachesolr_breadcrumb_" . $name;
+      drupal_alter('apachesolr_theme_breadcrumb', $breadcrumb_name);
+      if ($themed = theme($breadcrumb_name, $field)) {
         $breadcrumb[] = l($themed, $base, $options);
       }
       else {
Index: apachesolr.index.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.index.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 apachesolr.index.inc
--- apachesolr.index.inc	1 Jul 2009 22:43:50 -0000	1.1.2.6
+++ apachesolr.index.inc	17 Aug 2009 17:17:35 -0000
@@ -117,8 +117,8 @@ function apachesolr_node_to_document($ni
     foreach ($cck_fields as $key => $cck_info) {
       if (isset($node->$key)) {
         // Got a CCK field. See if it is to be indexed.
-        $function = $cck_info['callback'];
-        if ($cck_info['callback'] && function_exists($function)) {
+        $function = $cck_info['indexing callback'];
+        if ($cck_info['indexing callback'] && function_exists($function)) {
           $field = $function($node, $key);
         }
         else {
@@ -128,6 +128,8 @@ function apachesolr_node_to_document($ni
         foreach ($field as $value) {
           // Don't index NULLs or empty strings
           // We can use 'value' rather than 'safe' since we strip tags and later check_plain().
+          // Furthermore, what is being indexed is the KEY for the CCK value. It will need
+          // a trip through content_format() later to display the value.
           if (isset($value['value']) && strlen($value['value'])) {
             if ($cck_info['multiple']) {
               $document->setMultiValue($index_key, apachesolr_clean_text($value['value']));
@@ -234,4 +236,3 @@ function apachesolr_add_tags_to_document
     }
   }
 }
-
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.155.2.11
diff -u -p -r1.1.2.12.2.155.2.11 apachesolr.module
--- apachesolr.module	17 Aug 2009 11:37:10 -0000	1.1.2.12.2.155.2.11
+++ apachesolr.module	17 Aug 2009 17:17:35 -0000
@@ -661,7 +661,7 @@ function apachesolr_facet_block($respons
     $items = array();
     foreach ($response->facet_counts->facet_fields->$facet_field as $facet => $count) {
       $sortpre = 1000000 - $count;
-      $options = array();
+      $options = array('delta' => $delta);
       $exclude = FALSE;
       // Solr sends this back if it's empty.
       if ($facet == '_empty_') {
@@ -1215,8 +1215,14 @@ function apachesolr_cck_fields() {
     if (module_exists('content')) {
       // A single default mapping for all text fields.
       $mappings['text'] = array(
-        'optionwidgets_select' => array('callback' => '', 'index_type' => 'string'),
-        'optionwidgets_buttons' => array('callback' => '', 'index_type' => 'string')
+        'optionwidgets_select' => array('indexing callback' => '',
+          'display callback' => 'apachesolr_cck_text_field_callback',
+          'index_type' => 'string',
+        ),
+        'optionwidgets_buttons' => array('indexing callback' => '',
+          'display callback' => 'apachesolr_cck_text_field_callback',
+          'index_type' => 'string',
+        ),
       );
       // A field-specific mapping would look like:
       // $mappings['per-field']['field_model_name'] = array('callback' => '', 'index_type' => 'string');
@@ -1230,13 +1236,17 @@ function apachesolr_cck_fields() {
         if ((isset($mappings[$row->field_type][$row->widget_type]) ||  isset($mappings['per-field'][$row->field_name]))) {
           if (isset($mappings['per-field'][$row->field_name])) {
             $row->index_type = $mappings['per-field'][$row->field_name]['index_type'];
-            $row->callback = $mappings['per-field'][$row->field_name]['callback'];
+            $row->indexing_callback = $mappings['per-field'][$row->field_name]['indexing callback'];
+            $row->display_callback = $mappings['per-field'][$row->field_name]['display callback'];
           }
           else {
             $row->index_type = $mappings[$row->field_type][$row->widget_type]['index_type'];
-            $row->callback = $mappings[$row->field_type][$row->widget_type]['callback'];
+            $row->indexing_callback = $mappings[$row->field_type][$row->widget_type]['indexing callback'];
+            $row->display_callback = $mappings[$row->field_type][$row->widget_type]['display callback'];
           }
           $row->multiple = (bool) $row->multiple;
+          // It's important that we put the 'cck_' here because several points in the later processing
+          // depend on it to route program flow to cck specific handlers.
           $row->name = 'cck_' . $row->field_name;
           $fields[$row->field_name] = array_merge((array) $fields[$row->field_name], (array) $row);
           $fields[$row->field_name]['content types'][] = $row->content_type;
@@ -1249,6 +1259,24 @@ function apachesolr_cck_fields() {
 }
 
 /**
+ * Use the content.module's content_format() to format the
+ * field based on its value ($facet).
+ *
+ *  @param $facet string
+ *    The indexed value
+ *  @param $options
+ *    An array of options including the hook_block $delta.
+ */
+function apachesolr_cck_text_field_callback($facet, $options) {
+  if (function_exists('content_format')) {
+    return content_format($options['delta'], $facet);
+  }
+  else {
+    return $facet;
+  }
+}
+
+/**
  * Implementation of hook_theme().
  */
 function apachesolr_theme() {
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.111.2.4
diff -u -p -r1.1.2.6.2.111.2.4 apachesolr_search.module
--- apachesolr_search.module	13 Aug 2009 22:06:46 -0000	1.1.2.6.2.111.2.4
+++ apachesolr_search.module	17 Aug 2009 17:17:35 -0000
@@ -713,7 +713,9 @@ function apachesolr_search_block($op = '
                 $new_query = clone $query;
                 $new_query->remove_filter($field['#name'], $field['#value']);
                 $options['query'] = $new_query->get_url_queryvalues();
-                $fielddisplay = theme("apachesolr_breadcrumb_". $field['#name'], $field['#value']);
+                $breadcrumb_name = "apachesolr_breadcrumb_" . $field['#name'];
+                drupal_alter('apachesolr_theme_breadcrumb', $breadcrumb_name);
+                $fielddisplay = theme($breadcrumb_name, $field);
                 if (!$fielddisplay) {
                   $fielddisplay = $field['#value'];
                 }
@@ -740,7 +742,8 @@ function apachesolr_search_block($op = '
             foreach ($fields as $name => $field) {
               if ($field['field_name'] == $delta) {
                 $index_key = apachesolr_index_key($field);
-                return apachesolr_facet_block($response, $query, 'apachesolr_search', $delta, $index_key, t('Filter by @field', array('@field' => $field['label'])));
+                $callback = isset($field['display_callback']) ? $field['display_callback'] : FALSE;
+                return apachesolr_facet_block($response, $query, 'apachesolr_search', $delta, $index_key, t('Filter by @field', array('@field' => $field['label'])), $callback);
               }
             }
           }
@@ -1025,6 +1028,9 @@ function apachesolr_search_theme() {
     'apachesolr_breadcrumb_type' => array(
       'arguments' => array('type' => NULL),
     ),
+    'apachesolr_breadcrumb_cck' => array(
+      'arguments' => array('field' => NULL),
+    ),
     'apachesolr_breadcrumb_changed' => array(
       'arguments' => array('type' => NULL),
     ),
@@ -1043,6 +1049,34 @@ function apachesolr_search_theme() {
   );
 }
 
+/**
+ * Alters the function used to theme breadcrumbs
+ * @param string $fieldname
+ *
+ */
+function apachesolr_search_apachesolr_theme_breadcrumb_alter(&$fieldname) {
+  $matches = preg_split('/_cck_/', $fieldname);
+  if (isset($matches[1])) {
+    $fieldname = 'apachesolr_breadcrumb_cck';
+  }
+}
+
+function theme_apachesolr_breadcrumb_cck($field) {
+  $matches = preg_split('/_cck_/', $field['#name']);
+  if (isset($matches[1])) {
+    $mappings = apachesolr_cck_fields();
+    if (isset($mappings[$matches[1]]['display_callback'])) {
+      $function = $mappings[$matches[1]]['display_callback'];
+      if (function_exists($function)) {
+        $facet = $field['#value'];
+        $options = array('delta' => $matches[1]);
+        return $function($facet, $options);
+      }
+    }
+  }
+  return $field['#value'];
+}
+
 function theme_apachesolr_breadcrumb_date_range($range) {
   if (preg_match('@[\[\{](\S+) TO (\S+)[\]\}]@', $range, $match)) {
     return apachesolr_date_format_range($match[1], $match[2]);
