Index: apachesolr.admin.inc
===================================================================
RCS file: apachesolr.admin.inc
diff -N apachesolr.admin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ apachesolr.admin.inc	26 Jan 2009 22:23:40 -0000
@@ -0,0 +1,276 @@
+<?php
+// $Id: apachesolr.module,v 1.1.2.12.2.92 2009/01/26 14:19:28 pwolanin Exp $
+
+/**
+ * @file
+ *   Administrative pages for the Apache Solr framework.
+ */
+
+function apachesolr_settings() {
+  $form = array();
+
+  //perform a check to ensure the server is there
+  $requirements = apachesolr_requirements('runtime');
+  $status = $requirements['apachesolr']['severity'] == 2 ? 'error' : 'status';
+  drupal_set_message($requirements['apachesolr']['value'], $status);
+
+  $form['apachesolr_host'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Solr host name'),
+    '#default_value' => variable_get('apachesolr_host', 'localhost'),
+    '#description' => t('Host name of your Solr server, e.g. <code>localhost</code> or <code>example.com</code>.'),
+  );
+  $form['apachesolr_port'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Solr port'),
+    '#default_value' => variable_get('apachesolr_port', '8983'),
+    '#description' => t('Port on which the Solr server listens. The Jetty example server is 8983, while Tomcat is 8080 by default.'),
+  );
+  $form['apachesolr_path'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Solr path'),
+    '#default_value' => variable_get('apachesolr_path', '/solr'),
+    '#description' => t('Path that identifies the Solr request handler to be used.'),
+  );
+
+  $numbers = drupal_map_assoc(array(10, 20, 50, 100));
+  $form['apachesolr_cron_limit'] = array(
+    '#type' => 'select',
+    '#title' => t('Number of items to index per cron run'),
+    '#default_value' => variable_get('apachesolr_cron_limit', 50),
+    '#options' => $numbers,
+    '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))
+  );
+
+  $options = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100));
+  $form['apachesolr_rows'] = array(
+    '#type' => 'select',
+    '#title' => t('Results per page'),
+    '#default_value' => variable_get('apachesolr_rows', 10),
+    '#options' => $options,
+    '#description' => t('The number of results that will be shown per page.'),
+  );
+  $form['apachesolr_failure'] = array(
+    '#type' => 'select',
+    '#title' => t('On failure'),
+    '#options' => array('show_error' => t('Show error'),
+      'show_drupal_results' => t('Show core Drupal results'),
+      'show_no_results' => t('Show no results')
+    ),
+    '#default_value' => variable_get('apachesolr_failure', 'show_error'),
+    '#description' => t('What to display if ApacheSolr search is not available.'),
+  );
+  return system_settings_form($form);
+}
+
+/**
+ * Gets information about the fields already in solr index.
+ */
+function apachesolr_index_page() {
+  try {
+    $solr = apachesolr_get_solr();
+    // TODO: only clear this every page view if we are running
+    // multi-site.
+    $solr->clearCache();
+    // Note: we use 2 since 1 fails on Ubuntu Hardy.
+    $data = $solr->getLuke(2);
+  }
+  catch (Exception $e) {
+    watchdog('apachesolr', $e->getMessage());
+    drupal_set_message($e->getMessage(), "warning");
+    $data->fields = array();
+  }
+
+  $output  = '';
+  if (isset($data->index->numDocs)) {
+    $output .= '<p>' . t('Number of documents in index: @num', array('@num' => $data->index->numDocs)) . "</p>\n";
+    $output .= '<p>' . t('Number of terms in index: @num', array('@num' => $data->index->numTerms)) . "</p>\n";
+  }
+
+  $fields = (array)$data->fields;
+  if ($fields) {
+    $output .= '<p>' . t('Number of fields in index: @num', array('@num' => count($fields))) . "</p>\n";
+    $rows = array();
+    foreach ($fields as $name => $field) {
+      // TODO: try to map the name to something more meaningful.
+      $rows[$name] = array($name, $field->type, isset($field->index) ? $field->distinct : t('Not indexed'));
+    }
+    ksort($rows);
+    // Display the table of Field names, Index Types, and term counts.
+    $output .= theme('table', array(t('Field name'), t('Index type'), t('Distinct terms')), $rows);
+  }
+  else {
+    $output .= '<p>' . t('No data on indexed fields.') . "</p>\n";
+  }
+
+  // Display the Delete Index form.
+  $output .= drupal_get_form('apachesolr_delete_index_form');
+
+  return $output;
+}
+
+/**
+ * Indicates what order the specified facets should be listed in.  This function is used in a usort
+ * invocation.
+ * @param $a
+ *   The first facet.
+ * @param $b
+ *   The second facet.
+ * @return
+ *   A signed integer that indicates which of the specified facets should come first.
+ */
+function _apachesolr_sort_facets($a, $b) {
+  return strcasecmp($a['info'], $b['info']);
+}
+
+/**
+ * This is the submit handler for the active facets form.
+ *
+ * The form values for each module are array filtereed to remove non-enabled items and
+ * stored in the variable table with the name 'apachesolr_enabled_facets'.
+ *
+ * @see apachesolr_enabled_facets_form()
+ */
+function apachesolr_enabled_facets_form_submit($form, &$form_state) {
+  $enabled = array();
+  foreach ($form_state['values']['apachesolr_enabled_facets'] as $module => $facets) {
+    $enabled[$module] = array_filter($facets);
+  }
+  variable_set('apachesolr_enabled_facets', $enabled);
+  drupal_set_message('For each filter block you chose to create, you should see a block below prefixed with "ApacheSolr". Drag these blocks into the region where you would like them to show up on the search page.');
+}
+
+/**
+ * Creates the form that allows the user to select which facets will be enabled.
+ *
+ * Only enabled facets are sent to solr.  Fewer enabled facets can reduce the
+ * load on the search server.  Blocks are only offered for enabled facets, so
+ * this also reduces the clutter on the blocks admin page.
+ */
+function apachesolr_enabled_facets_form() {
+  $facets = array();
+  foreach (module_implements('apachesolr_facets') as $module) {
+    $module_facets[$module] = module_invoke($module, 'apachesolr_facets');
+    uasort($module_facets[$module], '_apachesolr_sort_facets');
+  }
+
+  $enabled_facets = apachesolr_get_enabled_facets();
+  $form = array();
+  $form['apachesolr_enabled_facets']['help'] = array (
+    '#type' => 'item',
+    '#value' => t('You can use this screen to select which ApacheSolr filter blocks should be created by enabling the corresponding Apache Solr filters. For performance reasons, you should only enable filters that you intend to have available to users on the search page.  After selecting which filter blocks to create, you will be sent to the blocks page where you can choose which of those blocks should be enabled when your users search by placing each block in a region.'),
+  );
+
+  foreach($module_facets as $module => $facets) {
+    $form['apachesolr_enabled_facets'][$module] = array(
+      '#type' => 'fieldset',
+      // TODO: wrong.
+      '#title' => $module,
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+    );
+    // We must use module + delta as the keys since that combination is
+    // guaranteed to be unique.  A single module could, for example, have
+    // two different blocks that expose different faceting on the same
+    // field in the index.
+    foreach($facets as $delta => $data) {
+      $form['apachesolr_enabled_facets'][$module][$delta] = array(
+        '#type' => 'checkbox',
+        '#title' => $data['info'],
+        '#return_value' => $data['facet_field'],
+        '#default_value' => isset($enabled_facets[$module][$delta]) ? $data['facet_field'] : 0,
+      );
+    }
+  }
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+
+  $form['#tree'] = TRUE;
+  $form['#redirect'] = '/admin/build/block';
+
+  return $form;
+}
+
+/**
+ * Create a form for deleting the contents of the Solr index.
+ */
+function apachesolr_delete_index_form() {
+  $form = array();
+  $form['markup'] = array(
+    '#prefix' => '<h3>',
+    '#value' => t('Solr Index'),
+    '#suffix' => '</h3>',
+  );
+  $form['reindex'] = array(
+    '#type' => 'submit',
+    '#value' => t('Re-index all content'),
+    '#submit' => array('apachesolr_clear_index'),
+  );
+  $form['reindex-desc'] = array(
+    '#type' => 'item',
+    '#description' => t('Re-indexing will add all content to the index again (overwriting the index), but existing content in the index will remain searchable.'),
+  );
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Delete the index'),
+    '#validate' => array('apachesolr_delete_index_validate'),
+    '#submit' => array('apachesolr_delete_index'),
+  );
+  $form['delete_index'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Confirm index deletion'),
+    '#description' => t('Deletes all of the documents in the Solr index. This is rarely necessary unless your index is corrupt or you have installed a new schema.xml.'),
+    '#default_value' => NULL,
+  );
+  return $form;
+}
+
+/**
+ * Submit function for the 'Re-index all content' button.
+ *
+ * @see apachesolr_delete_index_form()
+ */
+function apachesolr_clear_index($form, &$form_state) {
+  apachesolr_clear_last_index();
+}
+
+/**
+ * Validate function for the 'Delete the index' button.
+ *
+ * @see apachesolr_delete_index_form()
+ */
+function apachesolr_delete_index_validate($form, &$form_state) {
+  if (!$form_state['values']['delete_index']) {
+    form_set_error('delete_index', t('If you want to delete the Solr index, you must check the confirmation box.'));
+  }
+}
+
+/**
+ * Submit function for the 'Delete the index' button.
+ *
+ * @see apachesolr_delete_index_form()
+ */
+function apachesolr_delete_index() {
+  try {
+    // Instantiate a new Solr object.
+    $solr = apachesolr_get_solr();
+    $query = '*:*';
+    // Allow other modules to modify the delete query.
+    // For example, use the site hash so that you only delete this site's
+    // content:  $query = 'hash:' . apachesolr_site_hash()
+    drupal_alter('apachesolr_delete_index', $query);
+    $solr->deleteByQuery($query);
+    $solr->commit();
+    apachesolr_clear_last_index();
+    // This form can't be seen by anyone without 'administer site configuration'
+    // permission, so no need to check perms before displaying a run-cron link.
+    drupal_set_message(t('The Solr content index has been erased. You must now !run_cron until your entire site has been re-indexed.', array('!run_cron' => l(t('run cron'), 'admin/reports/status/run-cron', array('query' => array('destination' => 'admin/settings/apachesolr/index'))))));
+  }
+  catch (Exception $e) {
+    watchdog('Apache Solr', $e->getMessage(), array(), WATCHDOG_ERROR);
+  }
+}
+
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.92
diff -u -p -r1.1.2.12.2.92 apachesolr.module
--- apachesolr.module	26 Jan 2009 14:19:28 -0000	1.1.2.12.2.92
+++ apachesolr.module	26 Jan 2009 22:23:40 -0000
@@ -18,82 +18,38 @@ function apachesolr_menu() {
     'page arguments'     => array('apachesolr_settings'),
     'access callback'    => 'user_access',
     'access arguments'   => array('administer site configuration'),
+    'file'               => 'apachesolr.admin.inc',
   );
   $items['admin/settings/apachesolr/settings'] = array(
     'title'              => 'Settings',
     'weight'             => -10,
     'access callback'    => 'user_access',
     'access arguments'   => array('administer site configuration'),
+    'file'               => 'apachesolr.admin.inc',
     'type'               => MENU_DEFAULT_LOCAL_TASK,
   );
