1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_argument_term_node_tid.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Allow taxonomy term ID(s) as argument.
|
10
|
*
|
11
|
* @ingroup views_argument_handlers
|
12
|
*/
|
13
|
class views_handler_argument_term_node_tid extends views_handler_argument_many_to_one {
|
14
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function option_definition() {
|
19
|
$options = parent::option_definition();
|
20
|
$options['set_breadcrumb'] = array('default' => FALSE, 'bool' => TRUE);
|
21
|
return $options;
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* {@inheritdoc}
|
26
|
*/
|
27
|
public function options_form(&$form, &$form_state) {
|
28
|
parent::options_form($form, $form_state);
|
29
|
$form['set_breadcrumb'] = array(
|
30
|
'#type' => 'checkbox',
|
31
|
'#title' => t("Set the breadcrumb for the term parents"),
|
32
|
'#description' => t('If selected, the breadcrumb trail will include all parent terms, each one linking to this view. Note that this only works if just one term was received.'),
|
33
|
'#default_value' => !empty($this->options['set_breadcrumb']),
|
34
|
);
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* {@inheritdoc}
|
39
|
*/
|
40
|
public function set_breadcrumb(&$breadcrumb) {
|
41
|
if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
|
42
|
return;
|
43
|
}
|
44
|
|
45
|
return views_taxonomy_set_breadcrumb($breadcrumb, $this);
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* {@inheritdoc}
|
50
|
*/
|
51
|
public function title_query() {
|
52
|
$titles = array();
|
53
|
$result = db_select('taxonomy_term_data', 'td')
|
54
|
->addTag('taxonomy_term_access')
|
55
|
->fields('td', array('name'))
|
56
|
->condition('td.tid', $this->value)
|
57
|
->execute();
|
58
|
foreach ($result as $term) {
|
59
|
$titles[] = check_plain($term->name);
|
60
|
}
|
61
|
return $titles;
|
62
|
}
|
63
|
|
64
|
}
|