diff -u solr/project_solr.module solr/project_solr.module --- solr/project_solr.module 18 Aug 2010 00:13:04 -0000 +++ solr/project_solr.module 18 Aug 2010 23:08:12 -0000 @@ -56,6 +56,11 @@ 'categories' => array(), ), ), + 'project_solr_category_block' => array( + 'arguments' => array( + 'items' => array(), + ), + ), ); } @@ -408,7 +413,7 @@ $variables[$delta] = project_block_render('project_solr', $delta); } - $search_path = 'project/' . drupal_strlower($project_type->name) . '/categories'; + $search_path = 'project/' . drupal_strtolower($project_type->name) . '/categories'; $variables['version_form'] = drupal_get_form('project_solr_version_form', $search_path); } @@ -653,7 +658,7 @@ apachesolr_current_query($query); // This hook allows modules to modify the query and params objects. - apachesolr_modify_query($query, $params, 'drupalorg_search_execute_base_query'); + apachesolr_modify_query($query, $params, 'project_solr_view_category_block'); $solr = apachesolr_get_solr(); $response = $solr->search($query->get_query_basic(), $params['start'], $params['rows'], $params); @@ -682,7 +687,27 @@ - 'content' => theme('item_list', $items), + 'content' => theme('project_solr_category_block', $items), ); } return array(); } /** + * Render the final markup for the content of a category block. + * + * @param array $items + * Array of links to projects in a given category block. + * + * @return + * Formatted HTML markup for the category block content. + * + * @see project_solr_view_category_block() + * @see theme_item_list() + */ +function theme_project_solr_category_block($items = array()) { + $output = ''; + if (!empty($items)) { + $output .= theme('item_list', $items); + } + return $output; +} + +/** @@ -710,7 +735,7 @@ } if (!empty($terms)) { $terms = array('' => t('- Any -')) + $terms; - if (empty($label)) { + if (!isset($label)) { $label = t('Filter by compatibility'); } return array( @@ -1022,8 +1047,10 @@ * * @param string $path * The base path to which the version form will redirect. + * @param string $label + * An optional label for the form element. */ -function project_solr_version_form(&$form_state, $path) { +function project_solr_version_form(&$form_state, $path, $label = NULL) { $query = apachesolr_current_query(); $form = array( @@ -1033,7 +1060,7 @@ // Add version select field to our form. $version_alias = variable_get('project_solr_project_release_api_tids_alias', 'api_version'); - $form[$version_alias] = project_solr_get_api_version_field($query, t('Select version')); + $form[$version_alias] = project_solr_get_api_version_field($query, $label); $form['path'] = array( '#type' => 'value',