| 1 |
<?php |
<?php |
| 2 |
// $Id: apachesolr.module,v 1.1.2.12.2.155.2.37 2009/11/20 11:37:36 robertDouglass Exp $ |
// $Id: apachesolr.module,v 1.1.2.12.2.155.2.38 2009/11/20 14:27:08 robertDouglass Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 818 |
*/ |
*/ |
| 819 |
function apachesolr_facet_block($response, $query, $module, $delta, $facet_field, $filter_by, $facet_callback = FALSE) { |
function apachesolr_facet_block($response, $query, $module, $delta, $facet_field, $filter_by, $facet_callback = FALSE) { |
| 820 |
if (!empty($response->facet_counts->facet_fields->$facet_field)) { |
if (!empty($response->facet_counts->facet_fields->$facet_field)) { |
| 821 |
|
$facet_query_sorts = variable_get('apachesolr_facet_query_sorts', array()); |
| 822 |
$contains_active = FALSE; |
$contains_active = FALSE; |
| 823 |
$items = array(); |
$items = array(); |
| 824 |
foreach ($response->facet_counts->facet_fields->$facet_field as $facet => $count) { |
foreach ($response->facet_counts->facet_fields->$facet_field as $facet => $count) { |
| 842 |
if ($facet_callback && function_exists($facet_callback)) { |
if ($facet_callback && function_exists($facet_callback)) { |
| 843 |
$facet_text = $facet_callback($facet, $options); |
$facet_text = $facet_callback($facet, $options); |
| 844 |
} |
} |
| 845 |
|
// If this block is to be alphabetically sorted, change $sortpre. |
| 846 |
|
if (isset($facet_query_sorts[$module][$delta]) && ($facet_query_sorts[$module][$delta] == 'index')) { |
| 847 |
|
$sortpre = $facet_text; |
| 848 |
|
} |
| 849 |
$unclick_link = ''; |
$unclick_link = ''; |
| 850 |
$active = FALSE; |
$active = FALSE; |
| 851 |
$new_query = clone $query; |
$new_query = clone $query; |
| 1106 |
function apachesolr_facetcount_form($module, $delta) { |
function apachesolr_facetcount_form($module, $delta) { |
| 1107 |
$initial = variable_get('apachesolr_facet_query_initial_limits', array()); |
$initial = variable_get('apachesolr_facet_query_initial_limits', array()); |
| 1108 |
$limits = variable_get('apachesolr_facet_query_limits', array()); |
$limits = variable_get('apachesolr_facet_query_limits', array()); |
| 1109 |
|
$sorts = variable_get('apachesolr_facet_query_sorts', array()); |
| 1110 |
$facet_missing = variable_get('apachesolr_facet_missing', array()); |
$facet_missing = variable_get('apachesolr_facet_missing', array()); |
| 1111 |
|
|
| 1112 |
$limit = drupal_map_assoc(array(50, 40, 30, 20, 15, 10, 5, 3)); |
$limit = drupal_map_assoc(array(50, 40, 30, 20, 15, 10, 5, 3)); |
| 1126 |
'#description' => t('The maximum number of filter links to show in this block.'), |
'#description' => t('The maximum number of filter links to show in this block.'), |
| 1127 |
'#default_value' => isset($limits[$module][$delta]) ? $limits[$module][$delta] : variable_get('apachesolr_facet_query_limit_default', 20), |
'#default_value' => isset($limits[$module][$delta]) ? $limits[$module][$delta] : variable_get('apachesolr_facet_query_limit_default', 20), |
| 1128 |
); |
); |
| 1129 |
|
|
| 1130 |
|
// TODO: Generalize how we know what type a facet block is by putting field |
| 1131 |
|
// type into the facet definition. 'created' and 'changed' are date blocks. |
| 1132 |
|
if ($delta != 'created' && $delta != 'changed') { |
| 1133 |
|
$form['apachesolr_facet_query_sort'] = array( |
| 1134 |
|
'#type' => 'radios', |
| 1135 |
|
'#title' => t('Sort order of facet links'), |
| 1136 |
|
'#options' => array('count' => t('Count'), 'index' => t('Alphanumeric')), |
| 1137 |
|
'#description' => t('The sort order of facet links in this block. %Count, which is the default, will show facets with the most results first. %Alphanumeric will sort alphabetically, ascending.', array('%Count' => t('Count'), '%Alphanumeric' => t('Alphanumeric'))), |
| 1138 |
|
'#default_value' => isset($sorts[$module][$delta]) ? $sorts[$module][$delta] : 'count', |
| 1139 |
|
); |
| 1140 |
|
} |
| 1141 |
$form['apachesolr_facet_missing'] = array( |
$form['apachesolr_facet_missing'] = array( |
| 1142 |
'#type' => 'radios', |
'#type' => 'radios', |
| 1143 |
'#title' => t('Include a facet for missing'), |
'#title' => t('Include a facet for missing'), |
| 1159 |
$limits = variable_get('apachesolr_facet_query_limits', array()); |
$limits = variable_get('apachesolr_facet_query_limits', array()); |
| 1160 |
$limits[$module][$delta] = (int)$edit['apachesolr_facet_query_limit']; |
$limits[$module][$delta] = (int)$edit['apachesolr_facet_query_limit']; |
| 1161 |
variable_set('apachesolr_facet_query_limits', $limits); |
variable_set('apachesolr_facet_query_limits', $limits); |
| 1162 |
|
$sorts = variable_get('apachesolr_facet_query_sorts', array()); |
| 1163 |
|
$sorts[$module][$delta] = $edit['apachesolr_facet_query_sort']; |
| 1164 |
|
variable_set('apachesolr_facet_query_sorts', $sorts); |
| 1165 |
$initial = variable_get('apachesolr_facet_query_initial_limits', array()); |
$initial = variable_get('apachesolr_facet_query_initial_limits', array()); |
| 1166 |
$initial[$module][$delta] = (int)$edit['apachesolr_facet_query_initial_limit']; |
$initial[$module][$delta] = (int)$edit['apachesolr_facet_query_initial_limit']; |
| 1167 |
variable_set('apachesolr_facet_query_initial_limits', $initial); |
variable_set('apachesolr_facet_query_initial_limits', $initial); |