this is a hack that uses search-as-you-type to provide quick search
copy and paste the following code to a file named responder.php saved
in the same folder as search-responder.php
<?php
function format($keyword, $result) {
return count($result) == 1 ?
array(
'query' => $keyword,
'results' => $result,
'autocompletedQuery' => $result[0]['name']
)
: array(
'query' => $keyword,
'results' => $result
);
}
function parse($query) {
$document = new DOMDocument();
$document->loadXML($query);
return parse_resouces($document->getElementsByTagName('RES'));
}
function parse_record($record) {
return array(
'name' => read_tag($record->getElementsByTagName('T')),
'type' => 'Suggestions',
'content' => read_content(
read_tag($record->getElementsByTagName('T')),
read_tag($record->getElementsByTagName('S'))
),
'moreDetailsUrl' => read_tag($record->getElementsByTagName
('U')),
'style' => 'expanded'
);
}
function parse_resouces($resources) {
$result = array();
if($resources->length != 0) {
for($resource_index = 0;
$resource_index < $resources->length;
$resource_index++) {
for($child_index = 0,
$child_list = $resources->item($resource_index)-
>childNodes;
$child_index < $child_list->length;
$child_index++) {
if(strtolower($child_list->item($child_index)-
>tagName) == 'r') {
$result[] = parse_record($child_list->item
($child_index));
}
}
}
}
return $result;
}
function query($keyword) {
return file_get_contents(sprintf(
'
http://192.168.1.28/search?'
. 'q=%s'
. '&getfields=*'
. '&access=%s'
. '&client=%s'
. '&num=5'
. '&filter=0'
. '&output=xml_no_dtd'
. '&site=%s',
urlencode($keyword),
'p',
'default_frontend',
'default_collection'
));
}
function read_content($title, $snippet) {
return sprintf('<h1>%s</h1><br /><span type="summary">%s</span>',
$title, $snippet);
}
function read_tag($tag) {
$result = array();
for($tag_index = 0;
$tag_index < $tag->length;
$tag_index++) {
for($child_index = 0,
$child_list = $tag->item($tag_index)->childNodes;
$child_index < $child_list->length;
$child_index++) {
$result[] = strip_tags($child_list->item($child_index)-
>wholeText);
}
}
return implode(' - ', $result);
}
function output($result) {
return sprintf(
'searchAsYouType.handleAjaxResponse(%s)',
json_encode($result)
);
}
echo output(format($_GET['query'], parse(query($_GET['query']))));
// file ends
Then change search-as-you-type.js and replace search-responder.php to
responder.php at about line 31
// The fully qualified URL to the Ajax responder.
// e.g.
http://intranet.company.com/search-as-you-type/responder.php
ajaxResponderUrl:
"url/to/responder.php",
Then everything should just work. I do not have much time to provide
support to this script, however, you can always reply to this thread
if you are in doubt XD