1 date.theme.inc | theme_date_nav_title($params) |
Theme the calendar title.
Related topics
File
- core/
modules/ date/ date.theme.inc, line 655 - Theme and preprocess functions for output by Date module.
Code
function theme_date_nav_title($params) {
$date_views_config = config('date_views.settings');
$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 = $date_views_config->get("date_views_{$granularity}_format_with_year");
$format_without_year = $date_views_config->get("date_views_{$granularity}_format_without_year");
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;
}
}