diff -u solr/project_solr.module solr/project_solr.module --- solr/project_solr.module 10 Aug 2010 16:59:47 -0000 +++ solr/project_solr.module 10 Aug 2010 18:16:29 -0000 @@ -177,9 +177,9 @@ /** * Implementation of hook_apachesolr_modify_query(). - * - * This extracts 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 turns them into a + * + * 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. @@ -190,7 +190,6 @@ $vocabs = project_get_related_tids_map(TRUE); $project_type_related_vids = array_keys($vocabs); - // Pull all the filters. foreach ($query->get_filters() as $filter) { // Grab any project-type-related filters (im_vid_X filters). if (preg_match('/^im_vid_(.*)$/', $filter['#name'], $matches)) { @@ -213,7 +212,7 @@ /** * Implementation of hook_apachesolr_prepare_query(). * - * This simply adds an alias to allow the im_project_release_api_tids to present + * 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. @@ -530,23 +529,17 @@ } /** - * Adds an api version selection field to an existing form. + * Return a Form API array for an API version selector field. * - * Adds an api version selection field to an existing form with a configurable - * field name and a configurable title. - * - * @param array &$form - * An existing form array to which the field will be added. * @param object $query * An existing query object that we can check for existing filters. - * @param string $field_name - * The name of the version select field as it should appear in the form. - * @param string $title - * The label of the version select field as it should appear in the form. + * @param string $label + * Optional form label for the version selector field. * - * @return none + * @return + * Form array for the API version selector field. */ -function project_solr_add_version_field(&$form, $query, $field_name = 'api_version', $title = 'Filter by compatibility') { +function project_solr_get_api_version_field($query, $label = NULL) { if (module_exists('project_release')) { $current_tid = ''; $terms = array(); @@ -560,8 +553,11 @@ } if (!empty($terms)) { $terms = array('' => t('- Any -')) + $terms; - $form[$field_name] = array( - '#title' => t($title), + if (empty($label)) { + $label = t('Filter by compatibility'); + } + return array( + '#title' => $label, '#type' => 'select', '#options' => $terms, '#default_value' => $current_tid, @@ -605,7 +601,7 @@ } // Add the version selection field to our form. - project_solr_add_version_field($form, $query); + $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);