diff -u drupalorg_search/drupalorg_search.module drupalorg_search/drupalorg_search.module --- drupalorg_search/drupalorg_search.module 18 Aug 2010 23:53:55 -0000 +++ drupalorg_search/drupalorg_search.module 19 Aug 2010 01:30:19 -0000 @@ -353,52 +353,15 @@ * blocks. Creates and caches a solr query for use by block elements. */ function drupalorg_search_execute_base_query() { - // Build a simple query. - $base_path = 'project/modules'; - - $filters = isset($_GET['filters']) ? $_GET['filters'] : ''; - $query = apachesolr_drupal_query('', $filters, '', $base_path); - $params = array( - // The fields to return. - 'fl' => 'id,nid,title', - 'start' => 0, - // We don't actually need to return rows. - 'rows' => 1, - // We need to be able to facet on the project vid value - // so we can pull project categories. - 'facet.field' => array( - 'type', - 'im_vid_' . _project_get_vid(), - 'im_project_release_api_tids', - ), - // Filters are set below via explicit calls to add_filter() rather than - // here in the $params array. This is because any filters passed to - // apachesolr_drupal_query() will override filters set via the $params - // array during the prepare_query() invocation. - 'fq' => array(), - 'facet' => 'true', - 'facet.mincount' => 1, - 'facet.sort' => 'true', - ); + // Create an object for the 'Modules' project type. Since we're hard-coding + // anyway, we don't need a full taxonomy_get_term(). + $project_type = new stdClass; + $project_type->tid = DRUPALORG_MODULE_TID; + $project_type->name = 'modules'; - apachesolr_search_add_facet_params($params, $query); - - // Allow modules to alter the query prior to statically caching it. - // This can e.g. be used to add available sorts. - foreach (module_implements('apachesolr_prepare_query') as $module) { - $function_name = $module . '_apachesolr_prepare_query'; - $function_name($query, $params, 'drupalorg_search_execute_base_query'); - } - - // We add our fields after the prepare_query() because prepare_query() - // generates a call to parse_filters() which destroys anything that - // does not get passed into the query on construction. - // We explicitly filter the blocks to only show projects with the module tid - // associated. These values are not passed in the url, so we add them here - // ourselves to ensure we only get the content we want. - $query->add_filter('type', 'project_project'); - $query->add_filter('im_vid_' . _project_get_vid(), DRUPALORG_MODULE_TID); + // Grab a Solr query with almost everything we need from project_solr. + $query = project_solr_build_project_query($project_type); // Cache the built query. Since all the built queries go through // this process, all the hook_invocations will happen later.