You are here

function calendar_current_type in Calendar 7.2

Same name and namespace in other branches
  1. 6.2 calendar.module \calendar_current_type()
  2. 7 calendar.module \calendar_current_type()

Figure out which type of display to use, based on the current argument.

Return value

year, month, day, or week.

File

./calendar.module, line 174
Adds calendar filtering and displays to Views.

Code

function calendar_current_type($view) {
  if (!is_object($view) || !isset($view->argument) || !is_array($view->argument)) {
    if (!empty($view->date_info->default_display)) {
      return $view->date_info->default_display;
    }
    return FALSE;
  }
  $i = 0;
  $date_handler = new date_sql_handler();
  foreach ($view->argument as $argument) {
    if ($argument['id'] == 'date_argument') {
      $parts = array_keys($date_handler
        ->arg_parts($view->args[$i]));
      break;
    }
    $i++;
  }
  return array_pop($parts);
}