Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.141
diff -u -p -r1.1.2.12.2.141 apachesolr.module
--- apachesolr.module	13 May 2009 15:03:23 -0000	1.1.2.12.2.141
+++ apachesolr.module	15 May 2009 18:15:23 -0000
@@ -650,18 +650,16 @@ function apachesolr_facet_block($respons
         // '*' sorts before all numbers.
         $sortpre = '*';
         $new_query->remove_filter($facet_field, $facet);
-
-        $path = $new_query->get_path();
-        $querystring = $new_query->get_url_querystring();
-        $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
+        $options['query'] = $new_query->get_url_querystring();
+        $link = theme('apachesolr_unclick_link', $facet_text, $new_query->get_path(), $options);
       }
       else {
         $new_query->add_filter($facet_field, $facet, $exclude);
-        $path = $new_query->get_path();
-        $querystring = $new_query->get_url_querystring();
+        $options['query'] = $new_query->get_url_querystring();
+        $link = theme('apachesolr_facet_item', $facet_text, $count, $new_query->get_path(), $options, $active, $response->response->numFound);
       }
       if ($count || $active) {
-        $items[$sortpre . '*' . $facet_text] = theme('apachesolr_facet_item', $facet_text, $count, $path, $querystring, $active, $unclick_link, $response->response->numFound, $options);
+        $items[$sortpre . '*' . $facet_text] = $link;
       }
     }
     // Unless a facet is active only display 2 or more.
@@ -687,18 +685,17 @@ function apachesolr_date_facet_block($re
 
   $new_query = clone $query;
   foreach (array_reverse($new_query->get_filters($facet_field)) as $filter) {
+    $options = array();
     // Iteratively remove the date facets.
     $new_query->remove_filter($facet_field, $filter['#value']);
-    $path = $new_query->get_path();
-    $querystring = $new_query->get_url_querystring();
-    $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
     if ($facet_callback && function_exists($facet_callback)) {
-      $facet_text = $facet_callback($filter['#start']);
+      $facet_text = $facet_callback($filter['#start'], $options);
     }
     else {
       $facet_text = apachesolr_date_format_iso_by_gap(apachesolr_date_find_query_gap($filter['#start'], $filter['#end']), $filter['#start']);
     }
-    array_unshift($items, theme('apachesolr_facet_item', $facet_text, 0, $path, $querystring, TRUE, $unclick_link));
+    $options['query'] = $new_query->get_url_querystring();
+    array_unshift($items, theme('apachesolr_unclick_link', $facet_text, $new_query->get_path(), $options));
   }
   // Add links for additional date filters.
   if (!empty($response->facet_counts->facet_dates->$facet_field)) {
@@ -722,22 +719,21 @@ function apachesolr_date_facet_block($re
     $range_end[$prev_facet] = $end;
 
     foreach ($field as $facet => $count) {
+      $options = array();
       // Solr sends this back if it's empty.
       if ($facet == '_empty_' || $count == 0) {
         continue;
       }
       if ($facet_callback && function_exists($facet_callback)) {
-        $facet_text = $facet_callback($facet);
+        $facet_text = $facet_callback($facet, $options);
       }
       else {
         $facet_text = apachesolr_date_format_iso_by_gap(substr($gap, 2), $facet);
       }
       $new_query = clone $query;
       $new_query->add_filter($facet_field, '['. $facet .' TO '. $range_end[$facet] .']');
-      $path = $new_query->get_path();
-      $querystring = $new_query->get_url_querystring();
-
-      $items[] = theme('apachesolr_facet_item', $facet_text, $count, $path, $querystring, FALSE, '', $response->response->numFound);
+      $options['query'] = $new_query->get_url_querystring();
+      $items[] = theme('apachesolr_facet_item', $facet_text, $count, $new_query->get_path(), $options, FALSE, $response->response->numFound);
     }
   }
   if (count($items) > 0) {
@@ -1181,10 +1177,10 @@ function apachesolr_cck_fields() {
 function apachesolr_theme() {
   return array(
     'apachesolr_facet_item' => array(
-      'arguments' => array('name' => NULL, 'count' => NULL, 'path' => NULL, 'querystring' => '', 'active' => FALSE, 'unclick_link' => NULL, 'num_found' => NULL, 'options' => NULL),
+      'arguments' => array('facet_text' => NULL, 'count' => NULL, 'path' => NULL, 'options' => NULL, 'active' => FALSE, 'num_found' => NULL),
     ),
     'apachesolr_unclick_link' => array(
-      'arguments' => array('url' => NULL, 'querystring' => ''),
+      'arguments' => array('facet_text' => NULL, 'path' => NULL, 'options' => NULL),
     ),
     'apachesolr_facet_list' => array(
       'arguments' => array('items' => NULL),
@@ -1304,7 +1300,7 @@ function theme_apachesolr_mlt_recommenda
   return theme('item_list', $links);
 }
 
-function theme_apachesolr_facet_item($name, $count, $path, $querystring = '', $active = FALSE, $unclick_link = NULL, $num_found = NULL, $options = array()) {
+function theme_apachesolr_facet_item($facet_text, $count, $path, $options = array(), $active = FALSE, $num_found = NULL) {
 
   if ($active) {
     if (isset($options['attributes']['class'])) {
@@ -1314,16 +1310,7 @@ function theme_apachesolr_facet_item($na
       $options['attributes']['class'] = 'active';
     }
   }
-  if ($unclick_link) {
-    if (empty($options['html'])) {
-      $name = check_plain($name);
-    }
-    return $unclick_link . ' '. $name;
-  }
-  else {
-    $options['query'] = $querystring;
-    return apachesolr_l($name ." ($count)",  $path, $options);
-  }
+  return apachesolr_l($facet_text ." ($count)",  $path, $options);
 }
 
 /**
@@ -1347,8 +1334,16 @@ function apachesolr_l($text, $path, $opt
 }
 
 
-function theme_apachesolr_unclick_link($path, $querystring = '') {
-  return apachesolr_l("(-)", $path, array('query' => $querystring));
+function theme_apachesolr_unclick_link($facet_text, $path, $options = array()) {
+  $options['query'] = $querystring;
+  if (empty($options['html'])) {
+    $facet_text = check_plain($facet_text);
+  }
+  else {
+    // Don't pass this option as TRUE into apachesolr_l().
+    unset($options['html']);
+  }
+  return apachesolr_l("(-)", $path, $options) . ' '. $facet_text;
 }
 
 function theme_apachesolr_sort_link($text, $path, $querystring = '', $active = FALSE, $direction = '') {
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.92
diff -u -p -r1.1.2.6.2.92 apachesolr_search.module
--- apachesolr_search.module	14 May 2009 23:10:19 -0000	1.1.2.6.2.92
+++ apachesolr_search.module	15 May 2009 18:15:23 -0000
@@ -468,6 +468,7 @@ function apachesolr_search_block($op = '
             $terms = array();
 
             foreach ($response->facet_counts->facet_fields->$delta as $tid => $count) {
+              $options = array();
               if ($tid == '_empty_') {
                 // TODO - for now we don't handle facet missing.
                 continue;
@@ -479,19 +480,18 @@ function apachesolr_search_block($op = '
               if ($active = $query->has_filter('tid', $tid)) {
                 $contains_active = TRUE;
                 $new_query->remove_filter('tid', $term->tid);
-                $path = $new_query->get_path();
-                $querystring = $new_query->get_url_querystring();
-                $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
+                $options['query'] = $new_query->get_url_querystring();
+                $link = theme('apachesolr_unclick_link', $term->name, $new_query->get_path(), $options);
               }
               else {
                 $new_query->add_filter('tid', $term->tid);
-                $path = $new_query->get_path();
-                $querystring = $new_query->get_url_querystring();
+                $options['query'] = $new_query->get_url_querystring();
+                $link = theme('apachesolr_facet_item', $term->name, $count, $new_query->get_path(), $options, $active, $response->response->numFound);
               }
               $countsort = $count == 0 ? '' : 1 / $count;
               // if numdocs == 1 and !active, don't add.
               if ($response->response->numFound > 1 || $active) {
-                $terms[$term->vid][$active ? $countsort . $term->name : 1 + $countsort . $term->name] = theme('apachesolr_facet_item', $term->name, $count, $path, $querystring, $active, $unclick_link, $response->response->numFound);
+                $terms[$term->vid][$active ? $countsort . $term->name : 1 + $countsort . $term->name] = $link;
               }
             }
           }
@@ -521,13 +521,12 @@ function apachesolr_search_block($op = '
               if ($field['#name']) {
                 $new_query = clone $query;
                 $new_query->remove_filter($field['#name'], $field['#value']);
-                $path = $new_query->get_path();
-                $querystring = $new_query->get_url_querystring();
-                $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
-                if (! $fielddisplay = theme("apachesolr_breadcrumb_". $field['#name'], $field['#value'])) {
+                $options['query'] = $new_query->get_url_querystring();
+                $fielddisplay = theme("apachesolr_breadcrumb_". $field['#name'], $field['#value']);
+                if (!$fielddisplay) {
                   $fielddisplay = $field['#value'];
                 }
-                $links[] = theme('apachesolr_facet_item', $fielddisplay, NULL, $path, $querystring, $active, $unclick_link, $response->response->numFound);
+                $links[] = theme('apachesolr_unclick_link', $fielddisplay, $new_query->get_path(), $querystring);
               }
             }
             $content = theme('apachesolr_currentsearch', $response->response->numFound, $links);
