| 1 |
<?php |
<?php |
| 2 |
// $Id: apachesolr_search.module,v 1.1.2.6.2.111.2.27 2009/11/06 10:56:37 robertDouglass Exp $ |
// $Id: apachesolr_search.module,v 1.1.2.6.2.111.2.28 2009/11/20 10:24:30 robertDouglass Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 422 |
// which won't be used. |
// which won't be used. |
| 423 |
if (apachesolr_block_visibility($query, $module, $delta)) { |
if (apachesolr_block_visibility($query, $module, $delta)) { |
| 424 |
// TODO: generalize handling of date and range facets. |
// TODO: generalize handling of date and range facets. |
| 425 |
|
// TODO: put field type in the facet definitions. |
| 426 |
if ($module == 'apachesolr_search' && ($facet_field == 'created' || $facet_field == 'changed')) { |
if ($module == 'apachesolr_search' && ($facet_field == 'created' || $facet_field == 'changed')) { |
| 427 |
list($start, $end, $gap) = apachesolr_search_date_range($query, $facet_field); |
list($start, $end, $gap) = apachesolr_search_date_range($query, $facet_field); |
| 428 |
if ($gap) { |
if ($gap) { |
| 739 |
|
|
| 740 |
// Handle taxonomy vocabulary facets |
// Handle taxonomy vocabulary facets |
| 741 |
if ((strpos($delta, 'im_vid_') === 0) && module_exists('taxonomy')) { |
if ((strpos($delta, 'im_vid_') === 0) && module_exists('taxonomy')) { |
| 742 |
|
$facet_query_sorts = variable_get('apachesolr_facet_query_sorts', array()); |
| 743 |
|
|
| 744 |
if (is_object($response->facet_counts->facet_fields->$delta)) { |
if (is_object($response->facet_counts->facet_fields->$delta)) { |
| 745 |
$contains_active = FALSE; |
$contains_active = FALSE; |
| 746 |
$terms = array(); |
$terms = array(); |
|
|
|
| 747 |
foreach ($response->facet_counts->facet_fields->$delta as $tid => $count) { |
foreach ($response->facet_counts->facet_fields->$delta as $tid => $count) { |
| 748 |
$options = array('delta' => $delta); |
$options = array('delta' => $delta); |
| 749 |
if ($tid == '_empty_') { |
if ($tid == '_empty_') { |
| 753 |
$unclick_link = ''; |
$unclick_link = ''; |
| 754 |
unset($active); |
unset($active); |
| 755 |
$term = taxonomy_get_term($tid); |
$term = taxonomy_get_term($tid); |
| 756 |
|
$sortpre = ''; |
| 757 |
|
if (isset($facet_query_sorts['apachesolr_search'][$delta]) && ($facet_query_sorts['apachesolr_search'][$delta] == 'index')) { |
| 758 |
|
$sortpre = $term->name; |
| 759 |
|
} |
| 760 |
$new_query = clone $query; |
$new_query = clone $query; |
| 761 |
if ($active = $query->has_filter('tid', $tid)) { |
if ($active = $query->has_filter('tid', $tid)) { |
| 762 |
$contains_active = TRUE; |
$contains_active = TRUE; |
| 770 |
$link = theme('apachesolr_facet_link', $term->name, $new_query->get_path(), $options, $count, $active, $response->response->numFound); |
$link = theme('apachesolr_facet_link', $term->name, $new_query->get_path(), $options, $count, $active, $response->response->numFound); |
| 771 |
} |
} |
| 772 |
$countsort = $count == 0 ? '' : 1 / $count; |
$countsort = $count == 0 ? '' : 1 / $count; |
| 773 |
|
$countsort += .000001; |
| 774 |
|
$countsort = number_format($countsort, 6); |
| 775 |
// if numdocs == 1 and !active, don't add. |
// if numdocs == 1 and !active, don't add. |
| 776 |
if ($response->response->numFound > 1 || $active) { |
if ($response->response->numFound > 1 || $active) { |
| 777 |
$terms[$term->vid][$active ? $countsort . $term->name : 1 + $countsort . $term->name] = $link; |
$terms[$term->vid][$active ? $sortpre . $countsort . $term->name : $sortpre . (1 + $countsort) . $term->name] = $link; |
| 778 |
} |
} |
| 779 |
} |
} |
| 780 |
} |
} |