You are here

function calendar_plugin_display_attachment::display_granularity in Calendar 7

Same name and namespace in other branches
  1. 6.2 includes/calendar_plugin_display_attachment.inc \calendar_plugin_display_attachment::display_granularity()
  2. 7.2 includes/calendar_plugin_display_attachment.inc \calendar_plugin_display_attachment::display_granularity()

Inspect argument and view information to see which calendar period we should show. The argument tells us what to use if there is no value, the view args tell us what to use if there are values.

1 call to calendar_plugin_display_attachment::display_granularity()
calendar_plugin_display_attachment::attach_to in includes/calendar_plugin_display_attachment.inc
Attach only the appropriate displays for the current argument.

File

includes/calendar_plugin_display_attachment.inc, line 59
Views display plugin for the Calendar module.

Class

calendar_plugin_display_attachment
The plugin that handles calendar attachment displays.

Code

function display_granularity($display_id) {
  $arguments = $this->view
    ->get_items('argument', $display_id);
  $wildcard = '';
  $argument = '';
  $default_granularity = '';
  $i = 0;
  foreach ($arguments as $argument) {
    if ($argument['id'] == 'date_argument') {
      $pos = $i;
      $default_granularity = $argument['granularity'];
      $wildcard = $argument['wildcard'];
      $argument = !empty($this->view->args) && !empty($this->view->args[$pos]) ? $this->view->args[$pos] : '';
      break;
    }
    $i++;
  }

  // TODO Anything else we need to do for 'all' arguments?
  if ($argument == $wildcard) {
    $view_granularity = $default_granularity;
  }
  elseif (!empty($argument)) {
    module_load_include('inc', 'date_api', 'date_api_sql');
    $date_handler = new date_sql_handler();
    $view_granularity = $date_handler
      ->arg_granularity($argument);
  }
  else {
    $view_granularity = $default_granularity;
  }
  return $view_granularity;
}