added six custom queries
git-svn-id: http://yolanda.mister-muffin.de/svn@320 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
dfd08fd2dd
commit
8d9a158957
6 changed files with 46 additions and 30 deletions
|
@ -11,11 +11,19 @@
|
||||||
|
|
||||||
<string id="url_root">http://localhost</string><!-- MUST NOT end with trailing slash -->
|
<string id="url_root">http://localhost</string><!-- MUST NOT end with trailing slash -->
|
||||||
|
|
||||||
|
<!-- search options -->
|
||||||
|
<string id="search_frontpage_one_query">* order:timestamp sort:descending</string>
|
||||||
|
<string id="search_frontpage_two_query">* order:viewcount sort:descending</string>
|
||||||
|
<string id="search_frontpage_three_query">* order:downloadcount sort:descending</string>
|
||||||
|
<string id="search_frontpage_size">3</string>
|
||||||
|
<string id="search_results_default">10</string>
|
||||||
|
<string id="search_results_max">500</string>
|
||||||
|
<string id="search_order_default">relevance</string><!-- a v.column in the videos table or relevance -->
|
||||||
|
<string id="search_sort_default">desc</string><!-- asc or desc -->
|
||||||
|
|
||||||
<!-- general page settings -->
|
<!-- general page settings -->
|
||||||
<string id="page_locale">en-us</string>
|
<string id="page_locale">en-us</string>
|
||||||
<string id="page_xslt">xhtml.xsl</string>
|
<string id="page_xslt">xhtml.xsl</string>
|
||||||
<string id="page_results_pagesize_default">10</string>
|
|
||||||
<string id="page_results_pagesize_max">500</string>
|
|
||||||
<string id="page_tag_lenght_min">3</string>
|
<string id="page_tag_lenght_min">3</string>
|
||||||
<string id="page_tag_count">20</string>
|
<string id="page_tag_count">20</string>
|
||||||
<string id="page_openid">true</string>
|
<string id="page_openid">true</string>
|
||||||
|
|
|
@ -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=*%20orderby:timestamp%20sort:descending</string>
|
<string id="path_query_custom_one">/search.pl?query=*%20order:timestamp%20sort:descending</string>
|
||||||
<string id="path_query_mostdownloads">/search.pl?query=*%20orderby:downloadcount%20sort:descending</string>
|
<string id="path_query_custom_two">/search.pl?query=*%20order:downloadcount%20sort:descending</string>
|
||||||
<string id="path_query_mostviews">/search.pl?query=*%20orderby:viewcount%20sort:descending</string>
|
<string id="path_query_custom_three">/search.pl?query=*%20order:viewcount%20sort:descending</string>
|
||||||
|
|
||||||
</strings>
|
</strings>
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,10 @@ sub fill_results
|
||||||
$resultcount = $sth->execute(@args) or die $dbh->errstr;
|
$resultcount = $sth->execute(@args) or die $dbh->errstr;
|
||||||
|
|
||||||
#set pagesize by query or usersettings or default
|
#set pagesize by query or usersettings or default
|
||||||
$pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = $config->{"page_results_pagesize_default"};
|
$pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = $config->{"search_results_default"};
|
||||||
|
|
||||||
#if pagesize is more than maxpagesize reduce to maxpagesize
|
#if pagesize is more than maxpagesize reduce to maxpagesize
|
||||||
$pagesize = $pagesize > $config->{"page_results_pagesize_max"} ? $config->{"page_results_pagesize_max"} : $pagesize;
|
$pagesize = $pagesize > $config->{"search_results_max"} ? $config->{"search_results_max"} : $pagesize;
|
||||||
|
|
||||||
#rediculous but funny round up, will fail with 100000000000000 results per page
|
#rediculous but funny round up, will fail with 100000000000000 results per page
|
||||||
#on 0.0000000000001% of all queries - this is a risk we can handle
|
#on 0.0000000000001% of all queries - this is a risk we can handle
|
||||||
|
@ -73,7 +73,7 @@ sub fill_results
|
||||||
$sth = $dbh->prepare($dbquery) or die $dbh->errstr;
|
$sth = $dbh->prepare($dbquery) or die $dbh->errstr;
|
||||||
|
|
||||||
#execute it
|
#execute it
|
||||||
$sth->execute(@args) or die $dbquery;
|
$sth->execute(@args) or die $dbh->errstr;
|
||||||
|
|
||||||
$results->setAttribute('lastpage', $lastpage);
|
$results->setAttribute('lastpage', $lastpage);
|
||||||
$results->setAttribute('currentpage', $currentpage);
|
$results->setAttribute('currentpage', $currentpage);
|
||||||
|
@ -179,7 +179,7 @@ sub get_sqlquery
|
||||||
my $strquery = @_[0];
|
my $strquery = @_[0];
|
||||||
$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;
|
($order) = $strquery =~ / order:(\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;
|
||||||
|
@ -191,7 +191,7 @@ sub get_sqlquery
|
||||||
#($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|order|sort):\w+//gi;
|
||||||
$strquery =~ s/^\s*(.*?)\s*$/$1/;
|
$strquery =~ s/^\s*(.*?)\s*$/$1/;
|
||||||
|
|
||||||
#build mysql query
|
#build mysql query
|
||||||
|
@ -226,35 +226,35 @@ sub get_sqlquery
|
||||||
push @args, "$publisher";
|
push @args, "$publisher";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($orderby)
|
if($order)
|
||||||
{
|
{
|
||||||
if($orderby eq 'filesize')
|
if($order eq 'filesize')
|
||||||
{
|
{
|
||||||
$dbquery .= " order by v.filesize";
|
$dbquery .= " order by v.filesize";
|
||||||
}
|
}
|
||||||
elsif($orderby eq 'duration')
|
elsif($order eq 'duration')
|
||||||
{
|
{
|
||||||
$dbquery .= " order by v.duration";
|
$dbquery .= " order by v.duration";
|
||||||
}
|
}
|
||||||
elsif($orderby eq 'viewcount')
|
elsif($order eq 'viewcount')
|
||||||
{
|
{
|
||||||
$dbquery .= " order by v.viewcount";
|
$dbquery .= " order by v.viewcount";
|
||||||
}
|
}
|
||||||
elsif($orderby eq 'downloadcount')
|
elsif($order eq 'downloadcount')
|
||||||
{
|
{
|
||||||
$dbquery .= " order by v.downloadcount";
|
$dbquery .= " order by v.downloadcount";
|
||||||
}
|
}
|
||||||
elsif($orderby eq 'timestamp')
|
elsif($order eq 'timestamp')
|
||||||
{
|
{
|
||||||
$dbquery .= " order by v.timestamp";
|
$dbquery .= " order by v.timestamp";
|
||||||
}
|
}
|
||||||
elsif($orderby eq 'relevance' and $strquery)
|
elsif($order eq 'relevance')
|
||||||
{
|
{
|
||||||
$dbquery .= " order by relevance";
|
$dbquery .= " order by relevance";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbquery .= " order by v.id";
|
$dbquery .= " order by $config->{'search_order_default'}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sort eq "ascending")
|
if($sort eq "ascending")
|
||||||
|
@ -265,6 +265,10 @@ sub get_sqlquery
|
||||||
{
|
{
|
||||||
$dbquery .= " desc";
|
$dbquery .= " desc";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$dbquery .= " $config->{'search_sort_default'}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dbquery, @args;
|
return $dbquery, @args;
|
||||||
|
|
|
@ -60,10 +60,7 @@ $sth->finish() or die $dbh->errstr;
|
||||||
|
|
||||||
$root->appendChild($tagcloud);
|
$root->appendChild($tagcloud);
|
||||||
|
|
||||||
#TODO: make this configureable
|
foreach $strquery ($config->{"search_frontpage_one_query"}, $config->{"search_frontpage_two_query"}, $config->{"search_frontpage_three_query"})
|
||||||
@querystrings = ("* orderby:timestamp sort:descending", "*", "*");
|
|
||||||
|
|
||||||
foreach $strquery (@querystrings)
|
|
||||||
{
|
{
|
||||||
#new results block
|
#new results block
|
||||||
my $results = XML::LibXML::Element->new( "results" );
|
my $results = XML::LibXML::Element->new( "results" );
|
||||||
|
@ -71,13 +68,13 @@ foreach $strquery (@querystrings)
|
||||||
|
|
||||||
#get query string and args
|
#get query string and args
|
||||||
my ($dbquery, @args) = get_sqlquery($strquery);
|
my ($dbquery, @args) = get_sqlquery($strquery);
|
||||||
$dbquery .= " limit 0, 3";
|
$dbquery .= " limit 0, $config->{'search_frontpage_size'}";
|
||||||
|
|
||||||
#prepare query
|
#prepare query
|
||||||
$sth = $dbh->prepare($dbquery) or die $dbh->errstr;
|
$sth = $dbh->prepare($dbquery) or die $dbh->errstr;
|
||||||
|
|
||||||
#execute it
|
#execute it
|
||||||
$sth->execute(@args) or die $dbquery;
|
$sth->execute(@args) or die @args;
|
||||||
|
|
||||||
#foreach result, fill appropriate results hash
|
#foreach result, fill appropriate results hash
|
||||||
while (my ($id, $title, $description, $publisher, $timestamp, $creator,
|
while (my ($id, $title, $description, $publisher, $timestamp, $creator,
|
||||||
|
|
|
@ -36,6 +36,13 @@
|
||||||
<string id="query_mostdownloads">most downloaded</string>
|
<string id="query_mostdownloads">most downloaded</string>
|
||||||
<string id="query_mostviews">popular videos</string>
|
<string id="query_mostviews">popular videos</string>
|
||||||
|
|
||||||
|
<string id="search_frontpage_one">new videos</string>
|
||||||
|
<string id="search_frontpage_two">most downloaded</string>
|
||||||
|
<string id="search_frontpage_three">popular videos</string>
|
||||||
|
<string id="search_custom_one">new videos</string>
|
||||||
|
<string id="search_custom_two">most downloaded</string>
|
||||||
|
<string id="search_custom_three">popular videos</string>
|
||||||
|
|
||||||
<!-- errors -->
|
<!-- errors -->
|
||||||
<string id="error_202c">Error 202c - Access forbidden by government.</string>
|
<string id="error_202c">Error 202c - Access forbidden by government.</string>
|
||||||
<string id="error_missing_file">You did not supply a file.</string>
|
<string id="error_missing_file">You did not supply a file.</string>
|
||||||
|
|
|
@ -39,27 +39,27 @@
|
||||||
<li id="latestadditions">
|
<li id="latestadditions">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="$site_strings[@id='path_query_latestadditions']" />
|
<xsl:value-of select="$site_strings[@id='path_query_custom_one']" />
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="$locale_strings[@id='query_latestadditions']" />
|
<xsl:value-of select="$locale_strings[@id='search_custom_one']" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li id="mostviews">
|
<li id="mostviews">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="$site_strings[@id='path_query_mostviews']" />
|
<xsl:value-of select="$site_strings[@id='path_query_custom_two']" />
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="$locale_strings[@id='query_mostviews']" />
|
<xsl:value-of select="$locale_strings[@id='search_custom_two']" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li id="mostdownloads">
|
<li id="mostdownloads">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="$site_strings[@id='path_query_mostdownloads']" />
|
<xsl:value-of select="$site_strings[@id='path_query_custom_three']" />
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="$locale_strings[@id='query_mostdownloads']" />
|
<xsl:value-of select="$locale_strings[@id='search_custom_three']" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue