You are here

function _event_nav in Event 5.2

Same name and namespace in other branches
  1. 5 event.module \_event_nav()

Build the navigation links for the calendar views

Parameters

$date The date we are viewing, as an array:

$dir The 'direction' we want (prev or next):

$view The view we are navigating, month, week, day or table:

$types The content types to filter by:

$terms The taxonomy terms to filter by:

$duration The duration of the current view in multiples of view type:

Return value

Themed navigation link.

Related topics

2 calls to _event_nav()
event_calendar_month in ./event.module
Displays a monthly event calendar.
event_page in ./event.module
Displays a page containing event information. The page layout defaults to a graphical calendar.

File

./event.module, line 1642

Code

function _event_nav($date, $dir, $view, $types, $terms, $duration = NULL) {

  // first, retrieve the stored timestamp of the first/last event
  $range = variable_get('event_range_' . $dir, -1);

  // If the variable isn't set, set it and try again
  if ($range == -1) {
    event_set_range();
    $range = variable_get('event_range_' . $dir, $date);
  }

  // if we are beyond the range of the stored events, dont display navigation
  if ($dir == 'prev' && event_is_later($date, $range) || $dir == 'next' && event_is_later($range, $date)) {
    $inc = $dir == 'prev' ? -1 : 1;
    $duration = $duration ? $duration : 1;

    // we have to separeate block navigation from normal month view
    // what happens with $attributes if its not declared? its still passed to theme below
    if ($view == 'block') {
      $view = 'month';
      $attributes = array(
        'class' => 'updateblock',
      );
    }
    switch ($view) {
      case 'day':
      case 'table':

        // Increment by $duration days
        $date = event_date_later($date, $inc * $duration);
        break;
      case 'week':

        // Increment by $duration weeks
        $date = event_date_later($date, $inc * $duration * 7);
        break;
      case 'month':

        // Increment by $duration months
        $date = event_date_later($date, $inc * $duration, 'months');
        break;
    }
    $url[] = 'event';
    $url[] = _event_format_url($date);
    $url[] = $view;
    $url[] = $types ? implode('+', $types) : 'all';
    $url[] = $terms ? implode('+', $terms) : 'all';
    $url[] = $duration;
    return theme('event_nav_' . $dir, implode('/', $url), $attributes);
  }
}