+  $items['admin/settings/apachesolr/enabled-filters'] = array(
+    'title' => 'Enabled filters',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('apachesolr_enabled_facets_form'),
+    'weight' => -7,
+    'access callback' => 'user_access',
+    'access arguments' => array('administer site configuration'),
+    'file'               => 'apachesolr.admin.inc',
+    'type' => MENU_LOCAL_TASK,
+  );
   $items['admin/settings/apachesolr/index'] = array(
     'title'              => 'Search index',
     'page callback'      => 'apachesolr_index_page',
     'access callback'    => 'user_access',
     'access arguments'   => array('administer site configuration'),
     'weight'             => -8,
+    'file'               => 'apachesolr.admin.inc',
     'type'               => MENU_LOCAL_TASK,
   );
   return $items;
 }
 
-function apachesolr_settings() {
-  $form = array();
-
-  //perform a check to ensure the server is there
-  $requirements = apachesolr_requirements('runtime');
-  $status = $requirements['apachesolr']['severity'] == 2 ? 'error' : 'status';
-  drupal_set_message($requirements['apachesolr']['value'], $status);
-
-  $form['apachesolr_host'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Solr host name'),
-    '#default_value' => variable_get('apachesolr_host', 'localhost'),
-    '#description' => t('Host name of your Solr server, e.g. <code>localhost</code> or <code>example.com</code>.'),
-  );
-  $form['apachesolr_port'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Solr port'),
-    '#default_value' => variable_get('apachesolr_port', '8983'),
-    '#description' => t('Port on which the Solr server listens. Tomcat is 8080 by default.'),
-  );
-  $form['apachesolr_path'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Solr path'),
-    '#default_value' => variable_get('apachesolr_path', '/solr'),
-    '#description' => t('Path that identifies the Solr request handler to be used. Leave this as /solr for now.'),
-  );
-
-  $numbers = drupal_map_assoc(array(10, 20, 50, 100));
-  $form['apachesolr_cron_limit'] = array(
-    '#type' => 'select',
-    '#title' => t('Number of items to index per cron run'),
-    '#default_value' => variable_get('apachesolr_cron_limit', 50),
-    '#options' => $numbers,
-    '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))
-  );
-
-  $options = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100));
-  $form['apachesolr_rows'] = array(
-    '#type' => 'select',
-    '#title' => t('Results per page'),
-    '#default_value' => variable_get('apachesolr_rows', 10),
-    '#options' => $options,
-    '#description' => t('The number of results that will be shown per page.'),
-  );
-  $form['apachesolr_failure'] = array(
-    '#type' => 'select',
-    '#title' => t('On failure'),
-    '#options' => array('show_error' => t('Show error'),
-      'show_drupal_results' => t('Show core Drupal results'),
-      'show_no_results' => t('Show no results')
-    ),
-    '#default_value' => variable_get('apachesolr_failure', 'show_error'),
-    '#description' => t('What to display if ApacheSolr search is not available.'),
-  );
-  return system_settings_form($form);
-}
-
 /**
  * Determines ApacheSolr's behavior when searching causes an exception (e.g. Solr isn't available.)
  * Depending on the admin settings, possibly redirect to Drupal's core search.
@@ -158,131 +114,6 @@ function apachesolr_requirements($phase)
 }
 
 /**
- * Gets information about the fields already in solr index.
- */
-function apachesolr_index_page() {
-  try {
-    $solr = apachesolr_get_solr();
-    // TODO: only clear this every page view if we are running
-    // multi-site.
-    $solr->clearCache();
-    // Note: we use 2 since 1 fails on Ubuntu Hardy.
-    $data = $solr->getLuke(2);
-  }
-  catch (Exception $e) {
-    watchdog('apachesolr', $e->getMessage());
-    drupal_set_message($e->getMessage(), "warning");
-    $data->fields = array();
-  }
-
-  $output  = '';
-  if (isset($data->index->numDocs)) {
-    $output .= '<p>' . t('Number of documents in index: @num', array('@num' => $data->index->numDocs)) . "</p>\n";
-    $output .= '<p>' . t('Number of terms in index: @num', array('@num' => $data->index->numTerms)) . "</p>\n";
-  }
-
-  $fields = (array)$data->fields;
-  if ($fields) {
-    $output .= '<p>' . t('Number of fields in index: @num', array('@num' => count($fields))) . "</p>\n";
-    $rows = array();
-    foreach ($fields as $name => $field) {
-      // TODO: try to map the name to something more meaningful.
-      $rows[$name] = array($name, $field->type, isset($field->index) ? $field->distinct : t('Not indexed'));
-    }
-    ksort($rows);
-    // Display the table of Field names, Index Types, and term counts.
-    $output .= theme('table', array(t('Field name'), t('Index type'), t('Distinct terms')), $rows);
-  }
-  else {
-    $output .= '<p>' . t('No data on indexed fields.') . "</p>\n";
-  }
-
-  // Display the Delete Index form.
-  $output .= drupal_get_form('apachesolr_delete_index_form');
-
-  return $output;
-}
-
-/**
- * Create a form for deleting the contents of the Solr index.
- */
-function apachesolr_delete_index_form() {
-  $form = array();
-  $form['markup'] = array(
-    '#type' => 'markup',
-    '#value' => '<h3>Solr Index</h3>',
-  );
-  $form['reindex'] = array(
-    '#type' => 'submit',
-    '#value' => t('Re-index all content'),
-    '#submit' => array('apachesolr_clear_index'),
-  );
-  $form['reindex-desc'] = array(
-    '#type' => 'item',
-    '#description' => t('Re-indexing will add all content to the index again (overwriting the index), but existing content in the index will remain searchable.'),
-  );
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Delete the index'),
-    '#validate' => array('apachesolr_delete_index_validate'),
-    '#submit' => array('apachesolr_delete_index'),
-  );
-  $form['delete_index'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Confirm index deletion'),
-    '#description' => t('Deletes all of the documents in the Solr index. This is rarely necessary unless your index is corrupt or you have installed a new schema.xml.'),
-    '#default_value' => NULL,
-  );
-  return $form;
-}
-
-/**
- * Submit function for the 'Re-index all content' button.
- *
- * @see apachesolr_delete_index_form()
- */
-function apachesolr_clear_index($form, &$form_state) {
-  apachesolr_clear_last_index();
-}
-
-/**
- * Validate function for the 'Delete the index' button.
- *
- * @see apachesolr_delete_index_form()
- */
-function apachesolr_delete_index_validate($form, &$form_state) {
-  if (!$form_state['values']['delete_index']) {
-    form_set_error('delete_index', t('If you want to delete the Solr index, you must check the confirmation box.'));
-  }
-}
-
-/**
- * Submit function for the 'Delete the index' button.
- *
- * @see apachesolr_delete_index_form()
- */
-function apachesolr_delete_index() {
-  try {
-    // Instantiate a new Solr object.
-    $solr = apachesolr_get_solr();
-    $query = '*:*';
-    // Allow other modules to modify the delete query.
-    // For example, use the site hash so that you only delete this site's
-    // content:  $query = 'hash:' . apachesolr_site_hash()
-    drupal_alter('apachesolr_delete_index', $query);
-    $solr->deleteByQuery($query);
-    $solr->commit();
-    apachesolr_clear_last_index();
-    // This form can't be seen by anyone without 'administer site configuration'
-    // permission, so no need to check perms before displaying a run-cron link.
-    drupal_set_message(t('The Solr content index has been erased. You must now !run_cron until your entire site has been re-indexed.', array('!run_cron' => l(t('run cron'), 'admin/reports/status/run-cron', array('query' => array('destination' => 'admin/settings/apachesolr/index'))))));
-  }
-  catch (Exception $e) {
-    watchdog('Apache Solr', $e->getMessage(), array(), WATCHDOG_ERROR);
-  }
-}
-
-/**
  * Like $site_key in _update_refresh() - returns a site-specific hash.
  */
 function apachesolr_site_hash() {
@@ -709,8 +540,21 @@ function apachesolr_nodeapi(&$node, $op,
   }
 }
 
