You are here

function calendar_build_calendar in Calendar 7.2

Same name in this branch
  1. 7.2 includes/calendar.inc \calendar_build_calendar()
  2. 7.2 calendar_multiday/includes/calendar.inc \calendar_build_calendar()
Same name and namespace in other branches
  1. 5.2 calendar.inc \calendar_build_calendar()
  2. 6.2 includes/calendar.inc \calendar_build_calendar()
  3. 6.2 calendar_multiday/includes/calendar.inc \calendar_build_calendar()
  4. 7 includes/calendar.inc \calendar_build_calendar()
  5. 7 calendar_multiday/includes/calendar.inc \calendar_build_calendar()

Build calendar

Parameters

unknown_type $view:

unknown_type $items:

Return value

themed table

2 calls to calendar_build_calendar()
template_preprocess_calendar in theme/theme.inc
Display a view as a calendar.
template_preprocess_calendar in calendar_multiday/theme/theme.inc
Display a view as a calendar.

File

includes/calendar.inc, line 14
Calendar building functions for the Calendar module.

Code

function calendar_build_calendar($view, $items) {

  // Remove nodes outside the selected date range.
  $values = array();
  foreach ($items as $delta => $item) {
    if (empty($item->calendar_start_date) || empty($item->calendar_end_date)) {
      continue;
    }
    $item_start = date_format($item->calendar_start_date, DATE_FORMAT_DATE);
    $item_end = date_format($item->calendar_end_date, DATE_FORMAT_DATE);
    if ($item_start >= $view->date_info->min_date_date && $item_start <= $view->date_info->max_date_date || $item_end >= $view->date_info->min_date_date && $item_end <= $view->date_info->max_date_date) {
      $values[$item_start][date_format($item->calendar_start_date, 'H:i:s')][] = $item;
    }
  }
  $items = $values;
  ksort($items);
  $rows = array();
  $curday = clone $view->date_info->min_date;
  switch ($view->calendar_type) {
    case 'year':
      $rows = array();
      $view->date_info->mini = TRUE;
      for ($i = 1; $i <= 12; $i++) {
        $rows[$i] = calendar_build_month($curday, $view, $items);
      }
      $view->date_info->mini = FALSE;
      break;
    case 'month':
      $rows = calendar_build_month($curday, $view, $items);
      break;
    case 'day':
      $rows = calendar_build_day($curday, $view, $items);
      break;
    case 'week':
      $rows = calendar_build_week($curday, $view, $items);

      // Merge the day names in as the first row.
      $rows = array_merge(array(
        calendar_week_header($view),
      ), $rows);
      break;
  }
  return $rows;
}