You are here

function calendar_plugin_style::calendar_build_day in Calendar 7.3

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

2 calls to calendar_plugin_style::calendar_build_day()
calendar_plugin_style::calendar_build_mini_week in includes/calendar_plugin_style.inc
Build one week row.
calendar_plugin_style::render in includes/calendar_plugin_style.inc
Render the display in this style.

File

includes/calendar_plugin_style.inc, line 835
Views style plugin for the Calendar module.

Class

calendar_plugin_style
Default style plugin to render an iCal feed.

Code

function calendar_build_day() {
  $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
  $selected = FALSE;
  $max_events = !empty($this->date_info->style_max_items) ? $this->date_info->style_max_items : 0;
  $ids = array();
  $inner = array();
  $all_day = array();
  $empty = '';
  $link = '';
  $count = 0;
  foreach ($this->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++;
          if (isset($item->type)) {
            $ids[$item->type] = $item;
          }
          if (empty($this->date_info->mini) && ($max_events == CALENDAR_SHOW_ALL || $count <= $max_events || $count > 0 && $max_events == CALENDAR_HIDE_ALL)) {
            if ($item->calendar_all_day) {
              $item->is_multi_day = TRUE;
              $all_day[] = $item;
            }
            else {
              $key = date_format($item->calendar_start_date, 'H:i:s');
              $inner[$key][] = $item;
            }
          }
        }
      }
    }
  }
  ksort($inner);
  if (empty($inner) && empty($all_day)) {
    $empty = theme('calendar_empty_day', array(
      'curday' => $curday_date,
      'view' => $this->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 && $this->date_info->calendar_type != 'day' && !$this->date_info->mini) {
    if ($this->date_info->style_max_items_behavior == 'hide' || $max_events == CALENDAR_HIDE_ALL) {
      $all_day = array();
      $inner = array();
    }
    $link = theme('calendar_' . $this->date_info->calendar_type . '_multiple_node', array(
      'curday' => $curday_date,
      'count' => $count,
      'view' => $this->view,
      'ids' => $ids,
    ));
  }
  $content = array(
    'date' => $curday_date,
    'datebox' => theme('calendar_datebox', array(
      'date' => $curday_date,
      'view' => $this->view,
      'items' => $this->items,
      'selected' => $selected,
    )),
    'empty' => $empty,
    'link' => $link,
    'all_day' => $all_day,
    'items' => $inner,
  );
  return $content;
}