-function apachesolr_apachesolr_facets() {
-  return array('type');
+/**
+ * Return the enabled facets from the specified block array.
+ *
+ * @param $module
+ *   The module (optional).
+ * @return
+ *   An array consisting info for facets that have been enabled
+ *   for the specified module, or all enabled facets.
+ */
+function apachesolr_get_enabled_facets($module = NULL) {
+  $enabled = variable_get('apachesolr_enabled_facets', array());
+  if (isset($module)) {
+    return isset($enabled[$module]) ? $enabled[$module] : array();
+  }
+  return $enabled;
 }
 
 /**
@@ -719,9 +563,11 @@ function apachesolr_apachesolr_facets() 
 function apachesolr_block($op = 'list', $delta = 0, $edit = array()) {
   switch ($op) {
     case 'list':
-      // Sorting block
-      $blocks['sort'] = array('info' => t('ApacheSolr Core: Sorting'), 'cache' => BLOCK_CACHE_PER_PAGE);
-      $blocks['type'] = array('info' => t('ApacheSolr Core: Filter by type'), 'cache' => BLOCK_CACHE_PER_PAGE);
+      // Add the blocks
+      $blocks['sort'] = array(
+        'info' => t('ApacheSolr Core: Sorting'),
+        'cache' => BLOCK_CACHE_PER_PAGE,
+      );
       return $blocks;
 
     case 'view':
@@ -765,37 +611,27 @@ function apachesolr_block($op = 'list', 
             }
             return array('subject' => t('Sort by'),
                          'content' => theme('apachesolr_sort_list', $sort_links));
-
-          case 'type':
-            $filter_by = t('Filter by type');
-            return apachesolr_facet_block($response, $query, $delta, $filter_by, 'apachesolr_get_type');
-
           default:
             break;
         }
-        break;
-      }
-      break;
-
-    case 'configure':
-      if ($delta != 'sort') {
-        return apachesolr_facetcount_form($delta);
-      }
-      break;
 
-    case 'save':
-      if ($delta != 'sort') {
-        apachesolr_facetcount_save($delta, $edit);
       }
       break;
   }
 }
 
-function apachesolr_facet_block($response, $query, $delta, $filter_by, $facet_callback = FALSE) {
-  if (!empty($response->facet_counts->facet_fields->$delta)) {
+/**
+ * Helper function for displaying a facet block.
+ */
+function apachesolr_facet_block($response, $query, $module, $delta, $facet_field, $filter_by, $facet_callback = FALSE) {
+  if (!empty($response->facet_counts->facet_fields->$facet_field)) {
     $contains_active = FALSE;
     $items = array();
-    foreach ($response->facet_counts->facet_fields->$delta as $facet => $count) {
+    foreach ($response->facet_counts->facet_fields->$facet_field as $facet => $count) {
+      // Solr sends this back if it's empty.
+      if ($facet == '_empty_') {
+        continue;
+      }
       $unclick_link = '';
       unset($active);
       if ($facet_callback && function_exists($facet_callback)) {
@@ -805,16 +641,16 @@ function apachesolr_facet_block($respons
         $facet_text = $facet;
       }
       $new_query = clone $query;
-      if ($active = $query->has_field($delta, $facet)) {
+      if ($active = $query->has_field($facet_field, $facet)) {
         $contains_active = TRUE;
-        $new_query->remove_field($delta, $facet);
+        $new_query->remove_field($facet_field, $facet);
         // TODO: don't assume 'search' - find the real path.
         $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
         $querystring = $new_query->get_url_querystring();
         $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
       }
       else {
-        $new_query->add_field($delta, $facet);
+        $new_query->add_field($facet_field, $facet);
         $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
         $querystring = $new_query->get_url_querystring();
       }
@@ -830,68 +666,41 @@ function apachesolr_facet_block($respons
     if (count($items) > 0) {
       ksort($items);
       // Get information needed by the rest of the blocks about limits.
-      $facet_display_limits = variable_get('apachesolr_facet_query_limits', array());
-      $facet_display_initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
-      $facet_display_limit = isset($facet_display_limits[$delta]) ? $facet_display_limits[$delta] : variable_get('apachesolr_facet_query_limit_default', 20);
-      $facet_display_initial_limit = isset($facet_display_initial_limits[$delta]) ? $facet_display_initial_limits[$delta] : variable_get('apachesolr_facet_query_initial_limit_default', 10);
-      $items = array_slice($items, 0, ($facet_display_limit == -1 ? NULL : $facet_display_limit));
-      $output = theme('apachesolr_facet_list', $items, $facet_display_initial_limit);
-      return array('subject' => t('@filter_by', array('@filter_by' => $filter_by)), 'content' => $output);
+      $initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
+      $limit = isset($initial_limits[$module][$delta]) ? $initial_limits[$module][$delta] : variable_get('apachesolr_facet_query_initial_limit_default', 10);
+      $output = theme('apachesolr_facet_list', $items, $limit);
+      return array('subject' => $filter_by, 'content' => $output);
     }
   }
   return NULL;
 }
 
 /**
- * Callback function for the 'Filter by type' facet block.
- */
-function apachesolr_get_type($facet) {
-  return node_get_types('name', $facet);
-}
-
-function apachesolr_form_block_admin_configure_alter(&$form, $form_state) {
-  if (isset($form['block_settings']) && isset($form['block_settings']['apachesolr_facet_query_limit'])) {
-    $form['#validate'][] = 'apachesolr_facet_query_limit_validate';
-  }
-}
-
-/**
- * Validates a facet query limit input. Must be a positive integer or -1.
- */
-function apachesolr_facet_query_limit_validate($form, &$form_state) {
-  $value = intval($form_state['values']['apachesolr_facet_query_limit']);
-  if ($value < 1 && $value != -1) {
-    form_set_error('apachesolr_facet_limit', t('Please enter a number greater than 1 or -1 for the facet query limit.'));
-    return FALSE;
-  }
-}
-
-/**
  * Used by the 'configure' $op of hook_block so that modules can generically set
  * facet limits on their blocks.
  */
-function apachesolr_facetcount_form($delta) {
-  $facet_query_initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
-  $facet_query_limits = variable_get('apachesolr_facet_query_limits', array());
-  
-  // If the block is not 'sort' (and therefore is a facet block),
-  // display facet limit option.
+function apachesolr_facetcount_form($module, $delta) {
+  $initial = variable_get('apachesolr_facet_query_initial_limits', array());
+  $limits = variable_get('apachesolr_facet_query_limits', array());
+
+  $limit = drupal_map_assoc(array(50, 40, 30, 20, 15, 10, 5, 3));
+
   $form['apachesolr_facet_query_initial_limit'] = array(
-    '#type' => 'textfield',
+    '#type' => 'select',
     '#title' => t('Initial filter terms to show'),
-    '#required' => TRUE,
-    '#description' => t('The initial number of filter links to show in this block. Set to -1 for unlimited. Default is 10.'),
-    '#default_value' => isset($facet_query_initial_limits[$delta]) ? $facet_query_initial_limits[$delta] : variable_get('apachesolr_facet_query_initial_limit_default', 10),
+    '#options' => $limit,
+    '#description' => t('The initial number of filter links to show in this block.'),
+    '#default_value' => isset($initial[$module][$delta]) ? $initial[$module][$delta] : variable_get('apachesolr_facet_query_initial_limit_default', 10),
   );
-  
+  $limit = drupal_map_assoc(array(100, 75, 50, 40, 30, 20, 15, 10, 5, 3));
   $form['apachesolr_facet_query_limit'] = array(
-    '#type' => 'textfield',
+    '#type' => 'select',
     '#title' => t('Maximum filter terms to show'),
-    '#required' => TRUE,
-    '#description' => t('The maximum number of filter links to show in this block. Set to -1 for unlimited. Default is 20.'),
-    '#default_value' => isset($facet_query_limits[$delta]) ? $facet_query_limits[$delta] : variable_get('apachesolr_facet_query_limit_default', 20),
+    '#options' => $limit,
+    '#description' => t('The maximum number of filter links to show in this block.'),
+    '#default_value' => isset($limits[$module][$delta]) ? $limits[$module][$delta] : variable_get('apachesolr_facet_query_limit_default', 20),
   );
-  
+
   return $form;
 }
 
@@ -899,14 +708,16 @@ function apachesolr_facetcount_form($del
  * Used by the 'save' $op of hook_block so that modules can generically set
  * facet limits on their blocks.
  */
-function apachesolr_facetcount_save($delta, $edit) {
+function apachesolr_facetcount_save($edit) {
   // Save query limits
-  $facet_query_limits = variable_get('apachesolr_facet_query_limits', array());
-  $facet_query_limits[$delta] = intval($edit['apachesolr_facet_query_limit']);
-  variable_set('apachesolr_facet_query_limits', $facet_query_limits);
-  $facet_query_initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
-  $facet_query_initial_limits[$delta] = intval($edit['apachesolr_facet_query_initial_limit']);
-  variable_set('apachesolr_facet_query_initial_limits', $facet_query_initial_limits);
+  $module = $edit['module'];
+  $delta = $edit['delta'];
+  $limits = variable_get('apachesolr_facet_query_limits', array());
+  $limits[$module][$delta] = (int)$edit['apachesolr_facet_query_limit'];
+  variable_set('apachesolr_facet_query_limits', $limits);
+  $initial = variable_get('apachesolr_facet_query_initial_limits', array());
+  $initial[$module][$delta] = (int)$edit['apachesolr_facet_query_initial_limit'];
+  variable_set('apachesolr_facet_query_initial_limits', $initial);
 }
 
 /**
@@ -1136,9 +947,6 @@ function apachesolr_theme() {
     'apachesolr_sort_link' => array(
       'arguments' => array('text' => NULL, 'path' => NULL, 'querystring' => '', 'active' => FALSE, 'direction' => ''),
     ),
-    'apachesolr_breadcrumb_type' => array(
-      'arguments' => array('type' => NULL),
-    ),
   );
 }
 
@@ -1194,16 +1002,14 @@ function theme_apachesolr_facet_list($it
       $items[] = array('data' => $link, 'class' => 'apachesolr-hidden-facet');
     }
   }
-  return theme('item_list', $items);
+  $admin_link = '';
+  if (user_access('administer site configuration')) {
+    $admin_link = l(t('Configure enabled filters'), 'admin/settings/apachesolr/enabled-filters');
+  }
+  return theme('item_list', $items) . $admin_link;
 }
 
 function theme_apachesolr_sort_list($items) {
   return theme('item_list', $items);
 }
 
-/**
- * Return the human readable text for a content type.
- */
-function theme_apachesolr_breadcrumb_type($type) {
-  return node_get_types('name', $type);
-}
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.59
diff -u -p -r1.1.2.6.2.59 apachesolr_search.module
--- apachesolr_search.module	16 Jan 2009 20:03:40 -0000	1.1.2.6.2.59
+++ apachesolr_search.module	26 Jan 2009 22:23:40 -0000
@@ -32,7 +32,7 @@ function apachesolr_search_help($section
  * Implementation of hook_menu().
  */
 function apachesolr_search_menu() {
-  $items['admin/settings/apachesolr/query_fields'] = array(
+  $items['admin/settings/apachesolr/query-fields'] = array(
     'title'            => 'Query field settings',
     'page callback'    => 'apachesolr_search_settings_page',
     'access arguments' => array('administer site configuration'),
@@ -110,24 +110,20 @@ function apachesolr_search_search($op = 
           $params['spellcheck'] = 'true';
         }
 
-        // TODO: This adds all of the possible facets to the query. Not all
-        // of these facets have their blocks enabled, so the list should be
-        // filtered by the actual enabled blocks, otherwise we're putting
-        // unneeded strain on the Solr server.
-        foreach (module_implements('apachesolr_facets') as $module) {
-          $function = $module .'_apachesolr_facets';
-          $result = call_user_func_array($function, array());
-          if (isset($result) && is_array($result)) {
-            foreach ($result as $facet) {
-              $params['facet.field'][] = $facet;
+        $facet_query_limits = variable_get('apachesolr_facet_query_limits', array());
+        // Request all enabled facets.
+        foreach (apachesolr_get_enabled_facets() as $module => $module_facets) {
+          foreach($module_facets as $delta => $facet_field) {
+            $params['facet.field'][] = $facet_field;
+            // Facet limits
+            if (isset($facet_query_limits[$module][$delta])) {
+              $params['f.' . $facet_field . '.facet.limit'] = $facet_query_limits[$module][$delta];
             }
           }
         }
-
-        // Facet limits
-        $facet_query_limits = variable_get('apachesolr_facet_query_limits', array());
-        foreach ($facet_query_limits as $fieldname => $limit) {
-          $params['f.' . $fieldname . '.facet.limit'] = $limit;
+        if (!empty($params['facet.field'])) {
+          // Add a default limit for fields where no limit was set.
+          $params['facet.limit'] = variable_get('apachesolr_facet_query_limit_default', 20);
         }
 
         if (isset($_GET['solrsort'])) {
@@ -139,12 +135,6 @@ function apachesolr_search_search($op = 
           $params['sort'] = $sort;
         }
 
-        if ($fields = apachesolr_cck_fields()) {
-          foreach ($fields as $name => $field) {
-            $index_key = apachesolr_index_key($field);
-            $params['facet.field'][] = $index_key;
-          }
-        }
         $page = isset($_GET['page']) ? $_GET['page'] : 0;
         $params['start'] = $page * $params['rows'];
         // This is the object that does the communication with the solr server.
@@ -207,7 +197,7 @@ function apachesolr_search_search($op = 
         if ($total > 0) {
           foreach ($response->response->docs as $doc) {
             $extra = array();
-            $snippet = isset($response->highlighting->{$doc->id}->$hl_fl) ? theme('apachesolr_snippets', $doc, $response->highlighting->{$doc->id}->$hl_fl) : '';
+            $snippet = isset($response->highlighting->{$doc->id}->$hl_fl) ? theme('apachesolr_search_snippets', $doc, $response->highlighting->{$doc->id}->$hl_fl) : '';
             if (!isset($doc->body)) {
               $doc->body = $snippet;
             }
@@ -247,8 +237,53 @@ function apachesolr_search_search($op = 
   } // switch
 }
 
+/**
+ * Implementation of hook_apachesolr_facets().
+ *
+ * Returns an array keyed by block delta.
+ */
 function apachesolr_search_apachesolr_facets() {
-  return array_keys(apachesolr_search_block());
+  $facets = array();
+
+  $facets['type'] = array(
+    'info' => t('ApacheSolr Search: Filter by content type'),
+    'facet_field' => 'type',
+  );
+  $facets['uid'] = array(
+    'info' => t('ApacheSolr Search: Filter by author'),
+    'facet_field' => 'uid',
+  );
+  $facets['language'] = array(
+    'info' => t('ApacheSolr Search: Filter by language'),
+    'facet_field' => 'language',
+  );
+
+  // Get taxonomy vocabulary facets.
+  if (module_exists('taxonomy')) {
+    $vocabs = taxonomy_get_vocabularies();
+    foreach ($vocabs as $vid => $vocab) {
+      // In this case the delta and facet field are the same.
+      $delta = 'imfield_vid_' . $vid;
+      $facets[$delta] = array(
+        'info' => t('ApacheSolr Search: Filter by @name', array('@name' => $vocab->name)),
+        'facet_field' => $delta,
+      );
+    }
+  }
+
+  // Get CCK field facets.
+  $fields = apachesolr_cck_fields();
+  if ($fields) {
+    foreach ($fields as $name => $field) {
+      // $delta can only be 32 chars, and the CCK field name may be this
+      // long also, so we cannot add anything to it.
+      $facets[$field['field_name']] = array(
+        'info' => t('ApacheSolr Search: Filter by @field', array('@field' => $field['label'])),
+        'facet_field' => apachesolr_index_key($field),
+      );
+    }
+  }
+  return $facets;
 }
 
 /**
@@ -258,26 +293,17 @@ function apachesolr_search_block($op = '
 
   switch ($op) {
     case 'list':
-      $blocks['uid'] = array('info' => t('ApacheSolr Search: Filter by author'));
-      $blocks['currentsearch'] = array('info' => t('ApacheSolr Search: Current search'), 'cache' => BLOCK_CACHE_PER_PAGE);
-      $blocks['language'] = array('info' => t('ApacheSolr Search: Filter by language'));
-      // Get taxonomy vocabulary facets.
-      if (module_exists('taxonomy')) {
-        $vocabs = taxonomy_get_vocabularies();
-        foreach ($vocabs as $vid => $vocab) {
-          $blocks['imfield_vid_' . $vid] = array('info' => t('ApacheSolr Search: Filter by @name', array('@name' => $vocab->name)), 'cache' => BLOCK_CACHE_PER_PAGE);
-        }
-      }
-
-      // Get CCK field facets.
-      if ($fields = apachesolr_cck_fields()) {
-        foreach ($fields as $name => $field) {
-          // $delta can only be 32 chars, and the CCK field name may be this
-          // long also, so we cannot add anything to it.
-          $blocks[$field['field_name']] = array('info' => t('ApacheSolr Search: Filter by @field', array('@field' => $field['label'])), 'cache' => BLOCK_CACHE_PER_PAGE);
-        }
+      $enabled_facets = apachesolr_get_enabled_facets('apachesolr_search');
+      $facets = apachesolr_search_apachesolr_facets();
+      // Add the blocks
+      $blocks = array();
+      foreach ($enabled_facets as $delta => $facet_field) {
+        $blocks[$delta] = $facets[$delta] + array('cache' => BLOCK_CACHE_PER_PAGE,);
       }
-
+      $blocks['currentsearch'] = array(
+        'info' => t('ApacheSolr Search: Current search'),
+        'cache' => BLOCK_CACHE_PER_PAGE,
+      );
       return $blocks;
 
     case 'view':
@@ -289,15 +315,14 @@ function apachesolr_search_block($op = '
         }
         $query = apachesolr_current_query();
 
-        if ($delta == 'language') {
-          include_once(drupal_get_path('module', 'apachesolr') . "/blocks/apachesolr_language.block.inc");
-          return apachesolr_language_block_view($response, $query);
+        $facets = apachesolr_get_enabled_facets('apachesolr_search');
+        if (empty($facets[$delta]) && ($delta != 'currentsearch')) {
+          return;
         }
 
-        // Get information needed by the rest of the blocks about limits.
-        $facet_display_limits = variable_get('apachesolr_facet_query_limits', array());
-        $facet_display_initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
-        
+        // Get information needed by the taxonomy blocks about limits.
+        $initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
+        $limit_default = variable_get('apachesolr_facet_query_initial_limit_default', 10);
 
         // Handle taxonomy vocabulary facets
         if ((strpos($delta, 'imfield_vid_') === 0) && module_exists('taxonomy')) {
@@ -337,15 +362,13 @@ function apachesolr_search_block($op = '
           $vocab = taxonomy_vocabulary_load($vid);
           if (is_numeric($vid) && is_array($terms) && isset($terms[$vid]) && is_array($terms[$vid])) {
             ksort($terms[$vid]);
-            $facet_display_limit = isset($facet_display_limits[$delta]) ? $facet_display_limits[$delta] : variable_get('apachesolr_facet_query_limit_default', 20);
-            $facet_display_initial_limit = isset($facet_display_initial_limits[$delta]) ? $facet_display_initial_limits[$delta] : variable_get('apachesolr_facet_query_initial_limit_default', 10);
-            $terms[$vid] = array_slice($terms[$vid], 0, ($facet_display_limit == -1 ? NULL : $facet_display_limit));
-            return array('subject' => t('Filter by @name', array('@name' => $vocab->name)),
-                         'content' => theme('apachesolr_facet_list', $terms[$vid], $facet_display_initial_limit));
-          }
-          else {
-            return;
+            $limit = isset($initial_limits['apachesolr_search'][$delta]) ? $initial_limits['apachesolr_search'][$delta] : $limit_default;
+            return array(
+              'subject' => t('Filter by @name', array('@name' => $vocab->name)),
+              'content' => theme('apachesolr_facet_list', $terms[$vid], $limit),
+            );
           }
+          return;
         }
 
         switch ($delta) {
@@ -372,55 +395,21 @@ function apachesolr_search_block($op = '
               }
             }
             $content = theme('apachesolr_currentsearch', $response->response->numFound, $links);
-            return array('subject' => t('Current search'),
-                         'content' => $content);
+            return array('subject' => t('Current search'), 'content' => $content);
 
-          case 'uid':
-            $filter_by = t('Filter by author');
-            return apachesolr_facet_block($response, $query, $delta, $filter_by, 'apachesolr_search_get_username');
+          case 'language':
+            return apachesolr_facet_block($response, $query, 'apachesolr_search', $delta, $delta, t('Filter by language'), 'locale_language_name');
+           case 'uid':
+            return apachesolr_facet_block($response, $query, 'apachesolr_search', $delta, $delta, t('Filter by author'), 'apachesolr_search_get_username');
+          case 'type':
+            return apachesolr_facet_block($response, $query, 'apachesolr_search', $delta, $delta, t('Filter by type'), 'apachesolr_search_get_type');
 
           default:
            if ($fields = apachesolr_cck_fields()) {
             foreach ($fields as $name => $field) {
               if ($field['field_name'] == $delta) {
                 $index_key = apachesolr_index_key($field);
-                if (!empty($response->facet_counts->facet_fields->$index_key)) {
-                  $contains_active = FALSE;
-                  foreach ($response->facet_counts->facet_fields->$index_key as $facet => $count) {
-                    $unclick_link = '';
-                    unset($active);
-                    $new_query = clone $query;
-                    if ($active = $query->has_field($index_key, $facet)) {
-                      $contains_active = TRUE;
-                      $new_query->remove_field($index_key, $facet);
-                      $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
-                      $querystring = $new_query->get_url_querystring();
-                      $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
-                    }
-                    else {
-                      $new_query->add_field($index_key, $facet);
-                      $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
-                      $querystring = $new_query->get_url_querystring();
-                    }
-                    $countsort = $count == 0 ? '' : 1 / $count;
-                    // if numdocs == 1 and !active, don't add.
-                    if ($response->numFound == 1 && !$active) {
-                      // skip
-                    }
-                    else {
-                      $facets[$active ? $countsort . $facet : 1 + $countsort . $facet] = theme('apachesolr_facet_item', $facet, $count, $path, $querystring, $active, $unclick_link, $response->numFound);
-                    }
-                  }
-                  if (!empty($facets)) {
-                    ksort($facets);
-                    $facet_display_limit = isset($facet_display_limits[$delta]) ? $facet_display_limits[$delta] : 20;
-                    $facet_display_initial_limit = isset($facet_display_initial_limits[$delta]) ? $facet_display_initial_limits[$delta] : variable_get('apachesolr_facet_query_initial_limit_default', 10);
-                    $facets = array_slice($facets, 0, ($facet_display_limit == -1 ? NULL : $facet_display_limit));
-                    $output = theme('apachesolr_facet_list', $facets, $facet_display_initial_limit);
-                    return array('subject' => t('Filter by @field', array('@field' => $field['label'])),
-                                 'content' => $output);
-                  }
-                }
+                return apachesolr_facet_block($response, $query, 'apachesolr_search', $delta, $index_key, t('Filter by @field', array('@field' => $field['label'])));
               }
             }
           }
@@ -430,20 +419,39 @@ function apachesolr_search_block($op = '
       break;
 
     case 'configure':
-      if ($delta != 'sort') {
-        return apachesolr_facetcount_form($delta);
+      if ($delta != 'currentsearch') {
+        return apachesolr_facetcount_form('apachesolr_search', $delta);
       }
       break;
 
     case 'save':
-      if ($delta != 'sort') {
-        apachesolr_facetcount_save($delta, $edit);
+      if ($delta != 'currentsearch') {
+        apachesolr_facetcount_save($edit);
       }
       break;
   }
 }
 
 /**
+ * Callback function for the 'Filter by name' facet block.
+ */
+function apachesolr_search_get_username($facet) {
+  if ($facet == 0) {
+    return variable_get('anonymous', t('Anonymous'));
+  }
+  else {
+    return db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $facet));
+  }
+}
+
+/**
+ * Callback function for the 'Filter by type' facet block.
+ */
+function apachesolr_search_get_type($facet) {
+  return node_get_types('name', $facet);
+}
+
+/**
  * Implementation of hook_form_[form_id]_alter().
  *
  * This adds spelling suggestions to the search form.
@@ -506,15 +514,6 @@ function apachesolr_search_build_spellch
   }
 }
 
-function apachesolr_search_get_username($facet) {
-  if ($facet == 0) {
-    return variable_get('anonymous', t('Anonymous'));
-  }
-  else {
-    return db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $facet));
-  }
-}
-
 /**
  * Implementation of hook_theme().
  */
@@ -526,10 +525,13 @@ function apachesolr_search_theme() {
     'apachesolr_breadcrumb_tid' => array(
       'arguments' => array('tid' => NULL),
     ),
+    'apachesolr_breadcrumb_type' => array(
+      'arguments' => array('type' => NULL),
+    ),
     'apachesolr_currentsearch' => array(
       'arguments' => array('total_found' => NULL, 'links' => NULL),
     ),
-      'apachesolr_snippets' => array(
+    'apachesolr_search_snippets' => array(
       'arguments' => array('doc' => NULL, 'snippets' => NULL),
     ),
   );
@@ -551,6 +553,13 @@ function theme_apachesolr_breadcrumb_tid
 }
 
 /**
+ * Return the human readable text for a content type.
+ */
+function theme_apachesolr_breadcrumb_type($type) {
+  return node_get_types('name', $type);
+}
+
+/**
  * Return current search block contents
  */
 function theme_apachesolr_currentsearch($total_found, $links) {
@@ -559,10 +568,11 @@ function theme_apachesolr_currentsearch(
 
 /**
  * Returns the snipit text for a search entry
+ *
  * @param object $doc
- * @param array $snippits
+ * @param array $snippets
  *
  */
-function theme_apachesolr_snippets(&$doc, $snippets) {
+function theme_apachesolr_search_snippets($doc, $snippets) {
   return implode(' ... ', $snippets);
 }
Index: blocks/apachesolr_language.block.inc
===================================================================
RCS file: blocks/apachesolr_language.block.inc
diff -N blocks/apachesolr_language.block.inc
--- blocks/apachesolr_language.block.inc	31 Dec 2008 19:14:40 -0000	1.1.2.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-<?php
-// $Id: apachesolr_language.block.inc,v 1.1.2.4 2008/12/31 19:14:40 jacobsingh Exp $
-
-function apachesolr_language_block_view($response, $query) {
-  $title = t('Filter by language');
-
-  if (is_object($response->facet_counts->facet_fields->language)) {
-    $contains_active = FALSE;
-    $languages = array();
-    foreach ($response->facet_counts->facet_fields->language as $language => $count) {
-      $unclick_link = '';
-      // Solr sends this back if it's empty.
-      if ($language == '_empty_') {
-        continue;
-      }
-      $new_query = clone $query;
-      if ($active = $query->has_field('language', $language)) {
-        $contains_active = TRUE;
-        $new_query->remove_field('language', $language);
-        $path = 'search/' . arg(1) . '/' . $new_query->get_query_basic();
-        $querystring = $new_query->get_url_querystring();
-        $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
-      }
-      else {
-        $new_query->add_field('language', $language);
-        $path = 'search/' . arg(1) . '/' . $new_query->get_query_basic();
-        $querystring = $new_query->get_url_querystring();
-      }
-      $countsort = $count == 0 ? '' : 1 / $count;
-      // if numdocs == 1 and !active, don't add.
-      if ($response->numFound == 1 && !$active) {
-        // skip
-      }
-      else {
-        $languages[] = theme('apachesolr_facet_item', locale_language_name($language), $count, $path, $querystring, $active, $unclick_link);
-      }
-    }
-    if (count($languages) > 0) {
-      $facet_display_limits = variable_get('apachesolr_facet_query_limits', array());
-      $facet_display_limit = isset($facet_display_limits['language']) ? $facet_display_limits['language'] : variable_get('apachesolr_facet_query_limit_default', 10);
-      $languages = array_slice($languages, 0, $facet_display_limit);
-      $output = theme('apachesolr_facet_list', $languages);
-      return array('subject' => $title, 'content' => $output);
-    }
-  }
-}
\ No newline at end of file
