Skip to content
Snippets Groups Projects
Commit dba17126 authored by Karen Stevenson's avatar Karen Stevenson
Browse files

#269920 Fix breadcrumb on year view. #238369 Clean up breadcrumb when using...

#269920 Fix breadcrumb on year view. #238369 Clean up breadcrumb when using calendar with other arguments. #282008 Fix back/next links on year view to omit mini links.
parent 83e03278
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@ Views Calendar 5.x
Version 2.0 dev
===============
- #269920 Fix breadcrumb on year view.
- #238369 Clean up breadcrumb when using calendar with other arguments.
- #282008 Fix back/next links on year view to omit mini links.
- Tweaked the jcalendar popup html and css a bit to keep title from popping out of the box in some themes.
- Bring the 5.2 and 6.2 calendar themes into alignment so both use the same styles and themes, including tableless back/next navigation links and themeable headers.
- #283902 Make sure date_format() isn't used on items with no calendar dates.
......
......@@ -664,35 +664,37 @@ function calendar_get_paths($view) {
date_modify($next_date, '+1 '. $view->calendar_type);
// build an array of the current path and its parts
$real_url = calendar_real_url($view, $view->real_args);
$buried_args = calendar_args_in_url($view);
$i = 0;
$path[$i] = array(
'path' => $view->url,
$path[0] = array(
'path' => $real_url,
'type' => 'url',
);
$start_calendar = FALSE;
foreach ($view->argument as $delta => $arg) {
if ($view->args[$delta]) {
$i++;
if ($delta < $buried_args) {
continue;
}
if (substr($arg['type'], 0, 8) == 'calendar') {
$start_calendar = TRUE;
$pathtype = str_replace('calendar_', '', $arg['type']);
$path[$i] = array(
$path[$delta + 1] = array(
'path' => $view->args[$delta] != CALENDAR_EMPTY_ARG ? $view->args[$delta] : CALENDAR_EMPTY_ARG,
'type' => $pathtype,
);
}
// Args prior to the calendar arg are already reflected in the $real_url.
elseif ($start_calendar) {
$path[$delta + 1] = array(
'path' => $view->args[$delta],
'type' => '',
);
}
}
// if there are other arguments after the view arguments, add them to the
// navigation links
while($i < sizeof($view->args)) {
$i++;
$path[$i] = array(
'path' => $view->args[intval($i - 1)],
'type' => '',
);
}
// reverse through the path, creating a $nextpath and $prevpath arrays
$formats = array('day' => 'j', 'month' => 'm', 'year' => 'Y', 'week' => 'W');
for ($x = $i; $x >= 0; $x--) {
for ($x = $delta + 1; $x >= 0; $x--) {
$type = $path[$x]['type'];
if (in_array($type, array_keys($formats)) && $path[$x]['path'] != CALENDAR_EMPTY_ARG) {
if ($type != 'week') {
......@@ -717,7 +719,7 @@ function calendar_get_paths($view) {
}
}
// Non-date path elements just get passed through.
else {
elseif (!empty($path[$x]['path'])) {
$nextpath[$x] = $path[$x]['path'];
$prevpath[$x] = $path[$x]['path'];
}
......
......@@ -253,6 +253,13 @@ function calendar_views_query_alter(&$query, &$view) {
&& $view->argument[0]['argdefault'] != 2)) {
return;
}
// If there are args before the calendar args and they don't have values
// we don't have enough information to create calendar navigation links
// so exit here.
$pos = calendar_arg_positions($view);
if ($pos[0] > count($view->args)) {
return;
}
// Check if a new date has been selected and if so redirect.
if (isset($_POST['calendar_goto'])) {
......@@ -449,7 +456,7 @@ function calendar_real_url($view, $args) {
foreach ($parts as $delta => $part) {
// If one of the args is buried in the url, add it here and adjust
// the delta values we'll compare the calendar arg positions to.
if (in_array($part, array('$arg', '$node', '$user', '$group'))) {
if (substr($part, 0, 1) == '$') {
$parts[$delta] = array_shift($args);
$bump++;
}
......@@ -462,6 +469,16 @@ function calendar_real_url($view, $args) {
return implode('/', $parts);
}
/**
* Count the args in the url
*
* Looking for a pattern like '/$'.
*/
function calendar_args_in_url($view) {
ereg('\/\$', $view->url, $regs);
return count($regs);
}
/**
* Pick up filter and sort info from url.
*/
......
......@@ -30,6 +30,13 @@ function theme_calendar_views_calendar(&$view, &$items, $type) {
if (!calendar_is_calendar($view)) {
return;
}
// If there are args before the calendar args and they don't have values
// we don't have enough information to create calendar navigation links
// so exit here.
$pos = calendar_arg_positions($view);
if ($pos[0] > count($view->real_args)) {
return;
}
include_once(drupal_get_path('module', 'calendar') .'/calendar.inc');
if ($type == 'block' || !calendar_is_calendar_arg($view)) {
$view->calendar_type = 'month';
......@@ -190,13 +197,22 @@ function theme_calendar_view_nodes($view, $nodes, $type, $teasers = false, $link
* $view->block_title.
*/
function theme_calendar_page_title($view, $items, $output) {
// Get rid of empty args to display the right title for the calendar.
$args = $view->args;
foreach($args as $delta => $arg) {
if ($arg == CALENDAR_EMPTY_ARG || empty($arg)) {
unset($args[$delta]);
}
}
$last_arg = array_pop($args);
return theme('calendar_arg_title', strtoupper($view->calendar_type), $last_arg, $last_arg);
switch ($view->build_type) {
case 'page':
if ($view->calendar_type == 'year') {
return $view->year;
}
else {
return views_get_title($view, $context = 'page', $args = $view->real_args);
return views_get_title($view, 'page', $args);
}
case 'block':
return $view->block_title;
......@@ -213,18 +229,13 @@ function theme_calendar_page_title($view, $items, $output) {
* @return string formatted title
*/
function theme_calendar_arg_title($field_type, $value, $query) {
$view = $GLOBALS['current_view'];
$value = intval(check_plain($value));
if (empty($value)) {
if ($view->month) {
return date_format_date($view->min_date, 'custom', 'F Y');
}
elseif ($view->year) {
return $view->year;
}
return '';
}
else {
switch ($field_type) {
$view = $GLOBALS['current_view'];
switch (strtoupper($field_type)) {
case 'YEAR':
$view->year = $value;
return $view->year;
......@@ -236,13 +247,15 @@ function theme_calendar_arg_title($field_type, $value, $query) {
return t('Week of @date', array('@date' => date_format($view->min_date, 'F j')));
}
}
return $value;
}
/**
* Function to construct back and next navigation from views arguments
*/
function theme_calendar_nav($view, $link = FALSE, $format = NULL) {
$mini = $view->mini;
$mini = $view->mini && $view->calendar_type != 'year';
if (!calendar_part_is_valid($view->year, 'year')) {
return $view->subtitle;
}
......@@ -252,7 +265,6 @@ function theme_calendar_nav($view, $link = FALSE, $format = NULL) {
$paths = calendar_get_paths($view);
$prev_path = implode('/', array_reverse($paths[0]));
$next_path = implode('/', array_reverse($paths[1]));
$prev_query = $next_query = array();
if ($_GET['view']) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment