You are here

function calendar_build_day in Calendar 6.2

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

Build the contents of a single day for the $rows results.

4 calls to calendar_build_day()
calendar_build_calendar in includes/calendar.inc
Build calendar
calendar_build_calendar in calendar_multiday/includes/calendar.inc
Build calendar
calendar_build_mini_week in calendar_multiday/includes/calendar.inc
Build one week row.
calendar_build_week in includes/calendar.inc
Build one week row.

File

includes/calendar.inc, line 143

Code

function calendar_build_day($curday, $view, $items) {
  $curday_date = date_format($curday, DATE_FORMAT_DATE);
  $selected = FALSE;
  $max_events = !empty($view->date_info->style_max_items) ? $view->date_info->style_max_items : 0;
  $types = array();
  $inner = array();
  $all_day = array();
  $empty = '';
  $link = '';
  $count = 0;
  foreach ($items as $date => $day) {
    if ($date == $curday_date) {
      $count = 0;
      $selected = TRUE;
      ksort($day);
      foreach ($day as $time => $hour) {
        foreach ($hour as $key => $item) {
          $count++;
          $types[$item->type] = $item;
          if (!$view->date_info->mini && ($max_events == CALENDAR_SHOW_ALL || $count <= $max_events || $count > 0 && $max_events == CALENDAR_HIDE_ALL)) {

            // Theme the item here unless this is a 'Day' or 'Week' view.
            // Day and week views need to do more processing before rendering
            // the item, so just past them the unrendered item.
            $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
            if ($item->calendar_all_day) {
              $all_day[] = in_array($view->date_info->calendar_type, array(
                'day',
                'week',
              )) ? $item : theme($theme, $item, $view);
            }
            else {
              $key = date_format($item->calendar_start_date, 'H:i:s');
              $inner[$key][] = in_array($view->date_info->calendar_type, array(
                'day',
                'week',
              )) ? $item : theme($theme, $item, $view);
            }
          }
        }
      }
    }
  }
  ksort($inner);
  if (empty($inner) && empty($all_day)) {
    $empty = theme('calendar_empty_day', $curday_date, $view);
  }

  // We have hidden events on this day, use the theme('calendar_multiple_') to show a link.
  if ($max_events != CALENDAR_SHOW_ALL && $count > 0 && $count > $max_events && $view->date_info->calendar_type != 'day' && !$view->date_info->mini) {
    if ($view->date_info->style_max_items_behavior == 'hide' || $max_events == CALENDAR_HIDE_ALL) {
      $all_day = array();
      $inner = array();
    }
    $link = theme('calendar_' . $view->date_info->calendar_type . '_multiple_node', $curday_date, $count, $view, $types);
  }
  $content = array(
    'date' => $curday_date,
    'datebox' => theme('calendar_datebox', $curday_date, $view, $items, $selected),
    'empty' => $empty,
    'link' => $link,
    'all_day' => $all_day,
    'items' => $inner,
  );
  return $content;
}