1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_argument_term_node_tid_depth_modif.
|
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
|
function options_form(&$form, &$form_state) { }
|
18
|
function query($group_by = FALSE) { }
|
19
|
function pre_query() {
|
20
|
// We don't know our argument yet, but it's based upon our position:
|
21
|
$argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL;
|
22
|
if (!is_numeric($argument)) {
|
23
|
return;
|
24
|
}
|
25
|
|
26
|
if ($argument > 10) {
|
27
|
$argument = 10;
|
28
|
}
|
29
|
|
30
|
if ($argument < -10) {
|
31
|
$argument = -10;
|
32
|
}
|
33
|
|
34
|
// figure out which argument preceded us.
|
35
|
$keys = array_reverse(array_keys($this->view->argument));
|
36
|
$skip = TRUE;
|
37
|
foreach ($keys as $key) {
|
38
|
if ($key == $this->options['id']) {
|
39
|
$skip = FALSE;
|
40
|
continue;
|
41
|
}
|
42
|
|
43
|
if ($skip) {
|
44
|
continue;
|
45
|
}
|
46
|
|
47
|
if (empty($this->view->argument[$key])) {
|
48
|
continue;
|
49
|
}
|
50
|
|
51
|
if (isset($handler)) {
|
52
|
unset($handler);
|
53
|
}
|
54
|
|
55
|
$handler = &$this->view->argument[$key];
|
56
|
if (empty($handler->definition['accept depth modifier'])) {
|
57
|
continue;
|
58
|
}
|
59
|
|
60
|
// Finally!
|
61
|
$handler->options['depth'] = $argument;
|
62
|
}
|
63
|
}
|
64
|
}
|