You are here

function theme_date_nav_title in Date 7

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.2 date_views/theme/theme.inc \theme_date_nav_title()

Theme the calendar title

1 theme call to theme_date_nav_title()
template_preprocess_date_navigation in date_views/theme/theme.inc
Preprocessor to construct back and next navigation from the date argument.

File

date_views/theme/theme.inc, line 110
Theme files for Date API.

Code

function theme_date_nav_title($params) {
  $granularity = $params['granularity'];
  $view = $params['view'];
  $link = !empty($params['link']) ? $params['link'] : FALSE;
  $format = !empty($params['format']) ? $params['format'] : NULL;
  switch ($granularity) {
    case 'year':
      $title = $view->date_info->year;
      $date_arg = $view->date_info->year;
      break;
    case 'month':
      $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'F Y' : 'F');
      $title = date_format_date($view->date_info->min_date, 'custom', $format);
      $date_arg = $view->date_info->year . '-' . date_pad($view->date_info->month);
      break;
    case 'day':
      $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'l, F j Y' : 'l, F j');
      $title = date_format_date($view->date_info->min_date, 'custom', $format);
      $date_arg = $view->date_info->year . '-' . date_pad($view->date_info->month) . '-' . date_pad($view->date_info->day);
      break;
    case 'week':
      $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'F j Y' : 'F j');
      $title = t('Week of @date', array(
        '@date' => date_format_date($view->date_info->min_date, 'custom', $format),
      ));
      $date_arg = $view->date_info->year . '-W' . date_pad($view->date_info->week);
      break;
  }
  if (!empty($view->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_real_url($view, $granularity, $date_arg, TRUE);
    return l($title, $url, array(
      'attributes' => $attributes,
    ));
  }
  else {
    return $title;
  }
}