function search_service_nodes in Services 7
Same name and namespace in other branches
- 6 services/search_service/search_service.inc \search_service_nodes()
- 6.2 services/search_service/search_service.inc \search_service_nodes()
Callback for search.nodes service.
1 string reference to 'search_service_nodes'
- search_service_service in services/
search_service/ search_service.module - Implementation of hook_service().
File
- services/
search_service/ search_service.inc, line 11 - @author Services Dev Team
Code
function search_service_nodes($keys, $simple = FALSE, $fields = array()) {
// define standard keys for simple set
$stdkeys = array(
'node',
'link',
'type',
'title',
'user',
'date',
'snippet',
);
// invoke the search hook to generate results
$results = module_invoke('node', 'search', 'search', $keys);
if ($results && is_array($results) && count($results)) {
// if simple results requested, remove extra data
if ($simple) {
$num = count($results);
for ($i = 0; $i < $num; $i++) {
$keys = array_keys($results[$i]);
foreach ($keys as $key) {
if ($key == 'node') {
$results[$i][$key] = $results[$i]['node']->nid;
}
if (!in_array($key, $stdkeys)) {
unset($results[$i][$key]);
}
}
}
}
else {
foreach ($results as $key => $result) {
$result['node'] = services_node_load($result['node'], $fields);
$results[$key] = $result;
}
}
return $results;
}
return services_error(t('Search returned no results.'), 404);
}