Projet

Général

Profil

Paste
Télécharger (1,61 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / taxonomy / views_handler_argument_term_node_tid_depth_modifier.inc @ 4003efde

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_argument_term_node_tid_depth_modifier.
6
 */
7

    
8
/**
9
 * Argument handler for to modify depth for a previous term.
10
 *
11
 * This handler is actually part of the node table and has some restrictions,
12
 * because it uses a subquery to find nodes with.
13
 *
14
 * @ingroup views_argument_handlers
15
 */
16
class views_handler_argument_term_node_tid_depth_modifier extends views_handler_argument {
17

    
18
  /**
19
   * {@inheritdoc}
20
   */
21
  public function options_form(&$form, &$form_state) {
22
  }
23

    
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function query($group_by = FALSE) {
28
  }
29

    
30
  /**
31
   * {@inheritdoc}
32
   */
33
  public function pre_query() {
34
    // We don't know our argument yet, but it's based upon our position.
35
    $argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL;
36
    if (!is_numeric($argument)) {
37
      return;
38
    }
39

    
40
    if ($argument > 10) {
41
      $argument = 10;
42
    }
43

    
44
    if ($argument < -10) {
45
      $argument = -10;
46
    }
47

    
48
    // Figure out which argument preceded us.
49
    $keys = array_reverse(array_keys($this->view->argument));
50
    $skip = TRUE;
51
    foreach ($keys as $key) {
52
      if ($key == $this->options['id']) {
53
        $skip = FALSE;
54
        continue;
55
      }
56

    
57
      if ($skip) {
58
        continue;
59
      }
60

    
61
      if (empty($this->view->argument[$key])) {
62
        continue;
63
      }
64

    
65
      if (isset($handler)) {
66
        unset($handler);
67
      }
68

    
69
      $handler = &$this->view->argument[$key];
70
      if (empty($handler->definition['accept depth modifier'])) {
71
        continue;
72
      }
73

    
74
      // Finally!
75
      $handler->options['depth'] = $argument;
76
    }
77
  }
78

    
79
}