summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/Releases.pm2
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm112
2 files changed, 37 insertions, 77 deletions
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 497c96de..cd3ea73c 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -511,7 +511,7 @@ sub browse {
div class => 'mainbox';
h1 mt '_rbrowse_title';
$self->htmlSearchBox('r', $f->{q});
- a id => 'filselect', href => '#';
+ a id => 'filselect', href => '#r';
lit '<i>&#9656;</i> '.mt('_rbrowse_filters').'<i></i>';
end;
input type => 'hidden', class => 'hidden', name => 'fil', id => 'fil', value => $f->{fil};
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index f3193b57..3a8ae7d5 100644
--- a/lib/VNDB/Handler/VNBrowse.pm
+++ b/lib/VNDB/Handler/VNBrowse.pm
@@ -21,14 +21,12 @@ sub list {
{ name => 'p', required => 0, default => 1, template => 'int' },
{ name => 'q', required => 0, default => '' },
{ name => 'sq', required => 0, default => '' },
- { name => 'ln', required => 0, multi => 1, enum => $self->{languages}, default => '' },
- { name => 'pl', required => 0, multi => 1, enum => $self->{platforms}, default => '' },
- { name => 'ti', required => 0, default => '', maxlength => 200 },
- { name => 'te', required => 0, default => '', maxlength => 200 },
- { name => 'sp', required => 0, default => $self->reqCookie($self->{cookie_prefix}.'tagspoil') =~ /^([0-2])$/ ? $1 : 0, enum => [0..2] },
+ { name => 'fil',required => 0, default => '' },
);
return 404 if $f->{_err};
$f->{q} ||= $f->{sq};
+ my $fil = fil_parse $f->{fil}, qw|taginc tagexc tagspoil lang plat|;
+ _fil_compat($self, $fil);
if($f->{q}) {
return $self->resRedirect('/'.$1.$2.(!$3 ? '' : $1 eq 'd' ? '#'.$3 : '.'.$3), 'temp')
@@ -37,9 +35,11 @@ sub list {
# for URL compatibilty with older versions (ugly hack to get English strings)
my @lang;
$f->{q} =~ s/\s*$VNDB::L10N::en::Lexicon{"_lang_$_"}\s*//&&push @lang, $_ for (@{$self->{languages}});
- $f->{ln} = $f->{ln}[0] ? [ @{$f->{ln}}, @lang ] : \@lang;
+ $fil->{lang} = $fil->{lang} ? [ ref($fil->{lang}) ? @{$fil->{lang}} : $fil->{lang}, @lang ] : \@lang;
}
+ $f->{fil} = fil_serialize $fil;
+ # TODO: this should be moved to dbVNGet() in order for savable VN filters to be useful
my @ignored;
my $tagfind = sub {
return map {
@@ -47,10 +47,10 @@ sub list {
push @ignored, [$_, 0] if !$i;
push @ignored, [$_, 1] if $i && $i->{meta};
$i && !$i->{meta} ? $i->{id} : ();
- } grep $_, split /\s*,\s*/, $_[0];
+ } grep $_, ref $_[0] ? @{$_[0]} : ($_[0]||'')
};
- my @ti = $tagfind->($f->{ti});
- my @te = $tagfind->($f->{te});
+ my @ti = $tagfind->(delete $fil->{taginc});
+ my @te = $tagfind->(delete $fil->{tagexc});
$f->{s} = 'title' if !@ti && $f->{s} eq 'tagscore';
$f->{o} = $f->{s} eq 'tagscore' ? 'd' : 'a' if !$f->{o};
@@ -62,28 +62,15 @@ sub list {
results => 50,
page => $f->{p},
sort => $f->{s}, reverse => $f->{o} eq 'd',
- $f->{pl}[0] ? ( platform => $f->{pl} ) : (),
- $f->{ln}[0] ? ( lang => $f->{ln} ) : (),
- @ti ? (tags_include => [ $f->{sp}, \@ti ]) : (),
+ @ti ? (tags_include => [ delete $fil->{tagspoil}, \@ti ]) : (),
@te ? (tags_exclude => \@te) : (),
+ %$fil
);
$self->resRedirect('/v'.$list->[0]{id}, 'temp')
if $f->{q} && @$list == 1 && $f->{p} == 1;
$self->htmlHeader(title => mt('_vnbrowse_title'), search => $f->{q});
- _filters($self, $f, $char, \@ignored);
-
- my $url = "/v/$char?q=$f->{q};ti=$f->{ti};te=$f->{te}";
- $_ and $url .= ";pl=$_" for @{$f->{pl}};
- $_ and $url .= ";ln=$_" for @{$f->{ln}};
- $self->htmlBrowseVN($list, $f, $np, $url, scalar @ti);
- $self->htmlFooter;
-}
-
-
-sub _filters {
- my($self, $f, $char, $ign) = @_;
form action => '/v/all', 'accept-charset' => 'UTF-8', method => 'get';
div class => 'mainbox';
@@ -95,68 +82,41 @@ sub _filters {
}
end;
- if(@$ign) {
+ if(@ignored) {
div class => 'warning';
h2 mt '_vnbrowse_tagign_title';
ul;
- li $_->[0].' ('.mt('_vnbrowse_tagign_'.($_->[1]?'meta':'notfound')).')' for @$ign;
+ li $_->[0].' ('.mt('_vnbrowse_tagign_'.($_->[1]?'meta':'notfound')).')' for @ignored;
end;
end;
}
- a id => 'advselect', href => '#';
- lit '<i>&#9656;</i> '.mt('_vnbrowse_advsearch');
+ a id => 'filselect', href => '#v';
+ lit '<i>&#9656;</i> '.mt('_rbrowse_filters').'<i></i>'; # TODO: it's not *r*browse
end;
- div id => 'advoptions', class => 'hidden vnoptions';
-
- h2;
- txt mt '_vnbrowse_tags';
- b ' ('.mt('_vnbrowse_booland').')';
- end;
- table class => 'formtable', style => 'margin-left: 0';
- $self->htmlFormPart($f, [ input => short => 'ti', name => mt('_vnbrowse_taginc'), width => 350 ]);
- $self->htmlFormPart($f, [ radio => short => 'sp', name => '', options => [map [$_, mt '_vnbrowse_spoil'.$_], 0..2]]);
- $self->htmlFormPart($f, [ input => short => 'te', name => mt('_vnbrowse_tagexc'), width => 350 ]);
- end;
-
- h2;
- txt mt '_vnbrowse_lang';
- b ' ('.mt('_vnbrowse_boolor').')';
- end;
- for my $i (@{$self->{languages}}) {
- span;
- input type => 'checkbox', name => 'ln', value => $i, id => "lang_$i",
- (scalar grep $_ eq $i, @{$f->{ln}}) ? (checked => 'checked') : ();
- label for => "lang_$i";
- cssicon "lang $i", mt "_lang_$i";
- txt mt "_lang_$i";
- end;
- end;
- }
+ input type => 'hidden', class => 'hidden', name => 'fil', id => 'fil', value => $f->{fil};
+ end;
+ end; # /form
- h2;
- txt mt '_vnbrowse_plat';
- b ' ('.mt('_vnbrowse_boolor').')';
- end;
- for my $i (sort @{$self->{platforms}}) {
- next if $i eq 'oth';
- span;
- input type => 'checkbox', id => "plat_$i", name => 'pl', value => $i,
- (scalar grep $_ eq $i, @{$f->{pl}}) ? (checked => 'checked') : ();
- label for => "plat_$i";
- cssicon $i, mt "_plat_$i";
- txt mt "_plat_$i";
- end;
- end;
- }
+ $self->htmlBrowseVN($list, $f, $np, "/v/$char?q=$f->{q};fil=$f->{fil}", scalar @ti);
+ $self->htmlFooter;
+}
- div style => 'text-align: center; clear: left;';
- input type => 'submit', value => mt('_vnbrowse_apply'), class => 'submit';
- input type => 'reset', value => mt('_vnbrowse_clear'), class => 'submit', onclick => 'location.href="/v/all"';
- end;
- end;
- end;
- end;
+
+sub _fil_compat {
+ my($self, $fil) = @_;
+ my $f = $self->formValidate(
+ { name => 'ln', required => 0, multi => 1, enum => $self->{languages}, default => '' },
+ { name => 'pl', required => 0, multi => 1, enum => $self->{platforms}, default => '' },
+ { name => 'ti', required => 0, default => '', maxlength => 200 },
+ { name => 'te', required => 0, default => '', maxlength => 200 },
+ { name => 'sp', required => 0, default => $self->reqCookie($self->{cookie_prefix}.'tagspoil') =~ /^([0-2])$/ ? $1 : 0, enum => [0..2] },
+ );
+ $fil->{lang} //= $f->{ln} if $f->{ln}[0];
+ $fil->{plat} //= $f->{pl} if $f->{pl}[0];
+ $fil->{taginc} //= $f->{ti} if $f->{ti};
+ $fil->{tagexc} //= $f->{te} if $f->{te};
+ $fil->{tagspoil} //= $f->{sp};
}