views_handler_filter_node_version_count.inc 1.7 KB

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