function template_preprocess_calendar_main in Calendar 6.2
Same name in this branch
- 6.2 theme/theme.inc \template_preprocess_calendar_main()
- 6.2 calendar_multiday/theme/theme.inc \template_preprocess_calendar_main()
Same name and namespace in other branches
- 7 theme/theme.inc \template_preprocess_calendar_main()
- 7 calendar_multiday/theme/theme.inc \template_preprocess_calendar_main()
- 7.2 theme/theme.inc \template_preprocess_calendar_main()
- 7.2 calendar_multiday/theme/theme.inc \template_preprocess_calendar_main()
Display a calendar navigation and links
File
- calendar_multiday/
theme/ theme.inc, line 5
Code
function template_preprocess_calendar_main(&$vars) {
require_once './' . drupal_get_path('module', 'calendar_multiday') . '/includes/calendar.inc';
$view = $vars['view'];
$result = (array) $view->result;
$options = $view->style_plugin->options;
$handler = $view->style_plugin;
$vars['display_type'] = $view->date_info->granularity;
$vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME);
$vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME);
$view->date_info->mini = isset($view->date_info->mini) ? $view->date_info->mini : $view->date_info->granularity == 'year';
$url = $view
->get_url();
$view->date_info->url = $url;
$arg = $view->date_info->date_arg;
$displays = $view->date_info->display_types;
// Set up the links to other calendar views.
$current_date = $view->date_info->min_date;
if (!empty($date->info->day)) {
$current_date = date_make_date($date_info->date_arg . ' 00:00:00');
}
elseif (!empty($view->date_info->week)) {
$week = date_week_range($view->date_info->week, $view->date_info->year);
$current_date = $week[0];
}
elseif (!empty($view->date_info->month)) {
$current_date = date_make_date($view->date_info->year . '-' . date_pad($view->date_info->month) . '-01 00:00:00');
}
else {
$current_date = date_make_date($view->date_info->year . '-01-01 00:00:00');
}
if (empty($view->date_info->month) || $view->date_info->month == $view->argument['date_argument']->options['wildcard']) {
$view->date_info->month = date_format($current_date, 'm');
}
if (empty($view->date_info->day) || $view->date_info->day == $view->argument['date_argument']->options['wildcard']) {
$view->date_info->day = date_format($current_date, 'd');
}
if (empty($view->date_info->week) || $view->date_info->week == $view->argument['date_argument']->options['wildcard']) {
$view->date_info->week = date_week($view->date_info->year . '-' . date_pad($view->date_info->month) . '-' . date_pad($view->date_info->day));
}
$calendar_links = array();
$base = array(
'attributes' => array(
'rel' => 'nofollow',
),
);
if (!empty($displays['year'])) {
$calendar_links[] = $base + array(
'title' => date_t('Year', 'datetime'),
'href' => date_real_url($view, 'year'),
);
}
if (!empty($displays['month'])) {
$calendar_links[] = $base + array(
'title' => date_t('Month', 'datetime'),
'href' => date_real_url($view, 'month'),
);
}
if (!empty($displays['week'])) {
$calendar_links[] = $base + array(
'title' => date_t('Week', 'datetime'),
'href' => date_real_url($view, 'week'),
);
}
if (!empty($displays['day'])) {
$calendar_links[] = $base + array(
'title' => date_t('Day', 'datetime'),
'href' => date_real_url($view, 'day'),
);
}
$vars['calendar_links'] = $calendar_links;
// If the Date Popup module is enabled, add a popup date selector.
if (!empty($view->date_info->calendar_popup)) {
$vars['calendar_popup'] = '<div class="clear-block">' . calendar_date_select($view) . '</div>';
}
// If an 'Add new ... link is provided, add it here.
// the query will bring the user back here after adding the node.
if (!empty($view->date_info->calendar_date_link) && user_access('create ' . $view->date_info->calendar_date_link . ' content')) {
$name = node_get_types('name', $view->date_info->calendar_date_link);
$href = 'node/add/' . str_replace('_', '-', $view->date_info->calendar_date_link);
$query = 'destination=' . $view->date_info->url;
$vars['calendar_links'][] = $base + array(
'title' => t('Add+'),
'href' => $href,
'query' => $query,
);
}
$vars['view'] = $view;
$vars['mini'] = !empty($view->date_info->mini);
$vars['block'] = !empty($view->date_info->block);
$vars['block_identifier'] = date_block_identifier($view);
}