You are here

function theme_date_nav_title in Date 7.2

Same name and namespace in other branches
  1. 8 date_views/theme/theme.inc \theme_date_nav_title()
  2. 6.2 theme/theme.inc \theme_date_nav_title()
  3. 6 theme/theme.inc \theme_date_nav_title()
  4. 7.3 date_views/theme/theme.inc \theme_date_nav_title()
  5. 7 date_views/theme/theme.inc \theme_date_nav_title()

Theme the calendar title.

1 theme call to theme_date_nav_title()
template_preprocess_date_views_pager in date_views/theme/theme.inc
Preprocess function for Date pager template.

File

date_views/theme/theme.inc, line 182
Theme files for Date Pager.

Code

function theme_date_nav_title($params) {
  $title = '';
  $granularity = $params['granularity'];
  $view = $params['view'];
  $date_info = $view->date_info;
  $link = !empty($params['link']) ? $params['link'] : FALSE;
  $format = !empty($params['format']) ? $params['format'] : NULL;
  $format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y');
  $format_without_year = variable_get('date_views_' . $granularity . '_format_without_year', 'l, F j');
  switch ($granularity) {
    case 'year':
      $title = $date_info->year;
      $date_arg = $date_info->year;
      break;
    case 'month':
      $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
      $title = date_format_date($date_info->min_date, 'custom', $format);
      $date_arg = $date_info->year . '-' . date_pad($date_info->month);
      break;
    case 'day':
      $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
      $title = date_format_date($date_info->min_date, 'custom', $format);
      $date_arg = $date_info->year;
      $date_arg .= '-';
      $date_arg .= date_pad($date_info->month);
      $date_arg .= '-';
      $date_arg .= date_pad($date_info->day);
      break;
    case 'week':
      $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
      $title = t('Week of @date', array(
        '@date' => date_format_date($date_info->min_date, 'custom', $format),
      ));
      $date_arg = $date_info->year . '-W' . date_pad($date_info->week);
      break;
  }
  if (!empty($date_info->mini) || $link) {

    // Month navigation titles are used as links in the mini view.
    $attributes = array(
      'title' => t('View full page month'),
    );
    $url = date_pager_url($view, $granularity, $date_arg, TRUE);
    return l($title, $url, array(
      'attributes' => $attributes,
    ));
  }
  else {
    return $title;
  }
}