You are here

function calendar_get_url in Calendar 5.2

An alternative to views_get_url() that will correctly substitute replacement values like $group or $node.

2 calls to calendar_get_url()
calendar_get_paths in ./calendar.inc
calendar_ical_views_feed_argument in ./calendar_ical.module
feed argument hook that will convert us to ical or display an icon. the 4th argument isn't part of the hook, but we use it to differentiate when called as a hook or when called manually from calendar_ical_views_post_view

File

./calendar.module, line 597
Adds calendar filtering and displays to Views.

Code

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,
      );
    }
    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;
  }
}