views_handler_argument_term_node_tid_depth_modifier.inc

  1. 3.x modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc
  2. 2.x modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc

Definition of views_handler_argument_term_node_tid_depth_modif.

File

modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_argument_term_node_tid_depth_modif.
  5. */
  6. /**
  7. * Argument handler for to modify depth for a previous term.
  8. *
  9. * This handler is actually part of the node table and has some restrictions,
  10. * because it uses a subquery to find nodes with.
  11. *
  12. * @ingroup views_argument_handlers
  13. */
  14. class views_handler_argument_term_node_tid_depth_modifier extends views_handler_argument {
  15. function options_form(&$form, &$form_state) { }
  16. function query($group_by = FALSE) { }
  17. function pre_query() {
  18. // We don't know our argument yet, but it's based upon our position:
  19. $argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL;
  20. if (!is_numeric($argument)) {
  21. return;
  22. }
  23. if ($argument > 10) {
  24. $argument = 10;
  25. }
  26. if ($argument < -10) {
  27. $argument = -10;
  28. }
  29. // figure out which argument preceded us.
  30. $keys = array_reverse(array_keys($this->view->argument));
  31. $skip = TRUE;
  32. foreach ($keys as $key) {
  33. if ($key == $this->options['id']) {
  34. $skip = FALSE;
  35. continue;
  36. }
  37. if ($skip) {
  38. continue;
  39. }
  40. if (empty($this->view->argument[$key])) {
  41. continue;
  42. }
  43. if (isset($handler)) {
  44. unset($handler);
  45. }
  46. $handler = &$this->view->argument[$key];
  47. if (empty($handler->definition['accept depth modifier'])) {
  48. continue;
  49. }
  50. // Finally!
  51. $handler->options['depth'] = $argument;
  52. }
  53. }
  54. }