<?php
// $Id$

/**
 * @file
 *
 */

function incubator_events_views_default_views() {

// UPCOMING EVENTS
  $view = new view();
  $view->name = 'incubator_events';
  $view->description = 'Upcoming events and regular activities';
  $view->tag = 'Incubator';
  $view->base_table = 'node';
  $view->human_name = 'Calendar';
  $view->core = 7;
  $view->api_version = '3.0';
  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

  /* Display: Master */
  $handler = $view->new_display('default', 'Master', 'default');
  $handler->display->display_options['title'] = 'Activities and Events';
  $handler->display->display_options['css_class'] = 'incubator-events-popups';
  $handler->display->display_options['use_ajax'] = TRUE;
  $handler->display->display_options['use_more'] = TRUE;
  $handler->display->display_options['use_more_always'] = FALSE;
  $handler->display->display_options['access']['type'] = 'perm';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'mini';
  $handler->display->display_options['pager']['options']['items_per_page'] = '5';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['pager']['options']['id'] = '1';
  $handler->display->display_options['style_plugin'] = 'list';
  $handler->display->display_options['style_options']['grouping'] = array(
    0 => array(
      'field' => 'field_event_date_value',
      'rendered' => 1,
      'rendered_strip' => 0,
    ),
  );
  $handler->display->display_options['row_plugin'] = 'fields';
  $handler->display->display_options['row_options']['inline'] = array(
    'field_event_date' => 'field_event_date',
    'title' => 'title',
  );
  $handler->display->display_options['row_options']['separator'] = ' : ';
  /* Field: Day */
  $handler->display->display_options['fields']['field_event_date_value']['id'] = 'field_event_date_value';
  $handler->display->display_options['fields']['field_event_date_value']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['fields']['field_event_date_value']['field'] = 'field_event_date_value';
  $handler->display->display_options['fields']['field_event_date_value']['ui_name'] = 'Day';
  $handler->display->display_options['fields']['field_event_date_value']['label'] = '';
  $handler->display->display_options['fields']['field_event_date_value']['exclude'] = TRUE;
  $handler->display->display_options['fields']['field_event_date_value']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['field_event_date_value']['date_format'] = 'date_only';
  $handler->display->display_options['fields']['field_event_date_value']['second_date_format'] = 'long';
  $handler->display->display_options['fields']['field_event_date_value']['format_date_sql'] = 1;
  /* Field: Time */
  $handler->display->display_options['fields']['field_event_date']['id'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['fields']['field_event_date']['field'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['ui_name'] = 'Time';
  $handler->display->display_options['fields']['field_event_date']['label'] = '';
  $handler->display->display_options['fields']['field_event_date']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['field_event_date']['settings'] = array(
    'format_type' => 'time_only',
    'fromto' => 'value',
    'multiple_number' => '1',
    'multiple_from' => '',
    'multiple_to' => '',
    'show_repeat_rule' => 'hide',
  );
  $handler->display->display_options['fields']['field_event_date']['delta_offset'] = '0';
  /* Field: Content: Title */
  $handler->display->display_options['fields']['title']['id'] = 'title';
  $handler->display->display_options['fields']['title']['table'] = 'node';
  $handler->display->display_options['fields']['title']['field'] = 'title';
  $handler->display->display_options['fields']['title']['label'] = '';
  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
  /* Field: Content: Rendered Node */
  $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
  $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
  $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
  $handler->display->display_options['fields']['rendered_entity']['label'] = '';
  $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
  $handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
  $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'teaser';
  $handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
  /* Sort criterion: Content: Event date -  start date (field_event_date) */
  $handler->display->display_options['sorts']['field_event_date_value']['id'] = 'field_event_date_value';
  $handler->display->display_options['sorts']['field_event_date_value']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['sorts']['field_event_date_value']['field'] = 'field_event_date_value';
  /* Contextual filter: Content: Has taxonomy term ID (with depth) */
  $handler->display->display_options['arguments']['term_node_tid_depth']['id'] = 'term_node_tid_depth';
  $handler->display->display_options['arguments']['term_node_tid_depth']['table'] = 'node';
  $handler->display->display_options['arguments']['term_node_tid_depth']['field'] = 'term_node_tid_depth';
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_action'] = 'default';
  $handler->display->display_options['arguments']['term_node_tid_depth']['title_enable'] = TRUE;
  $handler->display->display_options['arguments']['term_node_tid_depth']['title'] = 'Upcoming Events : %1';
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_type'] = 'taxonomy_tid';
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_options']['node'] = TRUE;
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_options']['anyall'] = '+';
  $handler->display->display_options['arguments']['term_node_tid_depth']['summary']['number_of_records'] = '0';
  $handler->display->display_options['arguments']['term_node_tid_depth']['summary']['format'] = 'default_summary';
  $handler->display->display_options['arguments']['term_node_tid_depth']['summary_options']['items_per_page'] = '25';
  $handler->display->display_options['arguments']['term_node_tid_depth']['specify_validation'] = TRUE;
  $handler->display->display_options['arguments']['term_node_tid_depth']['validate']['type'] = 'taxonomy_term';
  $handler->display->display_options['arguments']['term_node_tid_depth']['validate']['fail'] = 'ignore';
  $handler->display->display_options['arguments']['term_node_tid_depth']['depth'] = '2';
  /* Contextual filter: Content: Has taxonomy term ID depth modifier */
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['id'] = 'term_node_tid_depth_modifier';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['table'] = 'node';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['field'] = 'term_node_tid_depth_modifier';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['default_argument_type'] = 'fixed';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary']['format'] = 'default_summary';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'] = array(
    0 => array(
      'field' => 'field_event_date_value',
      'rendered' => 1,
      'rendered_strip' => 0,
    ),
  );
  /* Filter criterion: Content: Published */
  $handler->display->display_options['filters']['status']['id'] = 'status';
  $handler->display->display_options['filters']['status']['table'] = 'node';
  $handler->display->display_options['filters']['status']['field'] = 'status';
  $handler->display->display_options['filters']['status']['value'] = 1;
  $handler->display->display_options['filters']['status']['group'] = 1;
  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  /* Filter criterion: Content: Type */
  $handler->display->display_options['filters']['type']['id'] = 'type';
  $handler->display->display_options['filters']['type']['table'] = 'node';
  $handler->display->display_options['filters']['type']['field'] = 'type';
  $handler->display->display_options['filters']['type']['value'] = array(
    'event' => 'event',
  );
  /* Filter criterion: Content: Event date -  start date (field_event_date) */
  $handler->display->display_options['filters']['field_event_date_value']['id'] = 'field_event_date_value';
  $handler->display->display_options['filters']['field_event_date_value']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['filters']['field_event_date_value']['field'] = 'field_event_date_value';
  $handler->display->display_options['filters']['field_event_date_value']['operator'] = 'between';
  $handler->display->display_options['filters']['field_event_date_value']['default_date'] = '-6 hours';
  $handler->display->display_options['filters']['field_event_date_value']['default_to_date'] = '+3 months';

  /* Display: Upcoming Page */
  $handler = $view->new_display('page', 'Upcoming Page', 'upcoming');
  $handler->display->display_options['defaults']['title'] = FALSE;
  $handler->display->display_options['title'] = 'Activities and Events';
  $handler->display->display_options['defaults']['use_ajax'] = FALSE;
  $handler->display->display_options['defaults']['pager'] = FALSE;
  $handler->display->display_options['pager']['type'] = 'full';
  $handler->display->display_options['pager']['options']['items_per_page'] = '12';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['pager']['options']['id'] = '0';
  $handler->display->display_options['pager']['options']['quantity'] = '9';
  $handler->display->display_options['defaults']['header'] = FALSE;
  /* Header: Global: Text area */
  $handler->display->display_options['header']['area']['id'] = 'area';
  $handler->display->display_options['header']['area']['table'] = 'views';
  $handler->display->display_options['header']['area']['field'] = 'area';
  $handler->display->display_options['header']['area']['label'] = 'Calendar link';
  $handler->display->display_options['header']['area']['content'] = '<a href="/events/calendar/!1" title="View as calendar" class="incubator-calendar-link">View as calendar</a>';
  $handler->display->display_options['header']['area']['format'] = 'filtered_html';
  $handler->display->display_options['header']['area']['tokenize'] = TRUE;
  /* Header: Global: View area */
  $handler->display->display_options['header']['view']['id'] = 'view';
  $handler->display->display_options['header']['view']['table'] = 'views';
  $handler->display->display_options['header']['view']['field'] = 'view';
  $handler->display->display_options['header']['view']['label'] = 'Regular events view';
  $handler->display->display_options['header']['view']['empty'] = TRUE;
  $handler->display->display_options['header']['view']['view_to_insert'] = 'incubator_regular_events:default';
  $handler->display->display_options['header']['view']['inherit_arguments'] = TRUE;
  $handler->display->display_options['path'] = 'events/upcoming';
  $handler->display->display_options['menu']['type'] = 'normal';
  $handler->display->display_options['menu']['title'] = 'Activities';
  $handler->display->display_options['menu']['weight'] = '4';
  $handler->display->display_options['menu']['name'] = 'main-menu';
  $handler->display->display_options['menu']['context'] = 0;
  $handler->display->display_options['menu']['context_only_inline'] = 0;

  /* Display: Upcoming Block */
  $handler = $view->new_display('block', 'Upcoming Block', 'upcoming_block');
  $handler->display->display_options['defaults']['title'] = FALSE;
  $handler->display->display_options['title'] = 'Upcoming Events';
  $handler->display->display_options['defaults']['use_more'] = FALSE;
  $handler->display->display_options['use_more'] = TRUE;
  $handler->display->display_options['defaults']['use_more_always'] = FALSE;
  $handler->display->display_options['defaults']['use_more_always'] = FALSE;
  $handler->display->display_options['use_more_always'] = FALSE;
  $handler->display->display_options['defaults']['use_more_text'] = FALSE;
  $handler->display->display_options['defaults']['pager'] = FALSE;
  $handler->display->display_options['pager']['type'] = 'some';
  $handler->display->display_options['pager']['options']['items_per_page'] = '5';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  $handler->display->display_options['style_plugin'] = 'default';
  $handler->display->display_options['style_options']['grouping'] = array(
    0 => array(
      'field' => 'field_event_date_value',
      'rendered' => 1,
      'rendered_strip' => 0,
    ),
  );
  $handler->display->display_options['defaults']['style_options'] = FALSE;
  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  $handler->display->display_options['row_plugin'] = 'fields';
  $handler->display->display_options['row_options']['inline'] = array(
    'field_event_date' => 'field_event_date',
    'title' => 'title',
  );
  $handler->display->display_options['row_options']['separator'] = ' : ';
  $handler->display->display_options['defaults']['row_options'] = FALSE;

  /* Display: Calendar Page */
  $handler = $view->new_display('page', 'Calendar Page', 'calendar');
  $handler->display->display_options['defaults']['title'] = FALSE;
  $handler->display->display_options['title'] = 'Calendar';
  $handler->display->display_options['defaults']['use_ajax'] = FALSE;
  $handler->display->display_options['defaults']['pager'] = FALSE;
  $handler->display->display_options['pager']['type'] = 'none';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  $handler->display->display_options['style_plugin'] = 'fullcalendar';
  $handler->display->display_options['style_options']['colorbox']['colorbox'] = TRUE;
  $handler->display->display_options['style_options']['colorbox']['colorboxIFrame'] = TRUE;
  $handler->display->display_options['style_options']['sameWindow'] = TRUE;
  $handler->display->display_options['style_options']['editable'] = TRUE;
  $handler->display->display_options['style_options']['fields']['date_field'] = array(
    'field_event_date' => 'field_event_date',
  );
  $handler->display->display_options['style_options']['fields']['date'] = TRUE;
  $handler->display->display_options['defaults']['style_options'] = FALSE;
  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  $handler->display->display_options['defaults']['row_options'] = FALSE;
  $handler->display->display_options['defaults']['header'] = FALSE;
  /* Header: Global: Text area */
  $handler->display->display_options['header']['area']['id'] = 'area';
  $handler->display->display_options['header']['area']['table'] = 'views';
  $handler->display->display_options['header']['area']['field'] = 'area';
  $handler->display->display_options['header']['area']['label'] = 'Event list link';
  $handler->display->display_options['header']['area']['content'] = '<a href="/events/upcoming/!1" title="View as event list" class="incubator-event-list-link">View as event list</a>';
  $handler->display->display_options['header']['area']['format'] = 'filtered_html';
  $handler->display->display_options['header']['area']['tokenize'] = TRUE;
  $handler->display->display_options['defaults']['footer'] = FALSE;
  /* Footer: Global: View area */
  $handler->display->display_options['footer']['view']['id'] = 'view';
  $handler->display->display_options['footer']['view']['table'] = 'views';
  $handler->display->display_options['footer']['view']['field'] = 'view';
  $handler->display->display_options['footer']['view']['label'] = 'Regular events view';
  $handler->display->display_options['footer']['view']['empty'] = TRUE;
  $handler->display->display_options['footer']['view']['view_to_insert'] = 'incubator_regular_events:default';
  $handler->display->display_options['footer']['view']['inherit_arguments'] = TRUE;
  $handler->display->display_options['defaults']['fields'] = FALSE;
  /* Field: Content: Title */
  $handler->display->display_options['fields']['title']['id'] = 'title';
  $handler->display->display_options['fields']['title']['table'] = 'node';
  $handler->display->display_options['fields']['title']['field'] = 'title';
  $handler->display->display_options['fields']['title']['label'] = '';
  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
  /* Field: Content: Event date */
  $handler->display->display_options['fields']['field_event_date']['id'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['fields']['field_event_date']['field'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['label'] = '';
  $handler->display->display_options['fields']['field_event_date']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['field_event_date']['settings'] = array(
    'format_type' => 'long',
    'fromto' => 'both',
    'multiple_number' => '',
    'multiple_from' => '',
    'multiple_to' => '',
    'show_repeat_rule' => 'hide',
  );
  $handler->display->display_options['fields']['field_event_date']['group_rows'] = FALSE;
  $handler->display->display_options['fields']['field_event_date']['delta_offset'] = '0';
  $handler->display->display_options['defaults']['sorts'] = FALSE;
  $handler->display->display_options['defaults']['filter_groups'] = FALSE;
  $handler->display->display_options['defaults']['filters'] = FALSE;
  /* Filter criterion: Content: Published */
  $handler->display->display_options['filters']['status']['id'] = 'status';
  $handler->display->display_options['filters']['status']['table'] = 'node';
  $handler->display->display_options['filters']['status']['field'] = 'status';
  $handler->display->display_options['filters']['status']['value'] = 1;
  $handler->display->display_options['filters']['status']['group'] = 1;
  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  /* Filter criterion: Content: Type */
  $handler->display->display_options['filters']['type']['id'] = 'type';
  $handler->display->display_options['filters']['type']['table'] = 'node';
  $handler->display->display_options['filters']['type']['field'] = 'type';
  $handler->display->display_options['filters']['type']['value'] = array(
    'event' => 'event',
  );
  /* Filter criterion: Content: Event date -  start date (field_event_date) */
  $handler->display->display_options['filters']['field_event_date_value']['id'] = 'field_event_date_value';
  $handler->display->display_options['filters']['field_event_date_value']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['filters']['field_event_date_value']['field'] = 'field_event_date_value';
  $handler->display->display_options['filters']['field_event_date_value']['operator'] = 'between';
  $handler->display->display_options['filters']['field_event_date_value']['default_date'] = '-3 months';
  $handler->display->display_options['filters']['field_event_date_value']['default_to_date'] = '+15 months';
  $handler->display->display_options['path'] = 'events/calendar';
  $handler->display->display_options['menu']['type'] = 'normal';
  $handler->display->display_options['menu']['title'] = 'Calendar';
  $handler->display->display_options['menu']['weight'] = '4';
  $handler->display->display_options['menu']['name'] = 'main-menu';
  $handler->display->display_options['menu']['context'] = 0;
  $handler->display->display_options['menu']['context_only_inline'] = 0;

  /* Display: iCal Feed - By Tags */
  $handler = $view->new_display('feed', 'iCal Feed - By Tags', 'ical_feed_term');
  $handler->display->display_options['defaults']['title'] = FALSE;
  $handler->display->display_options['pager']['type'] = 'none';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['style_plugin'] = 'date_ical';
  $handler->display->display_options['style_options']['cal_name'] = '';
  $handler->display->display_options['row_plugin'] = 'date_ical_fields';
  $handler->display->display_options['row_options']['date_field'] = 'field_event_date';
  $handler->display->display_options['row_options']['title_field'] = 'title';
  $handler->display->display_options['row_options']['description_field'] = 'body';
  $handler->display->display_options['row_options']['location_field'] = 'nothing';
  $handler->display->display_options['row_options']['additional_settings'] = array(
    'skip_blank_dates' => 1,
  );
  $handler->display->display_options['defaults']['fields'] = FALSE;
  /* Field: Content: Title */
  $handler->display->display_options['fields']['title']['id'] = 'title';
  $handler->display->display_options['fields']['title']['table'] = 'node';
  $handler->display->display_options['fields']['title']['field'] = 'title';
  $handler->display->display_options['fields']['title']['label'] = '';
  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  /* Field: Content: Time and place */
  $handler->display->display_options['fields']['field_event_info']['id'] = 'field_event_info';
  $handler->display->display_options['fields']['field_event_info']['table'] = 'field_data_field_event_info';
  $handler->display->display_options['fields']['field_event_info']['field'] = 'field_event_info';
  $handler->display->display_options['fields']['field_event_info']['label'] = '';
  $handler->display->display_options['fields']['field_event_info']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['field_event_info']['hide_alter_empty'] = FALSE;
  /* Field: Content: Event date */
  $handler->display->display_options['fields']['field_event_date']['id'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['fields']['field_event_date']['field'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['label'] = '';
  $handler->display->display_options['fields']['field_event_date']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['field_event_date']['settings'] = array(
    'format_type' => 'long',
    'fromto' => 'both',
    'multiple_number' => '',
    'multiple_from' => '',
    'multiple_to' => '',
    'show_repeat_rule' => 'hide',
  );
  $handler->display->display_options['fields']['field_event_date']['group_rows'] = FALSE;
  $handler->display->display_options['fields']['field_event_date']['delta_offset'] = '0';
  /* Field: Content: Body */
  $handler->display->display_options['fields']['body']['id'] = 'body';
  $handler->display->display_options['fields']['body']['table'] = 'field_data_body';
  $handler->display->display_options['fields']['body']['field'] = 'body';
  $handler->display->display_options['fields']['body']['label'] = '';
  $handler->display->display_options['fields']['body']['alter']['alter_text'] = TRUE;
  $handler->display->display_options['fields']['body']['alter']['text'] = '[title]

          [body]';
  $handler->display->display_options['fields']['body']['alter']['strip_tags'] = TRUE;
  $handler->display->display_options['fields']['body']['element_label_colon'] = FALSE;
  /* Field: Location: City */
  $handler->display->display_options['fields']['city']['id'] = 'city';
  $handler->display->display_options['fields']['city']['table'] = 'location';
  $handler->display->display_options['fields']['city']['field'] = 'city';
  $handler->display->display_options['fields']['city']['label'] = '';
  $handler->display->display_options['fields']['city']['exclude'] = TRUE;
  $handler->display->display_options['fields']['city']['element_label_colon'] = FALSE;
  /* Field: Location: Name */
  $handler->display->display_options['fields']['name']['id'] = 'name';
  $handler->display->display_options['fields']['name']['table'] = 'location';
  $handler->display->display_options['fields']['name']['field'] = 'name';
  $handler->display->display_options['fields']['name']['label'] = '';
  $handler->display->display_options['fields']['name']['exclude'] = TRUE;
  $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
  /* Field: Location: Province */
  $handler->display->display_options['fields']['province']['id'] = 'province';
  $handler->display->display_options['fields']['province']['table'] = 'location';
  $handler->display->display_options['fields']['province']['field'] = 'province';
  $handler->display->display_options['fields']['province']['label'] = '';
  $handler->display->display_options['fields']['province']['exclude'] = TRUE;
  $handler->display->display_options['fields']['province']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['province']['style'] = 'code';
  /* Field: Location: Street */
  $handler->display->display_options['fields']['street']['id'] = 'street';
  $handler->display->display_options['fields']['street']['table'] = 'location';
  $handler->display->display_options['fields']['street']['field'] = 'street';
  $handler->display->display_options['fields']['street']['label'] = '';
  $handler->display->display_options['fields']['street']['exclude'] = TRUE;
  $handler->display->display_options['fields']['street']['element_label_colon'] = FALSE;
  /* Field: Location Address */
  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
  $handler->display->display_options['fields']['nothing']['table'] = 'views';
  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
  $handler->display->display_options['fields']['nothing']['ui_name'] = 'Location Address';
  $handler->display->display_options['fields']['nothing']['label'] = '';
  $handler->display->display_options['fields']['nothing']['alter']['text'] = '[name]
          [street]
          [city] [province]';
  $handler->display->display_options['fields']['nothing']['alter']['strip_tags'] = TRUE;
  $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
  $handler->display->display_options['defaults']['arguments'] = FALSE;
  /* Contextual filter: Content: Has taxonomy term ID (with depth) */
  $handler->display->display_options['arguments']['term_node_tid_depth']['id'] = 'term_node_tid_depth';
  $handler->display->display_options['arguments']['term_node_tid_depth']['table'] = 'node';
  $handler->display->display_options['arguments']['term_node_tid_depth']['field'] = 'term_node_tid_depth';
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_action'] = 'default';
  $handler->display->display_options['arguments']['term_node_tid_depth']['title_enable'] = TRUE;
  $handler->display->display_options['arguments']['term_node_tid_depth']['title'] = 'Upcoming Events - %1';
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_type'] = 'taxonomy_tid';
  $handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_options']['limit'] = TRUE;
  $handler->display->display_options['arguments']['term_node_tid_depth']['summary']['number_of_records'] = '0';
  $handler->display->display_options['arguments']['term_node_tid_depth']['summary']['format'] = 'default_summary';
  $handler->display->display_options['arguments']['term_node_tid_depth']['summary_options']['items_per_page'] = '25';
  $handler->display->display_options['arguments']['term_node_tid_depth']['specify_validation'] = TRUE;
  $handler->display->display_options['arguments']['term_node_tid_depth']['validate']['type'] = 'taxonomy_term';
  $handler->display->display_options['arguments']['term_node_tid_depth']['validate']['fail'] = 'ignore';
  $handler->display->display_options['arguments']['term_node_tid_depth']['depth'] = '2';
  /* Contextual filter: Content: Has taxonomy term ID depth modifier */
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['id'] = 'term_node_tid_depth_modifier';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['table'] = 'node';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['field'] = 'term_node_tid_depth_modifier';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['default_argument_type'] = 'fixed';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary']['format'] = 'default_summary';
  $handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'] = 'field_event_date';
  $handler->display->display_options['path'] = 'events/upcoming/%/ical.ics';
  $handler->display->display_options['displays'] = array(
    'upcoming' => 'upcoming',
    'upcoming_block' => 'upcoming_block',
    'calendar' => 'calendar',
    'default' => 0,
  );
  $handler->display->display_options['sitename_title'] = 1;

  /* Display: Attachment */
  $handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
  $handler->display->display_options['pager']['type'] = 'some';
  $handler->display->display_options['pager']['options']['items_per_page'] = '5';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $translatables['incubator_events'] = array(
    t('Master'),
    t('Activities and Events'),
    t('more'),
    t('Apply'),
    t('Reset'),
    t('Sort by'),
    t('Asc'),
    t('Desc'),
    t('Items per page'),
    t('- All -'),
    t('Offset'),
    t('« first'),
    t('‹ previous'),
    t('next ›'),
    t('last »'),
    t('All'),
    t('Upcoming Events : %1'),
    t('Upcoming Page'),
    t('Calendar link'),
    t('<a href="/events/calendar/!1" title="View as calendar" class="incubator-calendar-link">View as calendar</a>'),
    t('Regular events view'),
    t('Upcoming Block'),
    t('Upcoming Events'),
    t('Calendar Page'),
    t('Calendar'),
    t('Event list link'),
    t('<a href="/events/upcoming/!1" title="View as event list" class="incubator-event-list-link">View as event list</a>'),
    t('iCal Feed - By Tags'),
    t('[title]

          [body]'),
    t('[name]
          [street]
          [city] [province]'),
    t('Upcoming Events - %1'),
    t('Attachment'),
  );
  $views[$view->name] = $view;

  
// REGULAR EVENTS
/**
 * These display_options handle the grouping for the regular_events view:
 * 
['style_options']['grouping'][0]                                                The grouping option for the view.
['relationships']['field_activity_type_tid']                                    The taxonomy term relationship. This must change depending on the grouping.
['fields']['field_activity_type']                                               The field for the taxonomy term.
['fields']['address']                                                           The field for the address.
['sorts']['weight']                                                             The sort for the taxonomy term weight.
['sorts']['weight']['relationship'] = 'field_activity_type_tid'                 The relationsihp for the sort must be set to the relationship name above.
['sorts']['city']                                                               The sort for the city.
['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'][0] The grouping option for the taxonomy term argument.
*/
  
$view = new view();
$view->name = 'incubator_regular_events';
$view->description = '';
$view->tag = 'Incubator';
$view->base_table = 'node';
$view->human_name = 'Regular events';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Regular events';
$handler->display->display_options['css_class'] = 'incubator-events-popups';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['query']['options']['query_tags'] = array(
  0 => 'incubator_regular_events',
);
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['style_options']['grouping'] = array(
  0 => array(
    'field' => 'field_activity_type',
    'rendered' => 0,
    'rendered_strip' => 0,
  ),
);
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['inline'] = array(
  'title' => 'title',
);
$handler->display->display_options['row_options']['separator'] = ' - ';
/* Relationship: Content: Activity type (field_activity_type) */
$handler->display->display_options['relationships']['field_activity_type_tid']['id'] = 'field_activity_type_tid';
$handler->display->display_options['relationships']['field_activity_type_tid']['table'] = 'field_data_field_activity_type';
$handler->display->display_options['relationships']['field_activity_type_tid']['field'] = 'field_activity_type_tid';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Field: Content: Time and place */
$handler->display->display_options['fields']['field_event_info']['id'] = 'field_event_info';
$handler->display->display_options['fields']['field_event_info']['table'] = 'field_data_field_event_info';
$handler->display->display_options['fields']['field_event_info']['field'] = 'field_event_info';
$handler->display->display_options['fields']['field_event_info']['label'] = '';
$handler->display->display_options['fields']['field_event_info']['element_label_colon'] = FALSE;
/* Field: Content: Rendered Node */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['label'] = '';
$handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 0;
$handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
$handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'teaser';
$handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
/* Field: Content: Activity type */
$handler->display->display_options['fields']['field_activity_type']['id'] = 'field_activity_type';
$handler->display->display_options['fields']['field_activity_type']['table'] = 'field_data_field_activity_type';
$handler->display->display_options['fields']['field_activity_type']['field'] = 'field_activity_type';
$handler->display->display_options['fields']['field_activity_type']['label'] = '';
$handler->display->display_options['fields']['field_activity_type']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_activity_type']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_activity_type']['group_rows'] = FALSE;
$handler->display->display_options['fields']['field_activity_type']['delta_offset'] = '0';
/* Field: Location: Address */
$handler->display->display_options['fields']['address']['id'] = 'address';
$handler->display->display_options['fields']['address']['table'] = 'location';
$handler->display->display_options['fields']['address']['field'] = 'address';
$handler->display->display_options['fields']['address']['label'] = '';
$handler->display->display_options['fields']['address']['exclude'] = TRUE;
$handler->display->display_options['fields']['address']['alter']['trim_whitespace'] = TRUE;
$handler->display->display_options['fields']['address']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['address']['hide'] = array(
  'name' => 'name',
  'street' => 'street',
  'additional' => 'additional',
  'province' => 'province',
  'postal_code' => 'postal_code',
  'country' => 'country',
  'locpick' => 'locpick',
  'province_name' => 'province_name',
  'country_name' => 'country_name',
  'map_link' => 'map_link',
  'coords' => 'coords',
  'city' => 0,
);
$handler->display->display_options['fields']['address']['exclude_cck'] = 0;
/* Sort criterion: Taxonomy term: Weight */
$handler->display->display_options['sorts']['weight']['id'] = 'weight';
$handler->display->display_options['sorts']['weight']['table'] = 'taxonomy_term_data';
$handler->display->display_options['sorts']['weight']['field'] = 'weight';
$handler->display->display_options['sorts']['weight']['relationship'] = 'field_activity_type_tid';
/* Sort criterion: Location: City */
$handler->display->display_options['sorts']['city']['id'] = 'city';
$handler->display->display_options['sorts']['city']['table'] = 'location';
$handler->display->display_options['sorts']['city']['field'] = 'city';
/* Sort criterion: Content: Title */
$handler->display->display_options['sorts']['title']['id'] = 'title';
$handler->display->display_options['sorts']['title']['table'] = 'node';
$handler->display->display_options['sorts']['title']['field'] = 'title';
/* Contextual filter: Content: Has taxonomy term ID (with depth) */
$handler->display->display_options['arguments']['term_node_tid_depth']['id'] = 'term_node_tid_depth';
$handler->display->display_options['arguments']['term_node_tid_depth']['table'] = 'node';
$handler->display->display_options['arguments']['term_node_tid_depth']['field'] = 'term_node_tid_depth';
$handler->display->display_options['arguments']['term_node_tid_depth']['default_action'] = 'default';
$handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_type'] = 'taxonomy_tid';
$handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_options']['node'] = TRUE;
$handler->display->display_options['arguments']['term_node_tid_depth']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['term_node_tid_depth']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['term_node_tid_depth']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['term_node_tid_depth']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['term_node_tid_depth']['validate']['type'] = 'taxonomy_term';
$handler->display->display_options['arguments']['term_node_tid_depth']['validate']['fail'] = 'ignore';
$handler->display->display_options['arguments']['term_node_tid_depth']['depth'] = '2';
/* Contextual filter: Content: Has taxonomy term ID depth modifier */
$handler->display->display_options['arguments']['term_node_tid_depth_modifier']['id'] = 'term_node_tid_depth_modifier';
$handler->display->display_options['arguments']['term_node_tid_depth_modifier']['table'] = 'node';
$handler->display->display_options['arguments']['term_node_tid_depth_modifier']['field'] = 'term_node_tid_depth_modifier';
$handler->display->display_options['arguments']['term_node_tid_depth_modifier']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'] = array(
  0 => array(
    'field' => 'field_activity_type',
    'rendered' => 0,
    'rendered_strip' => 0,
  ),
);
$handler->display->display_options['filter_groups']['operator'] = 'OR';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'event' => 'event',
);
$handler->display->display_options['filters']['type']['group'] = 1;
$translatables['incubator_regular_events'] = array(
  t('Master'),
  t('Regular events'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('term'),
  t('All'),
);
  $views[$view->name] = $view;
  

// Subscribe to Event
  $view = new view();
  $view->name = 'calendar_subscribe_event';
  $view->description = '';
  $view->tag = 'Incubator';
  $view->base_table = 'node';
  $view->human_name = 'Calendar - Subscribe Event';
  $view->core = 7;
  $view->api_version = '3.0';
  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

  /* Display: Master */
  $handler = $view->new_display('default', 'Master', 'default');
  $handler->display->display_options['use_more_always'] = FALSE;
  $handler->display->display_options['access']['type'] = 'perm';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'none';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['style_plugin'] = 'default';
  $handler->display->display_options['row_plugin'] = 'fields';
  /* Field: Content: Title */
  $handler->display->display_options['fields']['title']['id'] = 'title';
  $handler->display->display_options['fields']['title']['table'] = 'node';
  $handler->display->display_options['fields']['title']['field'] = 'title';
  $handler->display->display_options['fields']['title']['label'] = '';
  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = TRUE;
  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
  /* Field: Content: Body */
  $handler->display->display_options['fields']['body']['id'] = 'body';
  $handler->display->display_options['fields']['body']['table'] = 'field_data_body';
  $handler->display->display_options['fields']['body']['field'] = 'body';
  $handler->display->display_options['fields']['body']['label'] = '';
  $handler->display->display_options['fields']['body']['alter']['alter_text'] = TRUE;
  $handler->display->display_options['fields']['body']['alter']['text'] = '[title]

  [body]';
  $handler->display->display_options['fields']['body']['alter']['strip_tags'] = TRUE;
  $handler->display->display_options['fields']['body']['element_label_colon'] = FALSE;
  /* Field: Content: Event date */
  $handler->display->display_options['fields']['field_event_date']['id'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['table'] = 'field_data_field_event_date';
  $handler->display->display_options['fields']['field_event_date']['field'] = 'field_event_date';
  $handler->display->display_options['fields']['field_event_date']['label'] = '';
  $handler->display->display_options['fields']['field_event_date']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['field_event_date']['settings'] = array(
    'format_type' => 'long',
    'fromto' => 'both',
    'multiple_number' => '',
    'multiple_from' => '',
    'multiple_to' => '',
    'show_repeat_rule' => 'show',
  );
  $handler->display->display_options['fields']['field_event_date']['delta_offset'] = '0';
  /* Field: Location: City */
  $handler->display->display_options['fields']['city']['id'] = 'city';
  $handler->display->display_options['fields']['city']['table'] = 'location';
  $handler->display->display_options['fields']['city']['field'] = 'city';
  $handler->display->display_options['fields']['city']['label'] = '';
  $handler->display->display_options['fields']['city']['exclude'] = TRUE;
  $handler->display->display_options['fields']['city']['element_label_colon'] = FALSE;
  /* Field: Location: Name */
  $handler->display->display_options['fields']['name']['id'] = 'name';
  $handler->display->display_options['fields']['name']['table'] = 'location';
  $handler->display->display_options['fields']['name']['field'] = 'name';
  $handler->display->display_options['fields']['name']['label'] = '';
  $handler->display->display_options['fields']['name']['exclude'] = TRUE;
  $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
  /* Field: Location: Province */
  $handler->display->display_options['fields']['province']['id'] = 'province';
  $handler->display->display_options['fields']['province']['table'] = 'location';
  $handler->display->display_options['fields']['province']['field'] = 'province';
  $handler->display->display_options['fields']['province']['label'] = '';
  $handler->display->display_options['fields']['province']['exclude'] = TRUE;
  $handler->display->display_options['fields']['province']['element_label_colon'] = FALSE;
  $handler->display->display_options['fields']['province']['style'] = 'code';
  /* Field: Location: Street */
  $handler->display->display_options['fields']['street']['id'] = 'street';
  $handler->display->display_options['fields']['street']['table'] = 'location';
  $handler->display->display_options['fields']['street']['field'] = 'street';
  $handler->display->display_options['fields']['street']['label'] = '';
  $handler->display->display_options['fields']['street']['exclude'] = TRUE;
  $handler->display->display_options['fields']['street']['element_label_colon'] = FALSE;
  /* Field: Location Address */
  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
  $handler->display->display_options['fields']['nothing']['table'] = 'views';
  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
  $handler->display->display_options['fields']['nothing']['ui_name'] = 'Location Address';
  $handler->display->display_options['fields']['nothing']['label'] = '';
  $handler->display->display_options['fields']['nothing']['alter']['text'] = '[name]
  [street]
  [city] [province]';
  $handler->display->display_options['fields']['nothing']['alter']['strip_tags'] = TRUE;
  $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
  /* Contextual filter: Content: Nid */
  $handler->display->display_options['arguments']['nid']['id'] = 'nid';
  $handler->display->display_options['arguments']['nid']['table'] = 'node';
  $handler->display->display_options['arguments']['nid']['field'] = 'nid';
  $handler->display->display_options['arguments']['nid']['default_action'] = 'default';
  $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
  $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
  $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
  $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
  /* Filter criterion: Content: Published */
  $handler->display->display_options['filters']['status']['id'] = 'status';
  $handler->display->display_options['filters']['status']['table'] = 'node';
  $handler->display->display_options['filters']['status']['field'] = 'status';
  $handler->display->display_options['filters']['status']['value'] = 1;
  $handler->display->display_options['filters']['status']['group'] = 1;
  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  /* Filter criterion: Content: Type */
  $handler->display->display_options['filters']['type']['id'] = 'type';
  $handler->display->display_options['filters']['type']['table'] = 'node';
  $handler->display->display_options['filters']['type']['field'] = 'type';
  $handler->display->display_options['filters']['type']['value'] = array(
    'event' => 'event',
  );

  /* Display: Feed */
  $handler = $view->new_display('feed', 'Feed', 'ical');
  $handler->display->display_options['pager']['type'] = 'none';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['style_plugin'] = 'date_ical';
  $handler->display->display_options['style_options']['cal_name'] = '';
  $handler->display->display_options['style_options']['no_calname'] = TRUE;
  $handler->display->display_options['row_plugin'] = 'date_ical_fields';
  $handler->display->display_options['row_options']['date_field'] = 'field_event_date';
  $handler->display->display_options['row_options']['title_field'] = 'title';
  $handler->display->display_options['row_options']['description_field'] = 'body';
  $handler->display->display_options['row_options']['location_field'] = 'nothing';
  $handler->display->display_options['row_options']['additional_settings'] = array(
    'skip_blank_dates' => 0,
  );
  $handler->display->display_options['path'] = 'node/%/event.ics';
  $translatables['calendar_subscribe_event'] = array(
    t('Master'),
    t('more'),
    t('Apply'),
    t('Reset'),
    t('Sort by'),
    t('Asc'),
    t('Desc'),
    t('[title]

  [body]'),
    t('[name]
  [street]
  [city] [province]'),
    t('All'),
    t('Feed'),
  );
  $views[$view->name] = $view;
  
  
// =============================================================================
// Modifications to default views
// =============================================================================
  
  // Get the path of the chosen view, for use later
  $chosen_view_path = variable_get('incubator_events_views_choice', 'upcoming') == 'calendar' ? 'events/calendar' : 'events/upcoming';
  
  // ===========================================================================
  // UPCOMING EVENTS AND CALENDAR
  $choice = variable_get('incubator_events_views_choice', 'upcoming');
  if ($choice != 'both' && variable_get('incubator_events_views_disable_secondary', FALSE)) {
    $alternate = $choice == 'calendar' ? 'upcoming' : 'calendar';
    // ^ If we don't want the secondary view...
    $views['incubator_events']->display[$alternate]->display_options['enabled'] = FALSE;
    // ^ ...disable the non-chosen view...
    _incubator_redirect("events/$alternate", "events/$choice");
    // ^ ...redirect its page to the chosen view...
    unset($views['incubator_events']->display[$choice]->display_options['header']['area']);
    // ^ ...and remove the link in the header.
  }
  else {
    if (module_exists('redirect')) {
      redirect_delete_by_path('events/upcoming');
      redirect_delete_by_path('events/calendar');
    }
  }
  $views['incubator_events']->display['upcoming']->display_options['title'] = variable_get('incubator_events_views_upcoming_title', 'Activities and Events');
  $views['incubator_events']->display['calendar']->display_options['title'] = variable_get('incubator_events_views_calendar_title', 'Calendar');
  $views['incubator_events']->display['calendar']->display_options['style_options']['firstDay'] = variable_get('incubator_events_views_calendar_firstday', '0');
  $views['incubator_events']->display['calendar']->display_options['style_options']['weekMode'] = variable_get('incubator_events_views_calendar_weekmode', 'variable');
  $views['incubator_events']->display['calendar']->display_options['style_options']['editable'] = !variable_get('incubator_events_views_calendar_editable', TRUE);
  $views['incubator_events']->display['upcoming_block']->display_options['link_display'] = variable_get('incubator_events_views_choice', 'upcoming') == 'calendar' ? 'calendar' : 'upcoming';
  
  // Create a redirect from /events to the main view
  _incubator_redirect('events', $chosen_view_path);
    
  // ===========================================================================
  // OLD "ACTIVITIES" VIEW
//  if (module_exists('redirect')) {
//    redirect_delete_by_path('events/activities');
//  }
//  if (!variable_get('incubator_events_views_enable_activities_page', FALSE)) {
//    $views['activities_upcoming_events']->disabled = TRUE;
//    $redirect_path = variable_get('incubator_events_views_choice', 'upcoming') == 'calendar' ? 'events/calendar' : 'events/upcoming';
//    _incubator_redirect('events/activities', $chosen_view_path);
//  }
//  // Create ical link for Activities view
//  $views['activities_upcoming_events']->display['default']->display_options['footer']['area_text_custom']['content'] = _incubator_events_ical_link(t('subscribe to this calendar'), 'events/upcoming/all/ical.ics');

  
  // ===========================================================================
  // REGULAR EVENTS
  // Check the description of the regular events view in hook_views_default_views above
  $grouping_fields = incubator_events_get_grouping_fields();
  
  if (!$grouping_fields['primary']) {
    // If grouping is disabled, unset all the grouping options
    $views['incubator_regular_events']->display['default']->handler->display->display_options['style_options']['grouping'] = FALSE;
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['relationships']['field_activity_type']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['field_activity_type']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['address']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['sorts']['weight']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['sorts']['city']);
    $views['incubator_regular_events']->display['default']->handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'] = FALSE;
  }
  
  else {
    // If grouping is enabled...
    foreach (array('primary', 'secondary') as $i) {
      // If a taxonomy field other than activity_type is chosen...
      if ($grouping_fields[$i] != 'field_activity_type' && stripos($grouping_fields[$i], 'field_') === 0) {
        $views['incubator_regular_events']->display['default']->handler->display->display_options['fields'][$grouping_fields{$i}] = $views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['field_activity_type'];
        $views['incubator_regular_events']->display['default']->handler->display->display_options['fields'][$grouping_fields{$i}]['id'] = $grouping_fields[$i];
        $views['incubator_regular_events']->display['default']->handler->display->display_options['fields'][$grouping_fields{$i}]['table'] = 'field_data_' . $grouping_fields[$i];
        $views['incubator_regular_events']->display['default']->handler->display->display_options['fields'][$grouping_fields{$i}]['field'] = $grouping_fields[$i];
        // ^ create the field that the grouping will be done on, for both primary and secondary fields.
        if ($i == 'primary') { 
        // ^ For the primary sort only...
          // Remove the field_activity_type_tid relationship
          unset($views['incubator_regular_events']->display['default']->handler->display->display_options['relationships']['field_activity_type_tid']);
          // And create the new relationship for the proper grouping field
          $grouping_tid = $grouping_fields{$i} . '_tid';
          $views['incubator_regular_events']->display['default']->handler->display->display_options['relationships'][$grouping_tid]['id'] = $grouping_tid;
          $views['incubator_regular_events']->display['default']->handler->display->display_options['relationships'][$grouping_tid]['table'] = 'field_data_' . $grouping_fields{$i};
          $views['incubator_regular_events']->display['default']->handler->display->display_options['relationships'][$grouping_tid]['field'] = $grouping_tid;
          // Change the sort to work on the primary field by default
          $views['incubator_regular_events']->display['default']->handler->display->display_options['style_options']['grouping']['0']['field'] = $grouping_fields[$i];
          $views['incubator_regular_events']->display['default']->handler->display->display_options['sorts']['weight']['relationship'] = $grouping_tid;
          $views['incubator_regular_events']->display['default']->handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'][0]['field'] = $grouping_fields[$i];
        }
        if ($i == 'secondary') {
          // Don't create separate records for the secondary grouping field
          $views['incubator_regular_events']->display['default']->handler->display->display_options['fields'][$grouping_fields{$i}]['group_rows'] = TRUE;
        }
        $uses_taxonomy_field = TRUE;
      }
    }
    if ($grouping_fields['primary'] == 'address') {
      // If the primary grouping is the address, change the grouping here
      $views['incubator_regular_events']->display['default']->handler->display->display_options['style_options']['grouping']['0'] = array(
        'field' => 'address',
        'rendered' => TRUE,
        'rendered_strip' => TRUE,
      );
    }
  }
  if (!in_array('field_activity_type', $grouping_fields)) {
    // If activity type is not in the grouping, remove that field and the sort.
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['field_activity_type']);
    if (empty($uses_taxonomy_field)) {
      unset($views['incubator_regular_events']->display['default']->handler->display->display_options['relationships']['term_node_tid']);
      unset($views['incubator_regular_events']->display['default']->handler->display->display_options['sorts']['weight']);
      $views['incubator_regular_events']->display['default']->handler->display->display_options['arguments']['term_node_tid_depth_modifier']['summary_options']['grouping'] = FALSE;
    }
  }
  if (!in_array('address', $grouping_fields)) {
    // If address is not in the grouping, remove that field and the sort.
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['address']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['sorts']['city']);
  }
  else {
    // Set the fields to hide on the address
    $show_address = variable_get('incubator_events_grouping_address', array('city' => 'city'));
    $views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['address']['hide']['city'] = 'city';
    foreach (array_filter($show_address) as $show_address_part) {
      $views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['address']['hide'][$show_address_part] = 0;
    }
  }
  
  // Disable pop-up events
  if (!variable_get('incubator_events_popups', FALSE)) {
    unset($views['incubator_events']->display['default']->handler->display->display_options['fields']['rendered_entity']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['fields']['rendered_entity']);
    unset($views['incubator_events']->display['default']->handler->display->display_options['css_class']);
    unset($views['incubator_regular_events']->display['default']->handler->display->display_options['css_class']);
  }

  return $views;
}

function incubator_events_views_default_views_alter(&$views) {
  
  foreach (array('taxonomy_term', 'local_recent_stories') as $view_name) {
    if (!empty($views[$view_name])) {
      // Set headers and filters for default display handler
        $handler =& $views[$view_name]->display['default']->handler;
        /* Header: Global: View area */
        $handler->display->display_options['header']['event_view']['id'] = 'view';
        $handler->display->display_options['header']['event_view']['table'] = 'views';
        $handler->display->display_options['header']['event_view']['field'] = 'view';
        $handler->display->display_options['header']['event_view']['view_to_insert'] = 'incubator_regular_events:default';
        $handler->display->display_options['header']['event_view']['inherit_arguments'] = TRUE;
        /* Header: Global: View area */
        $handler->display->display_options['header']['event_view_1']['id'] = 'view_1';
        $handler->display->display_options['header']['event_view_1']['table'] = 'views';
        $handler->display->display_options['header']['event_view_1']['field'] = 'view';
        $handler->display->display_options['header']['event_view_1']['view_to_insert'] = 'incubator_events:attachment_1';
        $handler->display->display_options['header']['event_view_1']['inherit_arguments'] = TRUE;
        /* Filter criterion: Content: Type */
        $handler->display->display_options['filters']['event_type']['id'] = 'type';
        $handler->display->display_options['filters']['event_type']['table'] = 'node';
        $handler->display->display_options['filters']['event_type']['field'] = 'type';
        $handler->display->display_options['filters']['event_type']['operator'] = 'not in';
        $handler->display->display_options['filters']['event_type']['value'] = array(
          'event' => 'event',
        );
    }
  }

  // Set filters for feed display handler
    $handler =& $views['taxonomy_term']->display['feed']->handler;

    $handler->display->display_options['defaults']['filter_groups'] = FALSE;
    $handler->display->display_options['defaults']['filters'] = FALSE;
    /* Filter criterion: Content: Published or admin */
    $handler->display->display_options['filters']['status_extra']['id'] = 'status_extra';
    $handler->display->display_options['filters']['status_extra']['table'] = 'node';
    $handler->display->display_options['filters']['status_extra']['field'] = 'status_extra';
    $handler->display->display_options['filters']['status_extra']['group'] = 1;
    $handler->display->display_options['filters']['status_extra']['expose']['operator'] = FALSE;
    /* Filter criterion: Content: Event date -  start date (field_event_date) */
    $handler->display->display_options['filters']['field_event_date_value']['id'] = 'field_event_date_value';
    $handler->display->display_options['filters']['field_event_date_value']['table'] = 'field_data_field_event_date';
    $handler->display->display_options['filters']['field_event_date_value']['field'] = 'field_event_date_value';
    $handler->display->display_options['filters']['field_event_date_value']['operator'] = 'empty';
    $handler->display->display_options['filters']['field_event_date_value']['group'] = 1;

}
