? .svn
? SolrPhpClient
? contrib/.svn
? contrib/apachesolr_image/.svn
? contrib/apachesolr_nodeaccess/.svn
? contrib/apachesolr_nodeaccess/tests/.svn
? contrib/apachesolr_og/.svn
? tests/.svn
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.111
diff -u -p -r1.1.2.6.2.111 apachesolr_search.module
--- apachesolr_search.module	2 Jul 2009 21:58:34 -0000	1.1.2.6.2.111
+++ apachesolr_search.module	3 Jul 2009 21:05:16 -0000
@@ -173,6 +173,10 @@ function apachesolr_search_view($type = 
       else {
         $results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg()));
       }
+    } else {
+     // Show search form and browse-by blocks
+     $browse_by = apachesolr_search_browse('', '', '', 'search/' . $type);
+     return drupal_get_form('search_form', NULL, $keys, $type) . $browse_by;
     }
   }
   // Construct the search form.
@@ -180,6 +184,57 @@ function apachesolr_search_view($type = 
 }
 
 /**
+ * Execute an empty search (match all documents) and show a listing of all enabled facets.
+ */
+function apachesolr_search_browse($keys = '', $filters = '', $solrsort = '', $base_path = '') {
+  $query = apachesolr_drupal_query($keys, $filters, $solrsort, $base_path);
+  $params = array(
+    'start' => 0,
+    'rows' => 0,
+    'facet' => 'true',
+    'facet.mincount' => 1,
+    'facet.sort' => 'true'
+  );
+
+  apachesolr_search_add_facet_params($params, $query);
+  $solr = apachesolr_get_solr();
+  apachesolr_current_query($query);
+  $response = $solr->search('', $params['start'], $params['rows'], $params);
+  apachesolr_static_response_cache($response);
+  apachesolr_has_searched(TRUE);
+  // Get blocks for all enabled filters
+  foreach (apachesolr_get_enabled_facets() as $module => $module_facets) {
+    foreach($module_facets as $delta => $facet_field) {
+      if ($delta == 'currentsearch') {
+        continue;
+      }
+      $blocks[$facet_field] = (object)module_invoke($module, 'block', 'view', $delta);
+      $blocks[$facet_field]->subject = str_replace(t('Filter by '), t('Browse by '), $blocks[$facet_field]->subject);
+      $blocks[$facet_field]->weight = db_result(db_query("SELECT weight FROM {blocks} WHERE delta = '%s'", $delta));
+    }
+  }
+  apachesolr_has_searched(FALSE);
+  usort($blocks, create_function('$a, $b', 'return $a->weight - $b->weight;'));
+  return theme('apachesolr_browse_blocks', $blocks);
+}
+
+/**
+ * Theming function that shows a groups of blocks so users can start a search from a filter.
+ *
+ * @param $blocks an array of block objects.
+ */
+function theme_apachesolr_browse_blocks($blocks) {
+  $result = "<div class='apachesolr_browse_block'><h2>" . t('Browse available categories') .'</h2>';
+  $result .= '<p>' . t('Pick a category to launch a search.') . '</p>';
+  foreach ($blocks as $facet_field => $block) {
+    $result .= theme('block', $block);
+  }
+  $result .= '</div>';
+
+  return $result;
+}
+
+/**
  * Execute a search results based on keyword, filter, and sort strings.
  *
  * @throws Exception
@@ -942,6 +997,9 @@ function apachesolr_search_theme() {
     'apachesolr_breadcrumb_created' => array(
       'arguments' => array('type' => NULL),
     ),
+    'apachesolr_browse_blocks' => array(
+      'arguments' => array('blocks' => NULL),
+    ),
     'apachesolr_currentsearch' => array(
       'arguments' => array('total_found' => NULL, 'links' => NULL),
     ),
@@ -1021,5 +1079,4 @@ function theme_apachesolr_currentsearch(
  */
 function theme_apachesolr_search_snippets($doc, $snippets) {
   return implode(' ... ', $snippets) .' ...';
-}
-
+}
\ No newline at end of file
