You are here

function calendar_plugin_style::calendar_build_week in Calendar 7.3

Build one week row.

2 calls to calendar_plugin_style::calendar_build_week()
calendar_plugin_style::calendar_build_month in includes/calendar_plugin_style.inc
Build one month.
calendar_plugin_style::render in includes/calendar_plugin_style.inc
Render the display in this style.

File

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

Class

calendar_plugin_style
Default style plugin to render an iCal feed.

Code

function calendar_build_week($check_month = FALSE) {
  $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
  $weekdays = calendar_untranslated_days($this->items, $this->view);
  $month = date_format($this->curday, 'n');
  $first_day = variable_get('date_first_day', 0);

  // Set up buckets
  $total_rows = 0;
  $multiday_buckets = array(
    array(),
    array(),
    array(),
    array(),
    array(),
    array(),
    array(),
  );
  $singleday_buckets = array(
    array(),
    array(),
    array(),
    array(),
    array(),
    array(),
    array(),
  );

  // move backwards to the first day of the week
  $day_wday = date_format($this->curday, 'w');
  date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
  $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
  for ($i = 0; $i < 7; $i++) {
    if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
      $class = strtolower($weekdays[$i]) . ' empty';
      $singleday_buckets[$i][][] = array(
        'entry' => theme('calendar_empty_day', array(
          'curday' => $curday_date,
          'view' => $this->view,
        )),
        'item' => NULL,
      );
    }
    else {
      $this
        ->calendar_build_week_day($i, $multiday_buckets, $singleday_buckets);
    }
    $total_rows = max(count($multiday_buckets[$i]) + 1, $total_rows);
    date_modify($this->curday, '+1 day');
    $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
  }
  $rows = array(
    'multiday_buckets' => $multiday_buckets,
    'singleday_buckets' => $singleday_buckets,
    'total_rows' => $total_rows,
  );
  return $rows;
}