You are here

function calendar_filter_week in Calendar 5

Same name and namespace in other branches
  1. 5.2 calendar.module \calendar_filter_week()

Callback for week filter. Build year, month, day, min, and max into query object.

Parameters

object $query:

integer $arg:

2 calls to calendar_filter_week()
calendar_handler_arg_week in ./calendar.module
Custom views handlers for the week argument.
calendar_views_query_alter in ./calendar.module
Implementation of hook_views_query() Insert filters into the query based on the current calendar view and the selected fields Used when the actual view arguments don't provide enough info to construct the query. i.e. on a view with no arguments…

File

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

Code

function calendar_filter_week(&$query, $arg) {
  calendar_load_calendar_api();
  if (!isset($query->year)) {
    calendar_filter_year($query, calendar_user_date('year'));
  }
  $arg = str_replace('W', '', $arg);
  $query->calendar_type = 'week';
  $query->week = calendar_part_is_valid($arg, 'week') ? $arg : calendar_user_date('week');
  $query->month = calendar_week('start_month', $query, $query->week);
  $query->day = calendar_week('start_day', $query, $query->week);
  $query->min = calendar_week('start_year', $query, $query->week) . '-' . sprintf('%02d', calendar_week('start_month', $query, $query->week)) . '-' . calendar_week('start_day', $query, $query->week) . ' 00:00:00';
  $query->max = calendar_week('end_year', $query, $query->week) . '-' . sprintf('%02d', calendar_week('end_month', $query, $query->week)) . '-' . calendar_week('end_day', $query, $query->week) . ' 23:59:59';
}