You are here

function calendar_build_day in Calendar 5.2

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

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

2 calls to calendar_build_day()
calendar_build_calendar in ./calendar.inc
Build calendar
calendar_build_week in ./calendar.inc
Build one week row.

File

./calendar.inc, line 343
All the code used while processing a calendar is stored in this file and is included only when needed.

Code

function calendar_build_day($curday, $view, $items, $params) {
  $curday_date = date_format($curday, DATE_FORMAT_DATE);
  $inner = '';
  $selected = FALSE;
  $max_events = variable_get('calendar_limit_' . $view->name, 5);
  $view->style_max_items_behavior = variable_get('calendar_limit_behavior_' . $view->name, 'more');
  $types = array();
  foreach ($items as $date => $day) {
    if ($date == $curday_date) {
      $count = 0;
      $selected = TRUE;
      ksort($day);
      foreach ($day as $time) {
        foreach ($time as $item) {
          $count++;
          if (!$view->mini && ($max_events == 0 || $max_events > 0 && $count <= $max_events || $view->calendar_type == 'day')) {
            $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_node_' . $view->calendar_type;
            $inner .= theme($theme, $item, $view);
          }
          $types[$item->type] = $item;
        }
      }
    }
  }
  if (empty($inner) && !$view->mini) {
    $inner = theme('calendar_empty_day');
  }

  // we have too many events on this day. use the theme('calendar_multiple_')
  if (!$view->mini && !($max_events == 0 || $max_events > 0 && $count <= $max_events || $view->calendar_type == 'day')) {
    if ($view->style_max_items_behavior == 'hide') {
      $inner = '';
    }
    $inner .= theme('calendar_multiple_node_' . $view->calendar_type, $curday_date, $count, $view, $types);
  }
  $content = theme('calendar_date_box', $curday_date, $view, $items, $params, $selected) . $inner;
  return $content;
}