function date_views_filter_handler::init in Date 7
Same name and namespace in other branches
- 8 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::init()
- 7.3 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::init()
- 7.2 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::init()
Provide some extra help to get the operator/value easier to use.
This likely has to be overridden by filters which are more complex than simple operator/value.
Overrides views_handler_filter::init
File
- date_views/
includes/ date_views_filter_handler.inc, line 29 - A flexible, configurable date filter.
Class
- date_views_filter_handler
- This filter allows you to select a granularity of date parts to filter on, such as year, month, day, etc.
Code
function init(&$view, &$options) {
parent::init($view, $options);
$this->date_handler->granularity = isset($options['granularity']) ? $options['granularity'] : 'day';
$this->date_hander->adjustment_field = isset($options['adjustment_field']) ? $options['adjustment_field'] : 0;
$this->format = $this->date_handler
->views_formats($this->options['granularity'], 'sql');
if (empty($this->view->date_info)) {
$this->view->date_info = new stdClass();
}
// Set the view range, do this only if not already set in case there are multiple date arguments.
if (empty($this->view->date_info->min_allowed_year)) {
$range = date_range_years($this->options['year_range']);
$this->view->date_info->min_allowed_year = !empty($range) && is_array($range) ? $range[0] : variable_get('min_allowed_year', 100);
$this->view->date_info->max_allowed_year = !empty($range) && is_array($range) ? $range[1] : variable_get('max_allowed_year', 4000);
}
if (empty($this->view->date_info->date_fields)) {
$this->view->date_info->date_fields = array();
}
$this->view->date_info->date_fields = array_merge($this->view->date_info->date_fields, $this->options['date_fields']);
$this->definition['allow empty'] = TRUE;
// If no value has been submitted on an exposed filter it is treated as
// a submitted value. Send a flag to the date widget processors so they
// know to set #default_value instead of 'input' in that case.
$this->force_value = FALSE;
if (empty($this->options['exposed']) || isset($this->options['expose']['identifier']) && !isset($_GET[$this->options['expose']['identifier']])) {
$this->force_value = TRUE;
}
}