Here is my working code: (red marked is for 3.0x)
# +----------------------------------------------------------------------+
# | Copyright (c) 2004 Iyengar Yoga Resources |
# +----------------------------------------------------------------------+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
# | you may not use this file except in compliance with the License. |
# | You may obtain a copy of the License at |
# | http://www.apache.org/licenses/LICENSE-2.0 |
# | Unless required by applicable law or agreed to in writing, software |
# | distributed under the License is distributed on an "AS IS" BASIS, |
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
# | implied. See the License for the specific language governing |
# | permissions and limitations under the License. |
# +----------------------------------------------------------------------+
# | Author: Ivan Herger <info@iyengar-yoga.com>
# | Adpted to GLinks 3.x by John Gotze <john@slashdemocracy.org |
# +----------------------------------------------------------------------+
use strict;
use lib '/home/cgi-bin/admin';
use Links qw/$CFG $DB $IN/;
local $SIG{__DIE__} = \&Links::fatal;
Links::init('/home/cgi-bin/admin');
main();
sub main {
my $t = $DB->table('SearchLogs');
$t->select_options('ORDER by slog_hits DESC', 'LIMIT 10');
my $q = $IN->param('query');
my $cond = GT::SQL::Condition->new( 'slog_query', 'LIKE', "$q%");
my $sth = $t->select($cond);
my $base = 'http://slashdemocracy.org/cgi-bin/search.cgi?query';
print "Content-Type: text/xml\n\n";
if ($t->hits) {
print qq|<ul class="LSRes">|;
while (my $result = $sth->fetchrow_hashref) {
print qq|<li onmouseover="liveSearchHover(this)" onclick="liveSearchClicked(this)"><a href="$base=$result->{slog_query}" name="$result->{slog_query}">$result->{slog_query}</a> <span style="color:green;overflow:hidden;">$result->{slog_hits} results</span></li>\n|;
}
print qq|</ul>|;
}
}
HTH
John
Code:
#!/usr/bin/perl # +----------------------------------------------------------------------+
# | Copyright (c) 2004 Iyengar Yoga Resources |
# +----------------------------------------------------------------------+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
# | you may not use this file except in compliance with the License. |
# | You may obtain a copy of the License at |
# | http://www.apache.org/licenses/LICENSE-2.0 |
# | Unless required by applicable law or agreed to in writing, software |
# | distributed under the License is distributed on an "AS IS" BASIS, |
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
# | implied. See the License for the specific language governing |
# | permissions and limitations under the License. |
# +----------------------------------------------------------------------+
# | Author: Ivan Herger <info@iyengar-yoga.com>
# | Adpted to GLinks 3.x by John Gotze <john@slashdemocracy.org |
# +----------------------------------------------------------------------+
use strict;
use lib '/home/cgi-bin/admin';
use Links qw/$CFG $DB $IN/;
local $SIG{__DIE__} = \&Links::fatal;
Links::init('/home/cgi-bin/admin');
main();
sub main {
my $t = $DB->table('SearchLogs');
$t->select_options('ORDER by slog_hits DESC', 'LIMIT 10');
my $q = $IN->param('query');
my $cond = GT::SQL::Condition->new( 'slog_query', 'LIKE', "$q%");
my $sth = $t->select($cond);
my $base = 'http://slashdemocracy.org/cgi-bin/search.cgi?query';
print "Content-Type: text/xml\n\n";
if ($t->hits) {
print qq|<ul class="LSRes">|;
while (my $result = $sth->fetchrow_hashref) {
print qq|<li onmouseover="liveSearchHover(this)" onclick="liveSearchClicked(this)"><a href="$base=$result->{slog_query}" name="$result->{slog_query}">$result->{slog_query}</a> <span style="color:green;overflow:hidden;">$result->{slog_hits} results</span></li>\n|;
}
print qq|</ul>|;
}
}
HTH
John