Commit 9da52a00 authored by Eric Bremner's avatar Eric Bremner
Browse files

Merge remote-tracking branch 'origin/ISTWCMS-2740-calendar-work' into 7.x-2.x

parents 0b94b83b d31b7ec0
<?php
/**
* @file
* Template file for the example display.
*
* Variables available:
* - $plugin: The pager plugin object. This contains the view as well as a lot.
*
* $nav_title
* The formatted title for this view. In the case of block
* views, it will be a link to the full view, otherwise it will
* be the formatted name of the year, month, day, or week.
*
* $prev_url
* $next_url
* Urls for the previous and next calendar pages. The links are
* composed in the template to make it easier to change the text,
* add images, etc.
*
* $prev_options
* $next_options
* Query strings and other options for the links that need to
* be used in the l() function, including rel=nofollow.
*
* $block:
* Whether or not this view is in a block.
*
* $view
* The view object for this navigation.
*
* $pager_prefix
* Additional information that might be added by overriding
* template_process_date_views_pager().
*
* $extra_classes
* Extra classes for the wrapper, if any.
*/
// Ensure there is always a visible header.
if ((string) $nav_title === '') {
$nav_title = 'Current month';
}
?>
<?php print !empty($pager_prefix) ? $pager_prefix : ''; ?>
<div class="date-nav-wrapper clearfix<?php print !empty($extra_classes) ? $extra_classes : ''; ?>">
<div class="date-nav">
<div class="date-prev">
<?php if (!empty($prev_url)) : ?>
<?php
$pos = strpos($prev_url, '?mini=');
$pos2 = strpos($prev_url, '&mini=');
if ($pos !== FALSE && !$mini) {
$prev_url_array = explode("?", $prev_url);
$prev_url = $prev_url_array[0];
}
if ($pos2 !== FALSE && !$mini) {
$prev_date = explode("?", $prev_url);
$prev_date_array = explode("/", $prev_date[0]);
$prev_url_array = explode("mini=", $prev_url);
$prev_url = $prev_url_array[0] . 'mini=' . end($prev_date_array);
}
?>
<?php print l('&laquo;' . ($mini ? '' : t('Previous', array(), array('context' => 'date_nav'))), $prev_url, $prev_options); ?>
<?php endif; ?>
</div>
<div class="date-heading">
<?php if ($mini) {?>
<h3><?php print $nav_title; ?></h3>
<?php } else {?>
<h2><?php print $nav_title; ?></h2>
<?php }?>
</div>
<div class="date-next">
<?php if (!empty($next_url)) : ?>
<?php
$pos = strpos($next_url, '?mini=');
$pos2 = strpos($prev_url, '&mini=');
if ($pos !== FALSE && !$mini) {
$next_url_array = explode("?", $next_url);
$next_url = $next_url_array[0];
}
if ($pos2 !== FALSE && !$mini) {
$next_date = explode("?", $next_url);
$next_date_array = explode("/", $next_date[0]);
$next_url_array = explode("mini=", $next_url);
$next_url = $next_url_array[0] . 'mini=' . end($next_date_array);
}
?>
<?php print l(($mini ? '' : t('Next', array(), array('context' => 'date_nav'))) . ' &raquo;', $next_url, $next_options); ?>
<?php endif; ?>
</div>
</div>
</div>
......@@ -971,15 +971,6 @@ function uw_ct_event_theme_registry_alter(&$theme_registry) {
'path' => drupal_get_path('module', 'uw_ct_event') . '/templates',
'type' => 'theme',
);
$theme_registry['date_views_pager'] = array(
'template' => 'date-views-pager',
'path' => drupal_get_path('module', 'uw_ct_event') . '/templates',
'theme path' => drupal_get_path('module', 'date') . '/date_views',
'type' => 'module',
'preprocess functions' => array(
'template_preprocess_uw_ct_event_date_views_pager',
),
);
$theme_registry['calendar_datebox'] = array(
'template' => 'calendar-datebox',
'path' => drupal_get_path('module', 'uw_ct_event') . '/templates',
......@@ -1146,7 +1137,7 @@ function uw_ct_event_preprocess_html(&$variables) {
$variables['page']['#children'] = str_replace($search, $replace, $variables['page']['#children']);
}
if (isset($path[0]) && $path[0] == 'events') {
if (isset($path[0]) && $path[0] == 'events' && $path[1] !== 'calendar') {
$type_tid = uw_ct_event_get_tid_from_machine_name('uw_event_type');
$using_type_tid = uw_ct_event_get_using_taxonomy_term('uw_event_type');
......@@ -1377,204 +1368,6 @@ function template_preprocess_uw_ct_event_calendar_mini(&$vars) {
$vars['view'] = $view;
}
/**
* Preprocess function for Date pager template.
*
* Copy from Date theme.inc template_preprocess_date_views_pager
* In order to change mini clendar title to month and
* year (Novemver 2013)
*/
function template_preprocess_uw_ct_event_date_views_pager(&$vars) {
// TODO: use hook_preprocess_module_date_views_pager, not custom template.
ctools_add_css('date_views', 'date_views');
$plugin = $vars['plugin'];
$input = $vars['input'];
$view = $plugin->view;
$vars['nav_title'] = '';
$vars['next_url'] = '';
$vars['prev_url'] = '';
if (empty($view->date_info) || empty($view->date_info->min_date)) {
return;
}
$date_info = $view->date_info;
// Make sure we have some sort of granularity.
$granularity = !empty($date_info->granularity) ? $date_info->granularity : 'month';
$pos = $date_info->date_arg_pos;
if (!empty($input)) {
$id = $plugin->options['date_id'];
if (array_key_exists($id, $input) && !empty($input[$id])) {
$view->args[$pos] = $input[$id];
}
}
$next_args = $view->args;
$prev_args = $view->args;
$min_date = $date_info->min_date;
$max_date = $date_info->max_date;
// Set up the pager link format. Setting the block identifier
// will force pager style links.
if ((isset($date_info->date_pager_format) && $date_info->date_pager_format != 'clean') || !empty($date_info->mini)) {
if (empty($date_info->block_identifier)) {
$date_info->block_identifier = $date_info->pager_id;
}
}
if (empty($date_info->hide_nav)) {
$prev_date = clone($min_date);
date_modify($prev_date, '-1 ' . $granularity);
$next_date = clone($min_date);
date_modify($next_date, '+1 ' . $granularity);
$format = array('year' => 'Y', 'month' => 'Y-m', 'day' => 'Y-m-d');
switch ($granularity) {
case 'week':
$next_week = date_week(date_format($next_date, 'Y-m-d'));
$prev_week = date_week(date_format($prev_date, 'Y-m-d'));
$next_arg = date_format($next_date, 'Y-\W') . date_pad($next_week);
$prev_arg = date_format($prev_date, 'Y-\W') . date_pad($prev_week);
break;
default:
$next_arg = date_format($next_date, $format[$granularity]);
$prev_arg = date_format($prev_date, $format[$granularity]);
}
$next_path = str_replace($date_info->date_arg, $next_arg, $date_info->url);
$prev_path = str_replace($date_info->date_arg, $prev_arg, $date_info->url);
$next_args[$pos] = $next_arg;
$prev_args[$pos] = $prev_arg;
$vars['next_url'] = date_pager_url($view, NULL, $next_arg);
$vars['prev_url'] = date_pager_url($view, NULL, $prev_arg);
$vars['next_options'] = $vars['prev_options'] = array();
}
else {
$next_path = '';
$prev_path = '';
$vars['next_url'] = '';
$vars['prev_url'] = '';
$vars['next_options'] = $vars['prev_options'] = array();
}
// Check whether navigation links would point to
// a date outside the allowed range.
if (!empty($next_date) && !empty($vars['next_url']) && date_format($next_date, 'Y') > $date_info->limit[1]) {
$vars['next_url'] = '';
}
if (!empty($prev_date) && !empty($vars['prev_url']) && date_format($prev_date, 'Y') < $date_info->limit[0]) {
$vars['prev_url'] = '';
}
$vars['prev_options'] += array('attributes' => array());
$vars['next_options'] += array('attributes' => array());
$prev_title = '';
$next_title = '';
// Build next/prev link titles.
switch ($granularity) {
case 'year':
$prev_title = t('Navigate to previous year');
$next_title = t('Navigate to next year');
break;
case 'month':
$prev_title = t('Navigate to previous month');
$next_title = t('Navigate to next month');
break;
case 'week':
$prev_title = t('Navigate to previous week');
$next_title = t('Navigate to next week');
break;
case 'day':
$prev_title = t('Navigate to previous day');
$next_title = t('Navigate to next day');
break;
}
$vars['prev_options']['attributes'] += array('title' => $prev_title);
$vars['next_options']['attributes'] += array('title' => $next_title);
// Add nofollow for next/prev links.
$vars['prev_options']['attributes'] += array('rel' => 'nofollow');
$vars['next_options']['attributes'] += array('rel' => 'nofollow');
// Need this so we can use '&laquo;' or images in the links.
$vars['prev_options'] += array('html' => TRUE);
$vars['next_options'] += array('html' => TRUE);
$link = FALSE;
// Month navigation titles are used as links in the block view.
if (!empty($date_info->mini) && $granularity == 'month') {
$link = TRUE;
}
$params = array(
'granularity' => $granularity,
'view' => $view,
'link' => $link,
);
$nav_title = uw_ct_event_date_nav_title($params);
$vars['nav_title'] = $nav_title;
$vars['mini'] = !empty($date_info->mini);
}
/**
* Event content type the calendar title.
*/
function uw_ct_event_date_nav_title($params) {
$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;
switch ($granularity) {
case 'year':
$title = $date_info->year;
$date_arg = $date_info->year;
break;
case 'month':
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'F Y' : 'F Y');
$title = date_format_date($date_info->min_date, 'custom', $format);
// $date_arg = $date_info->year . '-' . date_pad($date_info->month);.
$date_arg = $date_info->year . '-' . $date_info->month;
break;
case 'day':
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'l, F j, Y' : 'l, F j');
$title = date_format_date($date_info->min_date, 'custom', $format);
// $date_arg = $date_info->year . '-' .
// date_pad($date_info->month) .
// '-' . date_pad($date_info->day);.
$date_arg = $date_info->year . '-' . $date_info->month . '-' . $date_info->day;
break;
case 'week':
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'F j, Y' : 'F j');
$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);
// Replace 2013-01 with 2013-1.
$url_parts = explode('/', $url);
array_pop($url_parts);
array_push($url_parts, $date_arg);
$url = implode('/', $url_parts);
return l($title, $url, array('attributes' => $attributes));
}
else {
return $title;
}
}
/**
* Format an empty day on a calendar.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment