--- modules/project/solr/project_solr.module 2009-05-04 17:59:15.186451237 -0500 +++ modules/project_patched/solr/project_solr.module 2009-05-04 17:59:23.957287596 -0500 @@ -178,25 +178,15 @@ function project_solr_browse_summary_pag return theme('item_list', $items); } -function project_solr_browse_page($term_name) { +/** + * The actual searching is done here. + */ +function project_solr_browse_search($parent_term = '') { try { - $output = ''; $vid = _project_get_vid(); - $parent_term = db_fetch_object(db_query("SELECT t.tid, t.name, t.description FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s')", $term_name)); - - if (!$parent_term) { - // XXX: this is the Drupal 5 way... - return drupal_not_found(); - } - drupal_set_title(check_plain($parent_term->name)); - if (!empty($parent_term->description)) { - $output .= theme('project_type_description', $parent_term); - } - $text_query = isset($_GET['text']) ? $_GET['text'] : ''; $filters = isset($_GET['filters']) ? $_GET['filters'] : ''; - $sort = isset($_GET['solrsort']) ? check_plain($_GET['solrsort']) : ''; // Validate sort parameter @@ -236,52 +226,78 @@ function project_solr_browse_page($term_ // This hook allows modules to modify the query and params objects. apachesolr_modify_query($query, $params, 'apachesolr_search'); if (!$query) { - return array(); + return NULL; } // We add 'fq' (filter query) parameters here to include all the constant // filters for the query -- project nodes of the given top-level type that // have releases (if project_release is enabled). $fq[] = 'type:project_project'; - $fq[] = 'im_vid_'. _project_get_vid() .':'. $parent_term->tid; + if ($parent_term != '') { + $fq[] = 'im_vid_'. _project_get_vid() .':'. $parent_term->tid; + } if (module_exists('project_release')) { $fq[] = 'is_project_has_releases:1'; } $params['fq'][] = '('. implode(' AND ', $fq) .')'; - $response = $solr->search($query->get_query_basic(), $params['start'], $params['rows'], $params); // The response is cached so that it is accessible to the blocks and anything // else that needs it beyond the initial search. - $total = $response->response->numFound; - - project_solr_response_cache(array($query, $response, $parent_term)); - - // Set breadcrumb - $breadcrumb = menu_get_active_breadcrumb(); - drupal_set_breadcrumb($breadcrumb); - - $output .= '
'; - pager_query("SELECT %d", $params['rows'], 0, NULL, $total); - if ($total > 0) { - foreach ($response->response->docs as $doc) { - $doc->created = strtotime($doc->created); - $doc->changed = strtotime($doc->changed); - $output .= project_solr_render_search_result($doc); - } - } - else { - $output .= t('No projects found in this category.'); + if (project_term != '') { + project_solr_response_cache(array($query, $response, $parent_term)); } - - $output .= '
'; // id="project-overview" - $output .= theme('pager', NULL, $params['rows'], 0); + return $response; } catch (Exception $e) { watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR); apachesolr_failure(t('Solr search'), is_null($query) ? $keys : $query->get_query_basic()); + return NULL; + } +} + +/** + * Page for browsing/searching of modules. + */ +function project_solr_browse_page($term_name) { + $output = ''; + $parent_term = db_fetch_object(db_query("SELECT t.tid, t.name, t.description FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s')", $term_name)); + + if (!$parent_term) { + // XXX: this is the Drupal 5 way... + return drupal_not_found(); + } + drupal_set_title(check_plain($parent_term->name)); + if (!empty($parent_term->description)) { + $output .= theme('project_type_description', $parent_term); + } + + $response = project_solr_browse_search($parent_term); + if ($response == NULL) { + return $output; + } + + $total = $response->response->numFound; + + // Set breadcrumb + $breadcrumb = menu_get_active_breadcrumb(); + drupal_set_breadcrumb($breadcrumb); + + $output .= '
'; + pager_query("SELECT %d", variable_get('apachesolr_rows', 10), 0, NULL, $total); + if ($total > 0) { + foreach ($response->response->docs as $doc) { + $doc->created = strtotime($doc->created); + $doc->changed = strtotime($doc->changed); + $output .= project_solr_render_search_result($doc); + } + } + else { + $output .= t('No projects found in this category.'); } + $output .= '
'; // id="project-overview" + $output .= theme('pager', NULL, variable_get('apachesolr_rows', 10), 0); return $output; }