Index: solr/project_solr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/solr/project_solr.module,v
retrieving revision 1.73
diff -u -p -r1.73 project_solr.module
--- solr/project_solr.module	9 Aug 2010 23:02:36 -0000	1.73
+++ solr/project_solr.module	10 Aug 2010 18:16:29 -0000
@@ -177,18 +177,29 @@ function project_solr_apachesolr_update_
 
 /**
  * Implementation of hook_apachesolr_modify_query().
+ *
+ * Extract all of the project-type-related filters, which will be present
+ * in the url in the format im_vid_X:Y im_vid_X:Z, and turn them into a
+ * relevant subquery of the format (im_vid_X:Y OR im_vid_X:Z). This is done to
+ * allow searching for results matching any of Y or Z inside of vocabulary X.
+ * e.g. Return all themes that are Fixed OR Fluid.
  */
 function project_solr_apachesolr_modify_query(&$query, &$params) {
   $filter_set = array();
-  // Pull all the meta-type specific facets.
+  // Grab vids for all project-type-related vocabularies
+  $vocabs = project_get_related_tids_map(TRUE);
+  $project_type_related_vids = array_keys($vocabs);
+
   foreach ($query->get_filters() as $filter) {
-    // Grab any meta-type specific facet (im_vid_X facets).
+    // Grab any project-type-related filters (im_vid_X filters).
     if (preg_match('/^im_vid_(.*)$/', $filter['#name'], $matches)) {
-      $filter_set[$filter['#name']][] = $filter['#value'];
-      $query->remove_filter($filter['#name'], $filter['#value']);
+      if (in_array($matches[1], $project_type_related_vids)) {
+        $filter_set[$filter['#name']][] = $filter['#value'];
+        $query->remove_filter($filter['#name'], $filter['#value']);
+      }
     }
   }
-  // Add the meta-type specific facets back as an OR list.
+  // Add the project-type-related filters back as an OR list.
   foreach ($filter_set as $name => $filters) {
     $tid_query = apachesolr_drupal_query();
     foreach ($filters as $value) {  
@@ -200,6 +211,11 @@ function project_solr_apachesolr_modify_
 
 /**
  * Implementation of hook_apachesolr_prepare_query().
+ * 
+ * This just adds an alias to allow the im_project_release_api_tids to present
+ * itself as something different in the url. In the default case, instead of
+ * im_project_release_api_tids displaying in the url, api_version will display
+ * in the url, making the url more user-friendly.
  */
 function project_solr_apachesolr_prepare_query(&$query, &$params) {
   if (module_exists('project_release')) {
@@ -338,7 +354,7 @@ function project_solr_browse_page($term_
 
     $output .= '</div>'; // id="project-overview"
     $output .= theme('pager', NULL, $params['rows'], 0);
-    $output = drupal_get_form('project_solr_browse_projects_form', $project_type) . $output;
+    $output = drupal_get_form('project_solr_browse_projects_form', $project_type, 'project/' . drupal_strtolower($project_type->name)) . $output;
   }
   catch (Exception $e) {
     watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR);
@@ -513,9 +529,47 @@ function project_solr_block($op = 'list'
 }
 
 /**
+ * Return a Form API array for an API version selector field.
+ * 
+ * @param object $query
+ *   An existing query object that we can check for existing filters.
+ * @param string $label
+ *   Optional form label for the version selector field.
+ *
+ * @return
+ *   Form array for the API version selector field.
+ */
+function project_solr_get_api_version_field($query, $label = NULL) {
+  if (module_exists('project_release')) {
+    $current_tid = '';
+    $terms = array();
+    $active_terms = project_release_compatibility_list();
+    foreach ($active_terms as $tid => $term_name) {
+      $active = $query->has_filter('im_project_release_api_tids', $tid);
+      if ($active) {
+        $current_tid = $tid;
+      }
+      $terms[$tid] = $term_name;
+    }
+    if (!empty($terms)) {
+      $terms = array('' => t('- Any -')) + $terms;
+      if (empty($label)) {
+        $label = t('Filter by compatibility');
+      }
+      return array(
+        '#title' => $label,
+        '#type' => 'select',
+        '#options' => $terms,
+        '#default_value' => $current_tid,
+      );
+    }
+  }
+}
+
+/**
  * Build project browsing navigation form.
  */
-function project_solr_browse_projects_form(&$form_state, $project_type) {
+function project_solr_browse_projects_form(&$form_state, $project_type, $path) {
   drupal_add_css(drupal_get_path('module', 'project_solr') .'/project_solr.css');
   $response = apachesolr_static_response_cache();
   $query = apachesolr_current_query();
@@ -546,26 +600,8 @@ function project_solr_browse_projects_fo
     );
   }
 
-  if (module_exists('project_release')) {
-    $terms = array();
-    $active_terms = project_release_compatibility_list();
-    foreach ($active_terms as $tid => $term_name) {
-      $active = $query->has_filter('im_project_release_api_tids', $tid);
-      if ($active) {
-        $current_tid = $tid;
-      }
-      $terms[$tid] = $term_name;
-    }
-    if (!empty($terms)) {
-      $terms = array('' => t('- Any -')) + $terms;
-      $form['api_version'] = array(
-        '#title' => t('Filter by compatibility'),
-        '#type' => 'select',
-        '#options' => $terms,
-        '#default_value' => $current_tid,
-      );
-    }
-  }
+  // Add the version selection field to our form.
+  $form['api_version'] = project_solr_get_api_version_field($query);
 
   // Retrieve all the vocabularies related to project so that the facets can be built.
   $vocabs = project_get_related_tids_map(TRUE);
@@ -634,7 +670,7 @@ function project_solr_browse_projects_fo
 
   $form['path'] = array(
     '#type' => 'value',
-    '#value' => 'project/' . drupal_strtolower($project_type->name),
+    '#value' => $path,
   );
   $form['submit'] = array(
     '#type' => 'submit',
