From 384fcb6467fdc3cd592f28619121cd7d483a50df Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 5 Nov 2007 16:24:17 +0000 Subject: [PATCH] added tag search, a few improvements on the results page git-svn-id: http://yolanda.mister-muffin.de/svn@176 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/functions.pl | 2 +- trunk/locale/en-us.xml | 6 +++--- trunk/search.pl | 17 +++++++++++++++-- trunk/xsl/xhtml.xsl | 6 +++++- trunk/xsl/xhtml/results.xsl | 6 +++--- trunk/xsl/xhtml/video.xsl | 4 ++++ 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/trunk/functions.pl b/trunk/functions.pl index e766fbe..b5fdbf9 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -17,7 +17,7 @@ sub fill_tagcloud while (my ($text, $count) = $sth->fetchrow_array()) { #push the new value to the $page->tagcloud array - push @{ $page->{tagcloud}->{tag} }, { text => [$text], count => [$count] }; + push @{ $page->{tagcloud}->{tag} }, { text => [$text =~ / / ? "\"$text\"" : $text], count => [$count] }; } #finish query diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml index 37768f2..d802048 100755 --- a/trunk/locale/en-us.xml +++ b/trunk/locale/en-us.xml @@ -67,9 +67,9 @@ results for query - ordered by - ascending - descending + ordered by + ascending + descending results on pages relevance diff --git a/trunk/search.pl b/trunk/search.pl index 8aa1f17..d69227e 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -22,23 +22,36 @@ if($query->param('query') or $query->param('orderby')) my @args = (); + $strquery = $query->param('query'); + push @tags, $strquery =~ /tag:"([^"]+)"/gi; + push @tags, $strquery =~ /tag:(\w+)/gi; + $strquery =~ s/(tag|title):"[^"]+"//gi; + $strquery =~ s/(tag|title):\w+//gi; + $strquery =~ s/^\s*(.*?)\s*$/$1/; + #build mysql query $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ), v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights, v.license, filesize, duration, width, height, fps, viewcount, downloadcount"; - if($query->param('query')) + if($strquery) { $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 .= " and match(v.title, v.description, v.subject) against( ? in boolean mode)"; - push @args, $query->param('query'), $query->param('query'); + push @args, $strquery, $strquery; } else { $dbquery .= " from videos as v, users as u where u.id = v.userid"; } + if(@tags) + { + $dbquery .= " and match(v.subject) against (? in boolean mode)"; + push @args, "@tags"; + } + if($query->param('orderby')) { if($query->param('orderby') eq 'filesize') diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl index 8fd92ab..99a6ed0 100755 --- a/trunk/xsl/xhtml.xsl +++ b/trunk/xsl/xhtml.xsl @@ -289,7 +289,11 @@
: - + + + + +
diff --git a/trunk/xsl/xhtml/results.xsl b/trunk/xsl/xhtml/results.xsl index f291668..a395247 100644 --- a/trunk/xsl/xhtml/results.xsl +++ b/trunk/xsl/xhtml/results.xsl @@ -79,9 +79,9 @@
- - - "" + + +
diff --git a/trunk/xsl/xhtml/video.xsl b/trunk/xsl/xhtml/video.xsl index d88a6f3..82981d9 100644 --- a/trunk/xsl/xhtml/video.xsl +++ b/trunk/xsl/xhtml/video.xsl @@ -7,6 +7,10 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > + + + +