diff options
author | Yorhel <git@yorhel.nl> | 2008-11-15 16:15:36 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-11-15 16:15:36 +0100 |
commit | 7f0a96b564544a3393f62c74599d1fdf95d7146c (patch) | |
tree | 06f1d18858fce113ce08b60fd60458b121a38f18 /lib/VNDB/DB/Discussions.pm | |
parent | 22e68d50dd7ce1187a2e31eb8c45f5e1ec53bf11 (diff) |
Added tag listing to thread pages
Not sure about the style, but at least it works.
Thread page is now pretty much finished as well, yay!
Diffstat (limited to 'lib/VNDB/DB/Discussions.pm')
-rw-r--r-- | lib/VNDB/DB/Discussions.pm | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm index 15fba617..6bea4750 100644 --- a/lib/VNDB/DB/Discussions.pm +++ b/lib/VNDB/DB/Discussions.pm @@ -9,7 +9,7 @@ our @EXPORT = qw|dbThreadGet dbPostGet|; # Options: id, results, page, what -# what: Nothing, yet +# What: tags, tagtitles sub dbThreadGet { my($self, %o) = @_; $o{results} ||= 50; @@ -27,15 +27,45 @@ sub dbThreadGet { \%where ); + if($o{what} =~ /(tags|tagtitles)/ && $#$r >= 0) { + my %r = map { + $r->[$_]{tags} = []; + ($r->[$_]{id}, $_) + } 0..$#$r; + + if($o{what} =~ /tags/) { + ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, [ $_->{type}, $_->{iid} ]) for (@{$self->dbAll(q| + SELECT tid, type, iid + FROM threads_tags + WHERE tid IN(!l)|, + [ keys %r ] + )}); + } + if($o{what} =~ /tagtitles/) { + ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, $_) for (@{$self->dbAll(q| + SELECT tt.tid, tt.type, tt.iid, COALESCE(u.username, vr.title, pr.name) AS title, COALESCE(u.username, vr.original, pr.original) AS original + FROM threads_tags tt + LEFT JOIN vn v ON tt.type = 'v' AND v.id = tt.iid + LEFT JOIN vn_rev vr ON vr.id = v.latest + LEFT JOIN producers p ON tt.type = 'p' AND p.id = tt.iid + LEFT JOIN producers_rev pr ON pr.id = p.latest + LEFT JOIN users u ON tt.type = 'u' AND u.id = tt.iid + WHERE tt.tid IN(!l)|, + [ keys %r ] + )}); + } + } + return wantarray ? ($r, $np) : $r; } -# Options: tid, num, page, results +# Options: tid, num, what, page, results sub dbPostGet { my($self, %o) = @_; $o{results} ||= 50; $o{page} ||= 1; + $o{what} ||= ''; my %where = ( 'tp.tid = ?' => $o{tid}, |