summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Tags.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-11-27 12:02:25 +0100
committerYorhel <git@yorhel.nl>2009-11-27 12:02:25 +0100
commite69b417f9ce6e73e6c1a477048d167f9490f9d5a (patch)
tree04164691c32897d64d626037aa16accd287c93d5 /lib/VNDB/Handler/Tags.pm
parent4b6421198ab810375b6d152f0eb581a01c1017b5 (diff)
Display VN ratings on tag pages as well
With this method I managed to reuse the VN list table code for the lists on both the VN browser and the tag pages. And optimized away the dbTagVNs() function while I was at it (dbVNGet() is powerful enough)
Diffstat (limited to 'lib/VNDB/Handler/Tags.pm')
-rw-r--r--lib/VNDB/Handler/Tags.pm92
1 files changed, 28 insertions, 64 deletions
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index 8461fb7c..5412be02 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -29,7 +29,7 @@ sub tagpage {
return 404 if !$t;
my $f = $self->formValidate(
- { name => 's', required => 0, default => 'score', enum => [ qw|score title rel pop| ] },
+ { name => 's', required => 0, default => 'tagscore', enum => [ qw|title rel pop tagscore rating| ] },
{ name => 'o', required => 0, default => 'd', enum => [ 'a','d' ] },
{ name => 'p', required => 0, default => 1, template => 'int' },
{ name => 'm', required => 0, default => -1, enum => [qw|0 1 2|] },
@@ -38,12 +38,20 @@ sub tagpage {
my $tagspoil = $self->reqCookie('tagspoil');
$f->{m} = $tagspoil =~ /^[0-2]$/ ? $tagspoil : 0 if $f->{m} == -1;
- my($list, $np) = $t->{meta} || $t->{state} != 2 ? ([],0) : $self->dbTagVNs(
- tag => $tag,
- order => {score=>'th.rating',title=>'vr.title',rel=>'v.c_released',pop=>'v.c_popularity'}->{$f->{s}}.($f->{o}eq'a'?' ASC':' DESC').($f->{s}eq'score'?', th.users DESC':''),
- page => $f->{p},
+ my $sortcol = {qw|
+ rel c_released
+ pop c_popularity
+ rating c_rating
+ title title
+ tagscore tagscore
+ |}->{$f->{s}};
+
+ my($list, $np) = $t->{meta} || $t->{state} != 2 ? ([],0) : $self->dbVNGet(
+ what => 'rating',
results => 50,
- maxspoil => $f->{m},
+ page => $f->{p},
+ order => $sortcol.($f->{o} eq 'a' ? ' ASC' : ' DESC'),
+ tags_include => [ $f->{m}, [$tag ]],
);
my $title = mt '_tagp_title', $t->{meta}?0:1, $t->{name};
@@ -111,7 +119,20 @@ sub tagpage {
end;
_childtags($self, $t) if @{$t->{childs}};
- _vnlist($self, $t, $f, $list, $np) if !$t->{meta} && $t->{state} == 2;
+
+ if(!$t->{meta} && $t->{state} == 2) {
+ div class => 'mainbox';
+ 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';
+ end;
+ p "\n\n".mt '_tagp_novn' if !@$list;
+ p "\n".mt '_tagp_cached';
+ end;
+ $self->htmlBrowseVN($list, $f, $np, "/g$t->{id}?m=$f->{m}", 1);
+ }
$self->htmlFooter;
}
@@ -163,63 +184,6 @@ sub _childtags {
end;
}
-sub _vnlist {
- my($self, $t, $f, $list, $np) = @_;
- div class => 'mainbox';
- 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';
- end;
- if(!@$list) {
- p "\n\n".mt '_tagp_novn';
- }
- p "\n".mt '_tagp_cached';
- end;
- return if !@$list;
- $self->htmlBrowse(
- class => 'tagvnlist',
- items => $list,
- options => $f,
- nextpage => $np,
- pageurl => "/g$t->{id}?m=$f->{m};o=$f->{o};s=$f->{s}",
- sorturl => "/g$t->{id}?m=$f->{m}",
- header => [
- [ mt('_tagp_vncol_score'), 'score' ],
- [ mt('_tagp_vncol_title'), 'title' ],
- [ '', 0 ],
- [ '', 0 ],
- [ mt('_tagp_vncol_rel'), 'rel' ],
- [ mt('_tagp_vncol_pop'), 'pop' ],
- ],
- row => sub {
- my($s, $n, $l) = @_;
- Tr $n % 2 ? (class => 'odd') : ();
- td class => 'tc1';
- tagscore $l->{rating};
- i sprintf '(%d)', $l->{users};
- end;
- td class => 'tc2';
- a href => '/v'.$l->{vid}, title => $l->{original}||$l->{title}, shorten $l->{title}, 100;
- end;
- td class => 'tc3';
- $_ ne 'oth' && cssicon $_, mt "_plat_$_"
- for (sort split /\//, $l->{c_platforms});
- end;
- td class => 'tc4';
- cssicon "lang $_", mt "_lang_$_"
- for (reverse sort split /\//, $l->{c_languages});
- end;
- td class => 'tc5';
- lit $self->{l10n}->datestr($l->{c_released});
- end;
- td class => 'tc6', sprintf '%.2f', ($l->{c_popularity}||0)*100;
- end;
- }
- );
-}
-
sub tagedit {
my($self, $tag, $act) = @_;