You are here

function template_preprocess_calendar_year in Calendar 7.3

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

Display a year view.

File

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

Code

function template_preprocess_calendar_year(&$vars) {

  // Construct a calendar for each month, adjusting the $view passed
  // to the theme so it will produce the right results.
  $view = clone $vars['view'];
  $year = date_format($view->date_info->min_date, 'Y');
  $view->date_info->style_with_weekno = FALSE;
  $rows = $vars['rows'];
  $months = array();
  foreach ($rows as $month => $month_rows) {
    $view->date_info->month = $month;
    $view->date_info->granularity = 'month';
    $view->date_info->mini = TRUE;
    $view->date_info->hide_nav = TRUE;
    $view->date_info->show_title = TRUE;
    $view->date_info->url = date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month));
    $view->date_info->min_date = new DateObject($view->date_info->year . '-' . date_pad($month) . '-01 00:00:00', date_default_timezone());
    $view->date_info->max_date = clone $view->date_info->min_date;
    date_modify($view->date_info->max_date, '+1 month');
    date_modify($view->date_info->max_date, '-1 second');
    $variables = array(
      'view' => $view,
      'options' => $vars['options'],
      'rows' => $month_rows,
    );
    $months[$month] = theme('calendar_mini', $variables);
  }
  $view->date_info->mini = FALSE;
  $vars['months'] = $months;
  $vars['view']->date_info->hide_nav = FALSE;
  $vars['view']->date_info->granularity = 'year';
  $vars['mini'] = FALSE;
}