diff options
author | Yorhel <git@yorhel.nl> | 2011-02-06 15:18:09 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2011-02-06 15:18:09 +0100 |
commit | be9f4b48838755ee1d6cd4c1cf625f2c5d7b8802 (patch) | |
tree | 0b8c9c739fe36978d2d3998a8ed7fc85a17f6c08 /lib/VNDB | |
parent | 8b3eb97627131a9be85cf784484d8d51d9b417c0 (diff) |
Added filter selector to tag pages (excl. tags tab)
Diffstat (limited to 'lib/VNDB')
-rw-r--r-- | lib/VNDB/Handler/Tags.pm | 23 | ||||
-rw-r--r-- | lib/VNDB/Util/Misc.pm | 5 |
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm index 974754c9..af936f63 100644 --- a/lib/VNDB/Handler/Tags.pm +++ b/lib/VNDB/Handler/Tags.pm @@ -34,12 +34,14 @@ sub tagpage { { get => 'o', required => 0, default => 'd', enum => [ 'a','d' ] }, { get => 'p', required => 0, default => 1, template => 'int' }, { get => 'm', required => 0, default => -1, enum => [qw|0 1 2|] }, + { get => 'fil', required => 0 }, ); return $self->resNotFound if $f->{_err}; my $tagspoil = $self->reqCookie('tagspoil')||''; $f->{m} = $tagspoil =~ /^[0-2]$/ ? $tagspoil : 0 if $f->{m} == -1; + $f->{fil} //= $self->authPref('filter_vn'); - my($list, $np) = $t->{meta} || $t->{state} != 2 ? ([],0) : $self->filFetchDB(vn => undef, undef, { + my($list, $np) = $t->{meta} || $t->{state} != 2 ? ([],0) : $self->filFetchDB(vn => $f->{fil}, undef, { what => 'rating', results => 50, page => $f->{p}, @@ -111,23 +113,32 @@ sub tagpage { _childtags($self, $t) if @{$t->{childs}}; if(!$t->{meta} && $t->{state} == 2) { + form action => "/g$t->{id}", 'accept-charset' => 'UTF-8', method => 'get'; div class => 'mainbox'; a class => 'addnew', href => "/g/links?t=$tag", mt '_tagp_rawvotes'; h1 mt '_tagp_vnlist'; + p class => 'browseopts'; - a href => "/g$t->{id}?m=0", $f->{m} == 0 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 0);return true;", mt '_tagp_spoil0'; - a href => "/g$t->{id}?m=1", $f->{m} == 1 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 1);return true;", mt '_tagp_spoil1'; - a href => "/g$t->{id}?m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2'; + a href => "/g$t->{id}?fil=$f->{fil};m=0", $f->{m} == 0 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 0);return true;", mt '_tagp_spoil0'; + a href => "/g$t->{id}?fil=$f->{fil};m=1", $f->{m} == 1 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 1);return true;", mt '_tagp_spoil1'; + a href => "/g$t->{id}?fil=$f->{fil};m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2'; + end; + + a id => 'filselect', href => '#v'; + lit '<i>▸</i> '.mt('_js_fil_filters').'<i></i>'; end; + input type => 'hidden', class => 'hidden', name => 'fil', id => 'fil', value => $f->{fil}; + if(!@$list) { p; br; br; txt mt '_tagp_novn'; end; } p; br; txt mt '_tagp_cached'; end; end 'div'; - $self->htmlBrowseVN($list, $f, $np, "/g$t->{id}?m=$f->{m}", 1) if @$list; + end 'form'; + $self->htmlBrowseVN($list, $f, $np, "/g$t->{id}?fil=$f->{fil};m=$f->{m}", 1) if @$list; } - $self->htmlFooter; + $self->htmlFooter(prefs => ['filter_vn']); } diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm index 9f281ee7..85861f8b 100644 --- a/lib/VNDB/Util/Misc.pm +++ b/lib/VNDB/Util/Misc.pm @@ -34,9 +34,6 @@ sub filFetchDB { my $prefname = 'filter_'.$type; my $pref = $self->authPref($prefname); - # simply call the DB if we're not applying filters - return $dbfunc->($self, %$pre, %$post) if !$pref && !$overwrite; - my $filters = fil_parse $overwrite // $pref, @{$filfields{$type}}; # compatibility @@ -50,7 +47,7 @@ sub filFetchDB { exists($pre->{$_}) ? ($_ => $pre->{$_}) : (), ), @{$filfields{$type}}}) if defined $overwrite; - return $dbfunc->($self, %$pre, %$filters, %$post) if defined $overwrite; + return $dbfunc->($self, %$pre, %$filters, %$post) if defined $overwrite or !keys %$filters;; # since incorrect filters can throw a database error, we have to special-case # filters that originate from a preference setting, so that in case these are |