You are here

function theme_calendar_views_calendar in Calendar 5.2

Calendar Views plugin theme, overrides default views theme to create a calendar view.

File

./calendar.theme, line 27

Code

function theme_calendar_views_calendar(&$view, &$items, $type) {

  // It is not safe to display the calendar theme if it is not a calendar
  // view, lots of important information will be missing.
  if (!calendar_is_calendar($view)) {
    return;
  }

  // If there are args before the calendar args and they don't have values
  // we don't have enough information to create calendar navigation links
  // so exit here.
  $pos = calendar_arg_positions($view);
  if ($pos[0] > count($view->real_args)) {
    return;
  }
  require_once './' . drupal_get_path('module', 'calendar') . '/calendar.inc';
  $view->real_url = calendar_real_url($view, $view->args);
  $view->page_url = calendar_page_url($view);

  // Bail out here to display regular views views instead of calendar.
  switch ($view->calendar_display) {
    case 'table':
      $view->table_header = _views_construct_header($view, _views_get_fields());
      $out = theme('calendar_view_table', $view, $items, $type);
      break;
    case 'teasers':
      $out = theme('calendar_view_teasers', $view, $items, $type);
      break;
    case 'nodes':
      $out = theme('calendar_view_nodes', $view, $items, $type);
      break;
    case 'list':
      $out = theme('calendar_view_list', $view, $items, $type);
      break;
    default:
      $params['stripe'] = 'stripe';

      // Set to TRUE to see week numbers in each row.
      $formats = calendar_get_formats($view);
      if ($view->build_type != 'block' && in_array($view->calendar_type, array(
        'month',
        'week',
      ))) {
        $params['with_weekno'] = variable_get('calendar_weekno_' . $view->name, 1);
      }
      else {
        $params['with_weekno'] = FALSE;
      }
      $out = calendar_build_calendar($view, $items, $params);
  }
  if (empty($items)) {
    return $view->page_empty . $out;
  }
  else {
    return $out;
  }
}