You are here

function template_preprocess_calendar_year in Calendar 7

Same name in this branch
  1. 7 theme/theme.inc \template_preprocess_calendar_year()
  2. 7 calendar_multiday/theme/theme.inc \template_preprocess_calendar_year()
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.3 theme/theme.inc \template_preprocess_calendar_year()
  5. 7.2 theme/theme.inc \template_preprocess_calendar_year()
  6. 7.2 calendar_multiday/theme/theme.inc \template_preprocess_calendar_year()

Display a year view.

File

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

Code

function template_preprocess_calendar_year(&$vars) {

  // Add in all the $vars added by the main calendar preprocessor.
  $vars['view']->date_info->style_with_weekno = FALSE;
  template_preprocess_calendar($vars);

  // Get the url of the year view and remove the year argument from it.
  // TODO clean this up in case there is another arg that looks like
  // the year to make sure only the year gets removed.
  $view = $vars['view'];
  $year = date_format($view->date_info->min_date, 'Y');

  // Construct a calendar for each month, adjusting the $view passed
  // to the theme so it will produce the right results.
  $view = clone $vars['view'];
  $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_real_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);
  }
  $vars['months'] = $months;
  $vars['view']->date_info->hide_nav = FALSE;
  $vars['view']->date_info->granularity = 'year';
}