diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/DB/Chars.pm | 19 | ||||
-rw-r--r-- | lib/VNDB/Handler/Chars.pm | 20 | ||||
-rw-r--r-- | lib/VNDB/Handler/Traits.pm | 15 | ||||
-rw-r--r-- | lib/VNDB/Util/Misc.pm | 5 |
4 files changed, 43 insertions, 16 deletions
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm index be620378..634e0078 100644 --- a/lib/VNDB/DB/Chars.pm +++ b/lib/VNDB/DB/Chars.pm @@ -8,7 +8,8 @@ use Exporter 'import'; our @EXPORT = qw|dbCharGet dbCharRevisionInsert dbCharImageId|; -# options: id rev instance traitspoil trait_inc trait_exc char what results page +# options: id rev instance tagspoil trait_inc trait_exc char what results page gender bloodt +# bust_min bust_max waist_min waist_max hip_min hip_max height_min height_max weight_min weight_max # what: extended traits vns changes sub dbCharGet { my $self = shift; @@ -16,7 +17,7 @@ sub dbCharGet { page => 1, results => 10, what => '', - traitspoil => 0, + tagspoil => 0, @_ ); @@ -29,6 +30,18 @@ sub dbCharGet { $o{notid} ? ( 'c.id <> ?' => $o{notid} ) : (), $o{instance} ? ( 'cr.main = ?' => $o{instance} ) : (), $o{vid} ? ( 'cr.id IN(SELECT cid FROM chars_vns WHERE vid = ?)' => $o{vid} ) : (), + defined $o{gender} ? ( 'cr.gender IN(!l)' => [ ref $o{gender} ? $o{gender} : [$o{gender}] ]) : (), + defined $o{bloodt} ? ( 'cr.bloodt IN(!l)' => [ ref $o{bloodt} ? $o{bloodt} : [$o{bloodt}] ]) : (), + defined $o{bust_min} ? ( 'cr.s_bust >= ?' => $o{bust_min} ) : (), + defined $o{bust_max} ? ( 'cr.s_bust <= ? AND cr.s_bust > 0' => $o{bust_max} ) : (), + defined $o{waist_min} ? ( 'cr.s_waist >= ?' => $o{waist_min} ) : (), + defined $o{waist_max} ? ( 'cr.s_waist <= ? AND cr.s_waist > 0' => $o{waist_max} ) : (), + defined $o{hip_min} ? ( 'cr.s_hip >= ?' => $o{hip_min} ) : (), + defined $o{hip_max} ? ( 'cr.s_hip <= ? AND cr.s_hip > 0' => $o{hip_max} ) : (), + defined $o{height_min} ? ( 'cr.height >= ?' => $o{height_min} ) : (), + defined $o{height_max} ? ( 'cr.height <= ? AND cr.height > 0' => $o{height_max} ) : (), + defined $o{weight_min} ? ( 'cr.weight >= ?' => $o{weight_min} ) : (), + defined $o{weight_max} ? ( 'cr.weight <= ? AND cr.weight > 0' => $o{weight_max} ) : (), $o{search} ? ( '(cr.name ILIKE ? OR cr.original ILIKE ? OR cr.alias ILIKE ?)', [ map '%%'.$o{search}.'%%', 1..3 ] ) : (), $o{char} ? ( @@ -37,7 +50,7 @@ sub dbCharGet { '(ASCII(cr.name) < 97 OR ASCII(cr.name) > 122) AND (ASCII(cr.name) < 65 OR ASCII(cr.name) > 90)' => 1 ) : (), $o{trait_inc} ? ( 'c.id IN(SELECT cid FROM traits_chars WHERE tid IN(!l) AND spoil <= ? GROUP BY cid HAVING COUNT(tid) = ?)', - [ ref $o{trait_inc} ? $o{trait_inc} : [$o{trait_inc}], $o{traitspoil}, ref $o{trait_inc} ? $#{$o{trait_inc}}+1 : 1 ]) : (), + [ ref $o{trait_inc} ? $o{trait_inc} : [$o{trait_inc}], $o{tagspoil}, ref $o{trait_inc} ? $#{$o{trait_inc}}+1 : 1 ]) : (), $o{trait_exc} ? ( 'c.id NOT IN(SELECT cid FROM traits_chars WHERE tid IN(!l))' => [ ref $o{trait_exc} ? $o{trait_exc} : [$o{trait_exc}] ] ) : (), ); diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index 9c8a1b5e..c707a453 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -451,33 +451,39 @@ sub list { my($self, $fch) = @_; my $f = $self->formValidate( - { get => 'p', required => 0, default => 1, template => 'int' }, - { get => 'q', required => 0, default => '' }, + { get => 'p', required => 0, default => 1, template => 'int' }, + { get => 'q', required => 0, default => '' }, + { get => 'fil', required => 0, default => '' }, ); return $self->resNotFound if $f->{_err}; - my($list, $np) = $self->dbCharGet( + my($list, $np) = $self->filFetchDB(char => $f->{fil}, {}, { $fch ne 'all' ? ( char => $fch ) : (), $f->{q} ? ( search => $f->{q} ) : (), results => 50, page => $f->{p}, what => 'vns', - ); + }); $self->htmlHeader(title => mt '_charb_title'); my $quri = uri_escape($f->{q}); + form action => '/c/all', 'accept-charset' => 'UTF-8', method => 'get'; div class => 'mainbox'; h1 mt '_charb_title'; - form action => '/c/all', 'accept-charset' => 'UTF-8', method => 'get'; - $self->htmlSearchBox('c', $f->{q}); - end; + $self->htmlSearchBox('c', $f->{q}); p class => 'browseopts'; for ('all', 'a'..'z', 0) { a href => "/c/$_?q=$quri", $_ eq $fch ? (class => 'optselected') : (), $_ eq 'all' ? mt('_char_all') : $_ ? uc $_ : '#'; } end; + + a id => 'filselect', href => '#c'; + lit '<i>▸</i> '.mt('_js_fil_filters').'<i></i>'; + end; + input type => 'hidden', class => 'hidden', name => 'fil', id => 'fil', value => $f->{fil}; end; + end 'form'; if(!@$list) { div class => 'mainbox'; diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm index f3abdfeb..0a21011c 100644 --- a/lib/VNDB/Handler/Traits.pm +++ b/lib/VNDB/Handler/Traits.pm @@ -27,6 +27,7 @@ sub traitpage { my $f = $self->formValidate( { get => 'p', required => 0, default => 1, template => 'int' }, { get => 'm', required => 0, default => undef, enum => [qw|0 1 2|] }, + { get => 'fil', required => 0, default => '' }, ); return $self->resNotFound if $f->{_err}; my $tagspoil = $self->reqCookie('tagspoil')||''; @@ -83,14 +84,15 @@ sub traitpage { childtags($self, mt('_traitp_childs'), 'i', $t) if @{$t->{childs}}; if(!$t->{meta} && $t->{state} == 2) { - my($chars, $np) = $self->dbCharGet( + my($chars, $np) = $self->filFetchDB(char => $f->{fil}, {}, { trait_inc => $trait, - traitspoil => $f->{m}, + tagspoil => $f->{m}, results => 50, page => $f->{p}, what => 'vns', - ); + }); + form action => "/i$t->{id}", 'accept-charset' => 'UTF-8', method => 'get'; div class => 'mainbox'; h1 mt '_traitp_charlist'; @@ -101,12 +103,17 @@ sub traitpage { a href => "/i$trait?m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2'; end; + a id => 'filselect', href => '#c'; + lit '<i>▸</i> '.mt('_js_fil_filters').'<i></i>'; + end; + input type => 'hidden', class => 'hidden', name => 'fil', id => 'fil', value => $f->{fil}; + if(!@$chars) { p; br; br; txt mt '_traitp_nochars'; end; } p; br; txt mt '_traitp_cached'; end; end 'div'; - + end 'form'; @$chars && $self->charBrowseTable($chars, $np, $f, "/i$trait?m=$f->{m}"); } diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm index 5406fe06..b7df11c3 100644 --- a/lib/VNDB/Util/Misc.pm +++ b/lib/VNDB/Util/Misc.pm @@ -13,11 +13,12 @@ our @EXPORT = qw|filFetchDB ieCheck|; my %filfields = ( vn => [qw|length hasani tag_inc tag_exc taginc tagexc tagspoil lang olang plat ul_notblack ul_onwish ul_voted ul_onlist|], release => [qw|type patch freeware doujin date_before date_after released minage lang olang resolution plat med voiced ani_story ani_ero|], + char => [qw|gender bloodt bust_min bust_max waist_min waist_max hip_min hip_max height_min height_max weight_min weight_max trait_inc trait_exc tagspoil|], ); # Arguments: -# type ('vn' or 'release'), +# type ('vn', 'release' or 'char'), # filter overwrite (string or undef), # when defined, these filters will be used instead of the preferences, # must point to a variable, will be modified in-place with the actually used filters @@ -30,7 +31,7 @@ sub filFetchDB { my($self, $type, $overwrite, $pre, $post) = @_; $pre = {} if !$pre; $post = {} if !$post; - my $dbfunc = $self->can($type eq 'vn' ? 'dbVNGet' : 'dbReleaseGet'); + my $dbfunc = $self->can($type eq 'vn' ? 'dbVNGet' : $type eq 'release' ? 'dbReleaseGet' : 'dbCharGet'); my $prefname = 'filter_'.$type; my $pref = $self->authPref($prefname); |