You are here

function date_views_browser_navigation in Date 5

Same name and namespace in other branches
  1. 5.2 date/date_views.inc \date_views_browser_navigation()

Navigation links for the full view

1 call to date_views_browser_navigation()
theme_date_views_browser_full_view in ./date_views.inc
View, themed so it can be overridden $display -- views_view_list, views_view_table, views_view_teasers, views_view_nodes

File

./date_views.inc, line 765

Code

function date_views_browser_navigation($view, $period) {
  include_once drupal_get_path('module', 'date_api') . '/date.inc';
  $path = explode('/', $view->url);
  $pos = sizeof($path);
  if (arg($pos) == '') {
    $arg = NULL;
  }
  else {
    $arg = arg($pos);
  }
  $range = date_views_date_range($arg);
  $stamp = date_views_browser_period_start_stamp($arg, $period);
  switch ($period) {
    case 'week':
      $prev_date = date_gmdate('Y-m-d', intval($stamp - 604799));
      $next_date = date_gmdate('Y-m-d', intval($stamp + 604801));
      break;
    case 'year':
      $year = intval(substr($range[0], 0, 4));
      $month = intval(substr($range[0], 5, 2));
      $prev_date = $month < 2 ? intval($year - 1) : $year;
      $next_date = $month > 11 ? intval($year + 1) : $year;
      break;
    case 'day':
      $prev_date = date_gmdate('Y-m-d', intval($stamp - 86399));
      $next_date = date_gmdate('Y-m-d', intval($stamp + 86401));
      break;
    case 'hour':
      $prev_date = date_gmdate('Y-m-d\\TH', intval($stamp - 3599));
      $next_date = date_gmdate('Y-m-d\\TH', intval($stamp + 3601));
      break;
    default:
      $year = intval(substr($range[0], 0, 4));
      $month = intval(substr($range[0], 5, 2));
      $prev_date = ($month > 1 ? $year : intval($year - 1)) . '-' . ($month > 1 ? sprintf('%02d', intval($month - 1)) : '12');
      $next_date = ($month < 12 ? $year : intval($year + 1)) . '-' . ($month < 12 ? sprintf('%02d', intval($month + 1)) : '01');
      break;
  }
  $prev = $view->url . '/' . $prev_date . date_views_browser_period($period);
  $next = $view->url . '/' . $next_date . date_views_browser_period($period);
  $label = date_views_browser_period_label($arg, $period);
  return theme('date_views_browser_navigation', $label, $period, $prev, $next, $view);
}