function similarterms_handler_argument_node_nid::query in Similar By Terms 6.2
Same name and namespace in other branches
- 7.2 views/similarterms_handler_argument_node_nid.inc \similarterms_handler_argument_node_nid::query()
File
- views/
similarterms_handler_argument_node_nid.inc, line 138 - Provide node nid argument handler.
Class
- similarterms_handler_argument_node_nid
- Argument handler to accept a node id. based on node_handler_argument_node_nid except that it doesn't add a where clause to the query
Code
function query() {
$this
->ensure_my_table();
$tids = $this->tids;
$v = $this->query
->add_table('term_node');
if (count($tids) == 1) {
$this->query
->add_where(0, "term_node.tid = %d", $tids);
}
elseif (count($tids) > 1) {
$placeholders = implode(', ', array_fill(0, count($tids), '%d'));
$this->query
->add_where(0, "term_node.tid IN ({$placeholders})", $tids);
}
// exclude the current node(s)
if (empty($this->options['include_args'])) {
if (count($this->value) > 1) {
$placeholders = implode(', ', array_fill(0, count($this->value), '%d'));
$this->query
->add_where(0, "node.nid NOT IN ({$placeholders})", $this->value);
}
else {
$this->query
->add_where(0, 'node.nid != %d', $this->value[0]);
}
}
}