$shortname Doxygen Search UTF-8 END_OPENSEARCH; } function opensearch_xml_results($query, array $results) { // Much as I hate copy'n'paste code re-use, this is for testing; // I expect a richer version to come soon. // Although I hate that IE does this richer than FF more... $qs_results = array(); foreach ($results as $i => $val) { foreach ($val['words'] as $j => $word) { if (array_key_exists($word['word'], $qs_results)) $qs_results[$word['match']]++; else $qs_results[$word['match']] = 1; } } $result = << $query
END_FRAG; foreach ($qs_results as $word => $count) { $result .= << $word $count results END_FRAG; } $result .= << END_FRAG; echo $result; } function opensearch_json_results($query, array $results) { $qs_results = array(); foreach ($results as $i => $val) { foreach ($val['words'] as $j => $word) { if (array_key_exists($word['word'], $qs_results)) $qs_results[$word['match']]++; else $qs_results[$word['match']] = 1; } } $result = '["'.$query.'", ['; $json_words = ""; $json_descriptions = ""; $i = 0; foreach ($qs_results as $word => $count) { if ($i != 0) { $json_words .= ", "; $json_descriptions .= ", "; } $json_words .= '"'.$word.'"'; $json_descriptions .= '"'.$count.' result'.($count==1?'':'s').'"'; $i++; } print "[\"$query\", [$json_words],[$json_descriptions]]"; } function invalid_format($query, array $results) { print "Search results for '$query':\n\n"; print_r($results); } ?>