You are here

function template_preprocess_calendar_month in Calendar 7.3

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

Display a month view.

1 call to template_preprocess_calendar_month()
template_preprocess_calendar_mini in theme/theme.inc
Display a mini month view.

File

theme/theme.inc, line 19
Theme functions for the Calendar module.

Code

function template_preprocess_calendar_month(&$vars) {
  $view = $vars['view'];
  $rows = $vars['rows'];
  if (empty($rows)) {
    $rows = array();
    $day_names = array();
  }
  elseif (count($rows) > 1) {
    $day_names = array_shift($rows);
  }
  else {
    $day_names = $rows;
    $rows = array();
  }
  $month_rows = $rows;
  foreach ($rows as $weekno => $row) {

    // If this row is already rendered, don't do anything.
    if (!isset($row['data'])) {
      foreach ($row as $day => $data) {
        $cell = $data['data'];

        // If this cell is already rendered, like the weekno column,
        // move to the next item.
        if (!is_array($cell)) {
          $month_rows[$weekno][$day]['data'] = $cell;
          continue;
        }
        $data = $cell['datebox'];
        if ($cell['empty']) {
          $data .= $cell['empty'];
        }
        else {
          $data .= implode($cell['all_day']);
          foreach ($cell['items'] as $hour => $item) {
            $data .= implode($item);
          }
          $data .= $cell['link'];
        }
        if ($view->date_info->mini) {
          $month_rows[$weekno][$day]['data'] = $data;
        }
        else {
          $month_rows[$weekno][$day]['data'] = '<div class="inner">' . $data . '</div>';
        }
      }
    }
  }
  $vars['rows'] = $month_rows;
  $vars['day_names'] = $day_names;
  $vars['display_type'] = $view->date_info->granularity;
  $vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME);
  $vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME);
}