function finder_node_finder_find in Finder 6
Same name and namespace in other branches
- 7 modules/finder_node/finder_node.module \finder_node_finder_find()
Implementation of hook_finder_find().
See also
File
- modules/
finder_node/ finder_node.module, line 146 - The finder node module.
Code
function finder_node_finder_find($finder, $finder_element_id, $keywords, $mode, $match, $pager) {
foreach ($keywords as $feid => $keyword_array) {
$element =& finder_element($finder, $feid);
$types[$feid] =& $element->settings['choices']['node_types'];
$published[$feid] =& $element->settings['choices']['published'];
// restrict by types
unset($types[$feid]['']);
if (!empty($types[$feid])) {
if ($feid == $finder_element_id) {
$query['wheres'][] = "node.type IN (" . db_placeholders(array_keys($types[$feid]), 'text') . ")";
}
else {
$query['wheres']['restrictions'][$feid][] = "node.type IN (" . db_placeholders(array_keys($types[$feid]), 'text') . ")";
}
$query['arguments'] = isset($query['arguments']) ? array_merge($query['arguments'], array_keys($types[$feid])) : array_keys($types[$feid]);
}
}
// restrict to published nodes if required
if (in_array(1, $published)) {
$query['wheres'][] = 'node.status = 1';
}
$join_ons = array(
'node_revisions' => array(
'node_revisions' => 'node_revisions.vid = node.vid',
),
'node_type' => array(
'node_type' => 'node_type.type = node.type',
),
'users' => array(
'users' => 'users.uid = node.uid',
),
);
$base_table = 'node';
$base_field = 'nid';
$query = finder_find_query($query, $finder, $finder_element_id, $keywords, $mode, $match, $pager, $join_ons, $base_table, $base_field);
return finder_query($query);
}