~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

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