Permalink
Browse files

added a couple checks

  • Loading branch information...
1 parent 897d2cc commit 3be09412ffbcc047e05bf5b48408477197105367 @DannyJoris DannyJoris committed Jul 26, 2012
Showing with 15 additions and 5 deletions.
  1. +2 −2 IslandoraSolrResults.inc
  2. +13 −3 islandora_solr_search.module
View
@@ -753,7 +753,7 @@ class IslandoraSolrResults {
}
// check if we need range filter form.
- if (variable_get('islandora_solr_range_slider_enabled', 0) == 1 AND array_key_exists($facet_key, $date_facets_arr)) {
+ if (variable_get('islandora_solr_range_slider_enabled', 0) == 1 AND array_key_exists($facet_key, $date_facets_arr) AND $solrQueryProcessor->solrResult->response->numFound > 0) {
// opening facet div // @TODO: this should go in theme function
$facet_output .='<div class="islandora_solr_search_range_slider">';
// add title
@@ -871,7 +871,7 @@ class IslandoraSolrResults {
}
// add datefilter
- if (variable_get('islandora_solr_date_filter_enabled', 0) == 1 AND array_key_exists($facet_key, $date_facets_arr) AND module_exists('jquery_ui')) {
+ if (variable_get('islandora_solr_date_filter_enabled', 0) == 1 AND array_key_exists($facet_key, $date_facets_arr) AND module_exists('jquery_ui') AND $solrQueryProcessor->solrResult->response->numFound > 0) {
// opening facet div // @TODO: this should go in theme function
$facet_output .='<div class="islandora_solr_search_date_filter">';
@@ -780,9 +780,19 @@ function islandora_solr_search_date_filter_form(&$form_state, $form_key, $solr_f
$filter_str = trim($filter_str, ']');
$filter_array = explode(' TO ', $filter_str);
- $from_default = (strpos($filter_array[0], '*') !== FALSE) ? '*' : format_date(strtotime(trim($filter_array[0])) + 1, 'custom', $format, 0);
- $to_default = (strpos($filter_array[1], '*') !== FALSE) ? '*' : format_date(strtotime(trim($filter_array[1])), 'custom', $format, 0);
- $filter_value = $from_str . ' - ' . $to_str;
+ // get timestamps
+ $from_unix = strtotime(trim($filter_array[0]));
+ $to_unix = strtotime(trim($filter_array[1]));
+
+ // only set default times if from date is lower than to date
+ if ($from_unix < $to_unix) {
+ $from_default = (strpos($filter_array[0], '*') !== FALSE) ? '*' : format_date($from_unix + 1, 'custom', $format, 0);
+ $to_default = (strpos($filter_array[1], '*') !== FALSE) ? '*' : format_date($to_unix, 'custom', $format, 0);
+ }
+ else {
+ $from_default = NULL;
+ $to_default = NULL;
+ }
}
}
}

0 comments on commit 3be0941

Please sign in to comment.