function advanced_help_search in Advanced Help 5
Same name and namespace in other branches
- 6 advanced_help.module \advanced_help_search()
Implementation of hook_search()
File
- ./
advanced_help.module, line 613 - advanced_help.module
Code
function advanced_help_search($op = 'search', $keys = null) {
switch ($op) {
case 'name':
return t('Help');
case 'reset':
variable_del('advanced_help_last_cron');
return;
case 'search':
$topics = advanced_help_get_topics();
$find = do_search($keys, 'help');
if (!$find) {
return;
}
$results = array();
$placeholders = implode(', ', array_fill(0, count($find), '%d'));
foreach ($find as $item) {
$sids[] = $item->sid;
}
$result = db_query("SELECT * FROM {advanced_help_index} WHERE sid IN ({$placeholders})", $sids);
while ($sid = db_fetch_object($result)) {
// Guard against removed help topics that are still indexed.
if (empty($topics[$sid->module][$sid->topic])) {
continue;
}
$info = $topics[$sid->module][$sid->topic];
$text = advanced_help_view_topic($sid->module, $sid->topic);
$results[] = array(
'link' => advanced_help_url("help/{$sid->module}/{$sid->topic}"),
'title' => $info['title'],
'snippet' => search_excerpt($keys, $text),
);
}
return $results;
}
}