Index: apachesolr.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v retrieving revision 1.1.2.19 diff -u -r1.1.2.19 apachesolr.module --- apachesolr.module 19 Jul 2008 19:07:55 -0000 1.1.2.19 +++ apachesolr.module 19 Jul 2008 23:09:41 -0000 @@ -215,7 +215,7 @@ // Let modules add to the document module_invoke_all('apachesolr_update_index', &$document, $node); - $fields = array('title', 'body', 'type', 'uid', 'changed', 'nid', 'comment_count', 'name'); + $fields = array('title', 'body', 'type', 'uid', 'changed', 'nid', 'comment_count', 'name', 'language'); foreach ((array)$node as $key => $value) { if (in_array($key, $fields)) { $document->$key = $value; Index: sites/all/modules/apachesolr/apachesolrlang.module =================================================================== RCS file: sites/all/modules/apachesolr/apachesolrlang.module diff -N sites/all/modules/apachesolr/apachesolrlang.module --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/apachesolrlang.module 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,73 @@ + $title); + return $blocks; + + case 'view': + if (apachesolr_has_searched()) { + // Get the query and response. Without these no blocks make sense. + $response =& apachesolr_static_response_cache(); + if (empty($response)) { + return; + } + $query =& apachesolr_drupal_query(); + + switch ($delta) { + case 'language': + if (is_array($response->facets->language)) { + $contains_active = FALSE; + foreach ($response->facets->language as $language => $count) { + $unclick_link = ''; + unset($active); + $new_query = clone $query; + if ($active = $query->has_field('language', $language)) { + $contains_active = TRUE; + $new_query->remove_field('language', $language); + $path = 'search/'. arg(1). '/'. $new_query->get_query(); + $unclick_link = theme('apachesolr_unclick_link', $path); + } + else { + $new_query->add_field('language', $language); + $path = 'search/'. arg(1). '/'. $new_query->get_query(); + } + $countsort = $count == 0 ? '' : 1 / $count; + // if numdocs == 1 and !active, don't add. + if ($response->numFound == 1 && !$active) { + // skip + } + else { + $result = db_query("SELECT name FROM {locales_meta} WHERE locale = '%s' LIMIT 1", $language); + $lang_name = db_result($result); + $languages[] = theme('apachesolr_facet_item', $lang_name ? $lang_name : $language, $count, $path, $active, $unclick_link); + } + } + if (is_array($languages)) { + $facet_limits = variable_get('apachesolr_facet_limits', array()); + $facet_limit = isset($facet_limits[$delta]) ? $facet_limits[$delta] : 10; + $languages = array_slice($languages, 0, $facet_limit); + $output = theme('apachesolr_facet_list', $languages); + return array('subject' => $title, 'content' => $output); + } + } + + break; + } + } + break; + + case 'configure': + return apachesolr_block($op, $delta); + + case 'save': + return apachesolr_block($op, $delta, $edit); + } +} Index: sites/all/modules/apachesolr/apachesolrlang.info =================================================================== RCS file: sites/all/modules/apachesolr/apachesolrlang.info diff -N sites/all/modules/apachesolr/apachesolrlang.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/apachesolrlang.info 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +; $Id$ +name = Apache Solr languages +description = Adds language facets. +dependencies = locale apachesolr search +package = ApacheSolr