asterisk for empty search query

git-svn-id: http://yolanda.mister-muffin.de/svn@306 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2008-04-16 13:32:20 +00:00
parent 3677f99dda
commit c0ec756d50
2 changed files with 77 additions and 70 deletions

View file

@ -18,9 +18,9 @@ if($query->param('query'))
$strquery = $query->param('query'); $strquery = $query->param('query');
$strquery =~ s/%([0-9A-F]{2})/chr(hex($1))/eg; $strquery =~ s/%([0-9A-F]{2})/chr(hex($1))/eg;
(@tags) = $strquery =~ /tag:(\w+)/gi; (@tags) = $strquery =~ / tag:(\w+)/gi;
($orderby) = $strquery =~ /orderby:(\w+)/i; ($orderby) = $strquery =~ / orderby:(\w+)/i;
($sort) = $strquery =~ /sort:(\w+)/i; ($sort) = $strquery =~ / sort:(\w+)/i;
#($title) = $strquery =~ /title:(\w+)/i; #($title) = $strquery =~ /title:(\w+)/i;
#($description) = $strquery =~ /description:(\w+)/i; #($description) = $strquery =~ /description:(\w+)/i;
#($creator) = $strquery =~ /creator:(\w+)/i; #($creator) = $strquery =~ /creator:(\w+)/i;
@ -31,7 +31,7 @@ if($query->param('query'))
#($filesize) = $strquery =~ /filesize:([<>]?\w+)/i; #($filesize) = $strquery =~ /filesize:([<>]?\w+)/i;
#($duration) = $strquery =~ /duration:([<>]?\w+)/i; #($duration) = $strquery =~ /duration:([<>]?\w+)/i;
#($timestamp) = $strquery =~ /timestamp:([<>]?\w+)/i; #($timestamp) = $strquery =~ /timestamp:([<>]?\w+)/i;
$strquery =~ s/(tag|orderby|sort):\w+//gi; $strquery =~ s/ (tag|orderby|sort):\w+//gi;
$strquery =~ s/^\s*(.*?)\s*$/$1/; $strquery =~ s/^\s*(.*?)\s*$/$1/;
#build mysql query #build mysql query
@ -41,16 +41,18 @@ if($query->param('query'))
duration, width, height, fps, viewcount, downloadcount"; duration, width, height, fps, viewcount, downloadcount";
if($strquery) if($strquery)
{
if($strquery eq "*")
{
$dbquery .= " from videos as v, users as u where u.id = v.userid";
}
else
{ {
$dbquery .= ", match(v.title, v.description, v.subject) against( ? in boolean mode) as relevance"; $dbquery .= ", match(v.title, v.description, v.subject) against( ? in boolean mode) as relevance";
$dbquery .= " from videos as v, users as u where u.id = v.userid"; $dbquery .= " from videos as v, users as u where u.id = v.userid";
$dbquery .= " and match(v.title, v.description, v.subject) against( ? in boolean mode)"; $dbquery .= " and match(v.title, v.description, v.subject) against( ? in boolean mode)";
push @args, $strquery, $strquery; push @args, $strquery, $strquery;
} }
else
{
$dbquery .= " from videos as v, users as u where u.id = v.userid";
}
if(@tags) if(@tags)
{ {
@ -119,6 +121,11 @@ if($query->param('query'))
{ {
print output_page(); print output_page();
} }
}
else
{
print $query->redirect("index.pl?error=error_no_query");
}
} }
elsif($query->param('advanced')) elsif($query->param('advanced'))
{ {

View file

@ -22,9 +22,9 @@
<string id="path_root">http://localhost/</string> <string id="path_root">http://localhost/</string>
<string id="path_upload">/upload.pl</string> <string id="path_upload">/upload.pl</string>
<string id="path_uploader">/uploader.pl</string> <string id="path_uploader">/uploader.pl</string>
<string id="path_query_latestadditions">/search.pl?query=orderby:timestamp%20sort:descending</string> <string id="path_query_latestadditions">/search.pl?query=*%20orderby:timestamp%20sort:descending</string>
<string id="path_query_mostdownloads">/search.pl?query=orderby:downloadcount%20sort:descending</string> <string id="path_query_mostdownloads">/search.pl?query=*%20orderby:downloadcount%20sort:descending</string>
<string id="path_query_mostviews">/search.pl?query=orderby:viewcount%20sort:descending</string> <string id="path_query_mostviews">/search.pl?query=*%20orderby:viewcount%20sort:descending</string>
</strings> </strings>