1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_filter_node_tnid.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Filter by whether the node is the original translation.
|
10
|
*
|
11
|
* @ingroup views_filter_handlers
|
12
|
*/
|
13
|
class views_handler_filter_node_tnid extends views_handler_filter {
|
14
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function admin_summary() {
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* {@inheritdoc}
|
23
|
*/
|
24
|
public function option_definition() {
|
25
|
$options = parent::option_definition();
|
26
|
|
27
|
$options['operator']['default'] = 1;
|
28
|
|
29
|
return $options;
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Provide simple boolean operator.
|
34
|
*/
|
35
|
public function operator_form(&$form, &$form_state) {
|
36
|
$form['operator'] = array(
|
37
|
'#type' => 'radios',
|
38
|
'#title' => t('Include untranslated content'),
|
39
|
'#default_value' => $this->operator,
|
40
|
'#options' => array(
|
41
|
1 => t('Yes'),
|
42
|
0 => t('No'),
|
43
|
),
|
44
|
);
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* {@inheritdoc}
|
49
|
*/
|
50
|
public function can_expose() {
|
51
|
return FALSE;
|
52
|
}
|
53
|
|
54
|
/**
|
55
|
* {@inheritdoc}
|
56
|
*/
|
57
|
public function query() {
|
58
|
$table = $this->ensure_my_table();
|
59
|
// Select for source translations (tnid = nid). Conditionally, also accept
|
60
|
// either untranslated nodes (tnid = 0).
|
61
|
$expression = "$table.tnid = $table.nid";
|
62
|
if ($this->operator) {
|
63
|
$expression .= " OR $table.tnid = 0";
|
64
|
}
|
65
|
$this->query->add_where_expression($this->options['group'], $expression);
|
66
|
}
|
67
|
|
68
|
}
|