예제 #1
0
 /**
  * Format a single filter for use in getFilterList().
  *
  * @param string $field     Field name
  * @param string $value     Field value
  * @param string $operator  Operator (AND/OR/NOT)
  * @param bool   $translate Should we translate the label?
  *
  * @return array
  */
 protected function formatFilterListEntry($field, $value, $operator, $translate)
 {
     if (!in_array($field, $this->newItemsFacets) || !($range = Utils::parseRange($value))) {
         $result = parent::formatFilterListEntry($field, $value, $operator, $translate);
         return $this->formatDateRangeFilterListEntry($result, $field, $value);
     }
     $domain = $this->getOptions()->getTextDomainForTranslatedFacet($field);
     list($from, $fromDate) = $this->formatNewItemsDateForDisplay($range['from'], $domain);
     list($to, $toDate) = $this->formatNewItemsDateForDisplay($range['to'], $domain);
     $ndash = html_entity_decode('–', ENT_NOQUOTES, 'UTF-8');
     if ($fromDate && $toDate) {
         $displayText = $from ? "{$from} {$ndash}" : $ndash;
         $displayText .= $to ? " {$to}" : '';
     } else {
         $displayText = $from;
         $displayText .= $to ? " {$ndash} {$to}" : '';
     }
     return compact('value', 'displayText', 'field', 'operator');
 }