function smartqueue_taxonomy_nodequeue_autocomplete in Nodequeue 6.2
Same name and namespace in other branches
- 7.2 modules/smartqueue/smartqueue.module \smartqueue_taxonomy_nodequeue_autocomplete()
Implementation of hook_nodequeue_autocomplete().
File
- ./
smartqueue.module, line 294
Code
function smartqueue_taxonomy_nodequeue_autocomplete($queue, $subqueue, $string, $where, $where_args) {
$matches = array();
// Get any descendant term IDs.
// @see taxonomy_select_nodes().
$tid = $subqueue->reference;
$term = taxonomy_get_term($tid);
$tree = taxonomy_get_tree($term->vid, $tid, -1, NULL);
$tids = array_merge(array(
$tid,
), array_map('_taxonomy_get_tid_from_term', $tree));
$placeholders = db_placeholders($tids, 'int');
// Prepend taxonomy term tids onto where_args array ready for db_query.
foreach ($tids as $tid) {
array_unshift($where_args, $tid);
}
// Disable language selection temporarily, enable it again later.
if (module_exists('i18n')) {
i18n_selection_mode('off');
}
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.tnid FROM {node} n\n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN ({$placeholders}) AND " . $where), $where_args, 0, variable_get('nodequeue_autocomplete_limit', 10));
if (module_exists('i18n')) {
i18n_selection_mode('reset');
}
while ($node = db_fetch_object($result)) {
$id = nodequeue_get_content_id($queue, $node);
$matches[$id] = check_plain($node->title) . " [nid: {$id}]";
}
return $matches;
}