class vms_handler_filter_mlid in Views Menu Support 8
Same name and namespace in other branches
- 7 handlers/vms_handler_filter_mlid.inc \vms_handler_filter_mlid
Filter to compare a field against currently active menu link item.
Hierarchy
- class \vms_handler_filter_mlid extends \views_handler_filter_equality
Expanded class hierarchy of vms_handler_filter_mlid
1 string reference to 'vms_handler_filter_mlid'
- vms_views_data_alter in ./
vms.views.inc - Implements hook_views_data_alter().
File
- handlers/
vms_handler_filter_mlid.inc, line 11 - Filter handler for allowing restricting integer fields based on currently active menu items (plus trails).
View source
class vms_handler_filter_mlid extends views_handler_filter_equality {
/**
* Provide simple equality operator.
*/
function operator_options() {
return array(
'=' => t('Is in'),
'!=' => t('Is not in'),
);
}
/**
* Provide a select list to select (replacement) value.
*/
function value_form(&$form, &$form_state) {
$form['value'] = array(
'#type' => 'select',
'#title' => t('Menu item'),
'#options' => vms_mlid_query_types(),
'#default_value' => $this->value,
);
}
/**
* Display the filter on the administrative summary.
*/
function admin_summary() {
$options = vms_mlid_query_types();
$operators = $this
->operator_options();
return check_plain($operators[$this->operator] . ' ' . $options[$this->value]);
}
/**
* This filter cannot be exposed.
*/
function can_expose() {
return FALSE;
}
/**
* Add the filtering to the query.
*
* Potentially redundant if the parent class could be replaced with an IN
* handler.
*/
public function query() {
$this
->ensure_my_table();
$vms_target = vms_get_current_mlid($this->options['value']);
$table = $this->table_alias . '.' . $this->real_field;
if ($this->operator == '=') {
$this->query
->add_where($this->options['group'], $table, $vms_target, 'IN');
}
else {
$this->query
->add_where($this->options['group'], db_or()
->condition($table, $vms_target, 'NOT IN')
->condition($table, $vms_target, 'IS NULL'));
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
vms_handler_filter_mlid:: |
function | Display the filter on the administrative summary. | ||
vms_handler_filter_mlid:: |
function | This filter cannot be exposed. | ||
vms_handler_filter_mlid:: |
function | Provide simple equality operator. | ||
vms_handler_filter_mlid:: |
public | function | Add the filtering to the query. | |
vms_handler_filter_mlid:: |
function | Provide a select list to select (replacement) value. |