function calendar_build_filter in Calendar 5
Same name and namespace in other branches
- 5.2 calendar.inc \calendar_build_filter()
Compile the filter query for this view.
Parameters
object $query:
object $view:
2 calls to calendar_build_filter()
- calendar_handler_arg_type in ./
calendar.module - Custom views handler for all calendar arguments.
- 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 690 - Adds calendar filtering and displays to Views.
Code
function calendar_build_filter(&$query, &$view) {
if (!isset($query->week)) {
$query->week = calendar_week('week', $query);
}
if (!$query->min) {
return;
}
// Add elements to the query min and max values to create a complete date value
// for the minimum and maximum once all the View's args have been used.
$minmax = array(
'year' => array(
'-01-01 00:00:00',
"-12-31 23:59:59",
),
'month' => array(
'-01 00:00:00',
'-' . sprintf("%02d", date_last_day_of_month($query->month, $query->year)) . ' 23:59:59',
),
'day' => array(
' 00:00:00',
' 23:59:59',
),
'hour' => array(
':00:00',
':59:59',
),
'minute' => array(
':00',
':59',
),
);
$query->min .= $minmax[$query->calendar_type][0];
$query->max .= $minmax[$query->calendar_type][1];
// find all datetime fields in this view and add filters for them to the query
$queries = array();
foreach ($view->field as $delta => $field) {
$query_strings = calendar_build_field_query($query, $field);
if (!empty($query_strings)) {
$queries = array_merge($queries, $query_strings);
}
}
// bring the node type into the query so we can use it in the theme
$query
->add_field('type', 'node');
if ($queries) {
$query
->add_where(implode(" OR ", $queries));
}
return;
}