/** * Generate a Solr version of a lower and upper date range. */ protected function generateRange($range, $field = NULL) { if ($range['date_range_start_op'] == 'NOW') { $lower = "NOW/DAY"; } else { $s = (int) abs($range['date_range_start_amount']) > 1 ? 'S' : ''; $lower = "NOW/" . $this->unitDivisor($range['date_range_start_unit']) . $range['date_range_start_op'] . $range['date_range_start_amount'] . $range['date_range_start_unit'] . $s; } if ($range['date_range_end_op'] == 'NOW') { $upper = "NOW/DAY+1DAY"; } else { $s = (int) abs($range['date_range_end_amount']) > 1 ? 'S' : ''; $upper = "NOW/" . $this->unitDivisor($range['date_range_end_unit']) . $range['date_range_end_op'] . $range['date_range_end_amount'] . $range['date_range_end_unit'] . $s; } if (!empty($field) && !SolrBaseQuery::validFilterValue($field . ":[{$lower} TO {$upper}]")) { $lower = "NOW/DAY"; $upper = "NOW/DAY+1DAY"; } return array($lower, $upper); }
/** * Constructor * * @param $env_id * The environment where you are calling the query from. Typically the default environment. * * @param $solr * An instantiated DrupalApacheSolrService Object. * Can be instantiated from apachesolr_get_solr(). * * @param $params * Array of params to initialize the object (typically 'q' and 'fq'). * * @param $sortstring * Visible string telling solr how to sort - added to GET query params. * * @param $base_path * The search base path (without the keywords) for this query, without trailing slash. */ public function __construct($name, $solr, array $params = array(), $sortstring = '', $base_path = '') { parent::__construct($name, $solr, $params, $sortstring, $base_path); }