/**
  * Expects a timestamp and converts it to an ISO 8601 date as needed by Solr.
  *
  * Example date output format: 1995-12-31T23:59:59Z
  * The trailing "Z" designates UTC time and is mandatory
  *
  * @param array Array of values, an array because of multivalued fields
  * @return array Modified array of values
  */
 public function process(array $values)
 {
     $results = array();
     foreach ($values as $timestamp) {
         $results[] = Tx_Solr_Util::timestampToIso($timestamp);
     }
     return $results;
 }
Beispiel #2
0
 /**
  * Parses the given date range from a GET parameter and returns a Solr
  * date range filter.
  *
  * @param string $rangeFilter The range filter query string from the query URL
  * @param array $configuration Facet configuration
  * @return string Lucene query language filter to be used for querying Solr
  */
 public function decodeFilter($dateRange, array $configuration = array())
 {
     list($dateRangeStart, $dateRangeEnd) = explode(self::DELIMITER, $dateRange);
     $dateRangeEnd .= '59';
     // adding 59 seconds
     // TODO for PHP 5.3 use date_parse_from_format() / date_create_from_format() / DateTime::createFromFormat()
     $dateRangeFilter = '[' . Tx_Solr_Util::timestampToIso(strtotime($dateRangeStart));
     $dateRangeFilter .= ' TO ';
     $dateRangeFilter .= Tx_Solr_Util::timestampToIso(strtotime($dateRangeEnd)) . ']';
     return $dateRangeFilter;
 }