You are here

public function SearchApiViewsHandlerArgumentDate::title in Search API 7

Computes the title this argument will assign the view, given the argument.

Return value

string A title fitting for the passed argument.

Overrides views_handler_argument::title

File

contrib/search_api_views/includes/handler_argument_date.inc, line 134
Contains the SearchApiViewsHandlerArgumentDate class.

Class

SearchApiViewsHandlerArgumentDate
Defines a contextual filter searching for a date or date range.

Code

public function title() {
  if (!empty($this->argument)) {
    if (empty($this->value)) {
      $this
        ->fillValue();
    }
    $dates = array();
    foreach ($this->value as $date) {
      $date_parts = explode(';', $date);
      $ts = $this
        ->getTimestamp($date_parts[0]);
      $datestr = format_date($ts, 'short');
      if (count($date_parts) > 1) {
        $ts = $this
          ->getTimestamp($date_parts[1]);
        $datestr .= ' - ' . format_date($ts, 'short');
      }
      if ($datestr) {
        $dates[] = $datestr;
      }
    }
    return $dates ? implode(', ', $dates) : check_plain($this->argument);
  }
  return check_plain($this->argument);
}