You are here

function calendar_ical_views_feed_argument in Calendar 5

Same name and namespace in other branches
  1. 5.2 calendar_ical.module \calendar_ical_views_feed_argument()

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

2 calls to calendar_ical_views_feed_argument()
calendar_ical_views_post_view in ./calendar_ical.module
post view for our own op -- mimics the feed selector
views_handler_arg_ical in ./calendar_ical.module
handler for our own ical argument; mimics the feed selector

File

./calendar_ical.module, line 337
Adds ical functionality to Calendar.

Code

function calendar_ical_views_feed_argument($op, &$view, $arg, $argtype = NULL) {
  if ($op == 'argument' && $arg == 'ical') {

    // Keep devel module from appending queries to ical export.
    $GLOBALS['devel_shutdown'] = FALSE;
    $view->page_type = 'calendar_ical';

    // reset the 'real url' to the URL without the feed argument.
    $view_args = array();
    $max = count($view->args);
    foreach ($view->args as $id => $view_arg) {
      ++$count;
      if ($view_arg == $arg && $view->argument[$id]['id'] == $argtype['id']) {
        if ($count != $max) {
          $view_args[] = $argtype['wildcard'];
        }
      }
      else {
        $view_args[] = $view_arg;
      }
    }
    $view->feed_url = views_get_url($view, $view_args);
  }
  else {
    if ($op == 'post_view') {
      $args = calendar_ical_post_view_make_args($view, $arg, 'ical');
      $url = views_get_url($view, $args);
      $title = views_get_title($view, 'page', $args);
      if ($view->used_filters) {
        $filters = drupal_query_string_encode($view->used_filters);
      }
      return implode(calendar_ical_add_ical(url($url, $filters), $title));
    }
  }
}