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

#239594 Make sure ical links with other arguments work correctly.

parent 90e15dfe
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ Views Calendar 5.x
Version 2.0 dev
===============
- #239594 Make sure ical links with other arguments work correctly.
- #238287 Make sure calendars with other args (like OG) display default view.
- #269920 Fix breadcrumb on year view.
- #238369 Clean up breadcrumb when using calendar with other arguments.
......
......@@ -662,36 +662,9 @@ function calendar_get_paths($view) {
date_modify($prev_date, '-1 '. $view->calendar_type);
$next_date = drupal_clone($view->min_date);
date_modify($next_date, '+1 '. $view->calendar_type);
$path = calendar_get_url($view, $view->args, TRUE);
// 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[0] = array(
'path' => $real_url,
'type' => 'url',
);
$start_calendar = FALSE;
foreach ($view->argument as $delta => $arg) {
if ($delta < $buried_args) {
continue;
}
if (substr($arg['type'], 0, 8) == 'calendar') {
$start_calendar = TRUE;
$pathtype = str_replace('calendar_', '', $arg['type']);
$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' => '',
);
}
}
// reverse through the path, creating a $nextpath and $prevpath arrays
$formats = array('day' => 'j', 'month' => 'm', 'year' => 'Y', 'week' => 'W');
for ($x = $delta + 1; $x >= 0; $x--) {
......
......@@ -496,6 +496,71 @@ function calendar_url_append($view) {
return $url;
}
/**
* An alternative to views_get_url()
* that will correctly substitute replacement
* values like $group or $node.
*/
function calendar_get_url($view, $args, $as_array = FALSE) {
// 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[0] = array(
'path' => $real_url,
'type' => 'url',
);
$start_calendar = FALSE;
foreach ($view->argument as $delta => $arg) {
if ($delta < $buried_args) {
continue;
}
if (in_array($arg['type'], calendar_args())) {
$start_calendar = TRUE;
$pathtype = str_replace('calendar_', '', $arg['type']);
$path[$delta + 1] = array(
'path' => $args[$delta] != CALENDAR_EMPTY_ARG ? $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' => $args[$delta],
'type' => '',
);
}
}
if ($as_array) {
return $path;
}
else {
$string = '';
$first = TRUE;
foreach ($path as $part) {
if (!$first) {
$string .= '/';
}
$string .= $part['path'];
$first = FALSE;
}
return $string;
}
}
/**
* Substitute a calendar argument with a wildcard.
*/
function calendar_wildcard($arg, $value) {
if (empty($value) && substr($arg['type'], 0, 8) == 'calendar') {
$value = CALENDAR_EMPTY_ARG;
}
elseif (!empty($arg['wildcard_substitution']) && !empty($arg['wildcard']) && !empty($value) && $value == $arg['wildcard']) {
$value = $arg['wildcard_substitution'];
}
return $value;
}
/**
* Function to test whether this is a view that uses the calendar plugin theme.
*/
......
......@@ -188,7 +188,7 @@ function calendar_ical_views_arguments() {
* handler for our own ical argument; mimics the feed selector
*/
function views_handler_arg_ical($op, &$query, $argtype, $arg = '') {
switch ($op) {
switch ($op) {
case 'summary':
case 'sort':
case 'link':
......@@ -223,9 +223,9 @@ function calendar_ical_views_post_view($view, $items, $output) {
* when called as a hook or when called manually from calendar_ical_views_post_view
*/
function calendar_ical_views_feed_argument($op, &$view, $arg, $argtype = NULL) {
if ($op == 'argument' && $arg == 'ical') {
if ($op == 'argument' && $arg == 'ical') {
// Keep devel module from appending queries to ical export.
$GLOBALS['devel_shutdown'] = FALSE;
$GLOBALS['devel_shutdown'] = FALSE;
$view->page_type = 'calendar_ical';
// reset the 'real url' to the URL without the feed argument.
$view_args = array();
......@@ -241,11 +241,12 @@ function calendar_ical_views_feed_argument($op, &$view, $arg, $argtype = NULL) {
$view_args[] = $view_arg;
}
}
$view->feed_url = views_get_url($view, $view_args);
$url = calendar_get_url($view, $args, FALSE);
$view->feed_url = $url;
}
else if ($op == 'post_view') {
$args = calendar_ical_post_view_make_args($view, $arg, 'ical');
$url = views_get_url($view, $args);
$url = calendar_get_url($view, $args, FALSE);
$title = views_get_title($view, 'page', $args);
if ($view->used_filters) {
$filters = drupal_query_string_encode($view->used_filters);
......
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