function facetapi_next_date_gap_get in Facet API 6
Return a date gap one increment smaller than the one passed.
Parameters
$gap: A string containing the gap, see FACETAPI_DATE_* constants for valid values.
$min_gap: A string containing the the minimum gap that can be returned, defaults to FACETAPI_DATE_SECOND. This is useful for defining the smallest increment that can be used in a date drilldown.
Return value
A string containing the smaller date gap, NULL if there is no smaller gap. See FACETAPI_DATE_* constants for valid values.
2 calls to facetapi_next_date_gap_get()
- FacetapiLuceneapiAdapter::fetchDate in contrib/
facetapi_luceneapi/ facetapi_luceneapi.adapter.inc - Fetches data from facets that filter results by date ranges.
- facetapi_apachesolr_date_range in contrib/
facetapi_apachesolr/ facetapi_apachesolr.module - Gets the range of dates we are using.
File
- ./
facetapi.module, line 1101 - An abstracted facet API that can be used by various search backens.
Code
function facetapi_next_date_gap_get($gap, $min_gap = FACETAPI_DATE_SECOND) {
// Array of numbers used to determine whether the next gap is smaller than
// the minimum gap allowed in the drilldown.
$gap_numbers = array(
FACETAPI_DATE_YEAR => 6,
FACETAPI_DATE_MONTH => 5,
FACETAPI_DATE_DAY => 4,
FACETAPI_DATE_HOUR => 3,
FACETAPI_DATE_MINUTE => 2,
FACETAPI_DATE_SECOND => 1,
);
// Gets gap numbers for both the gap and minimum gap, checks if the next gap
// is within the limit set by the $min_gap parameter.
$gap_num = isset($gap_numbers[$gap]) ? $gap_numbers[$gap] : 6;
$min_num = isset($gap_numbers[$min_gap]) ? $gap_numbers[$min_gap] : 1;
if ($gap_num > $min_num) {
return array_search($gap_num - 1, $gap_numbers);
}
else {
return $min_gap;
}
}