1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Filter to handle dates stored as a timestamp.
|
5
|
*
|
6
|
* @ingroup views_filter_handlers
|
7
|
*/
|
8
|
class views_handler_filter_node_version_count extends views_handler_filter_numeric {
|
9
|
function op_between($field) {
|
10
|
if ($this->operator == 'between') {
|
11
|
$this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) BETWEEN :min AND :max', array(':min' => $this->value['min'], ':max' => $this->value['max']));
|
12
|
}
|
13
|
else {
|
14
|
$this->query->add_where_expression($this->options['group'], '((SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) <= :min OR (SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) >= :max)', array(':min' => $this->value['min'], ':max' => $this->value['max']));
|
15
|
}
|
16
|
}
|
17
|
|
18
|
function op_simple($field) {
|
19
|
$this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid)' . $this->operator . ' :value', array(':value' => $this->value['value']));
|
20
|
}
|
21
|
|
22
|
function op_empty($field) {
|
23
|
if ($this->operator == 'empty') {
|
24
|
$operator = "IS NULL";
|
25
|
}
|
26
|
else {
|
27
|
$operator = "IS NOT NULL";
|
28
|
}
|
29
|
|
30
|
$this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) ' . $this->operator);
|
31
|
}
|
32
|
|
33
|
function op_regex($field) {
|
34
|
$this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) RLIKE :value', array(':value' => $this->value['value']));
|
35
|
}
|
36
|
}
|