summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-09 13:08:08 +0100
committerYorhel <git@yorhel.nl>2008-12-09 13:08:08 +0100
commit66bc1533761ae28c0c8cbcea91b80c0319d86b39 (patch)
tree9b321ebbdc34c5b57501dfd0278b9b0fcadc8efd /lib
parent62ab2e931cf21236e83d4483d8cb4eb773f26a89 (diff)
Code cleanup: removed leading spaces and combined DB/{Votes,VNList,WishList}.pm into ULists.pm
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Discussions.pm4
-rw-r--r--lib/VNDB/DB/Misc.pm4
-rw-r--r--lib/VNDB/DB/Producers.pm2
-rw-r--r--lib/VNDB/DB/ULists.pm264
-rw-r--r--lib/VNDB/DB/Users.pm4
-rw-r--r--lib/VNDB/DB/VN.pm12
-rw-r--r--lib/VNDB/DB/VNList.pm126
-rw-r--r--lib/VNDB/DB/Votes.pm85
-rw-r--r--lib/VNDB/DB/WishList.pm76
-rw-r--r--lib/VNDB/Func.pm12
-rw-r--r--lib/VNDB/Handler/Discussions.pm4
-rw-r--r--lib/VNDB/Handler/Misc.pm10
-rw-r--r--lib/VNDB/Handler/Producers.pm2
-rw-r--r--lib/VNDB/Handler/Releases.pm2
-rw-r--r--lib/VNDB/Handler/Users.pm4
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm2
-rw-r--r--lib/VNDB/Handler/VNEdit.pm4
-rw-r--r--lib/VNDB/Handler/VNPage.pm6
-rw-r--r--lib/VNDB/Util/Auth.pm4
-rw-r--r--lib/VNDB/Util/CommonHTML.pm6
-rw-r--r--lib/VNDB/Util/FormHTML.pm2
21 files changed, 306 insertions, 329 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index a16bf3be..1e626c57 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -117,7 +117,7 @@ sub dbThreadEdit {
# %options->{ title hidden locked tags }
-sub dbThreadAdd {
+sub dbThreadAdd {
my($self, %o) = @_;
my $id = $self->dbRow(q|
@@ -175,7 +175,7 @@ sub dbPostGet {
# tid, num, %options->{ num msg hidden lastmod }
-sub dbPostEdit {
+sub dbPostEdit {
my($self, $tid, $num, %o) = @_;
my %set = (
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm
index 9ebac75f..828d5281 100644
--- a/lib/VNDB/DB/Misc.pm
+++ b/lib/VNDB/DB/Misc.pm
@@ -12,7 +12,7 @@ our @EXPORT = qw|
# Returns: hashref, key = section, value = number of (visible) entries
# Sections: vn, producers, releases, users, threads, posts
-sub dbStats {
+sub dbStats {
my $s = shift;
return { map {
$_->{section} eq 'threads_posts' ? 'posts' : $_->{section}, $_->{count}
@@ -144,7 +144,7 @@ sub dbRevisionGet {
# arguments: v/r/p, id, %options ->( hidden, locked )
sub dbItemMod {
my($self, $type, $id, %o) = @_;
- $self->dbExec('UPDATE !s !H WHERE id = ?',
+ $self->dbExec('UPDATE !s !H WHERE id = ?',
{qw|v vn r releases p producers|}->{$type},
{ map { ($_.' = ?', int $o{$_}) } keys %o }, $id
);
diff --git a/lib/VNDB/DB/Producers.pm b/lib/VNDB/DB/Producers.pm
index adfa8b1c..edee4a8a 100644
--- a/lib/VNDB/DB/Producers.pm
+++ b/lib/VNDB/DB/Producers.pm
@@ -74,7 +74,7 @@ sub dbProducerGet {
[ keys %r ]
)});
}
-
+
return wantarray ? ($r, $np) : $r;
}
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm
new file mode 100644
index 00000000..0f84acb3
--- /dev/null
+++ b/lib/VNDB/DB/ULists.pm
@@ -0,0 +1,264 @@
+
+package VNDB::DB::ULists;
+
+use strict;
+use warnings;
+use Exporter 'import';
+
+
+our @EXPORT = qw|
+ dbVNListGet dbVNListList dbVNListAdd dbVNListDel
+ dbVoteGet dbVoteStats dbVoteAdd dbVoteDel
+ dbWishListGet dbWishListAdd dbWishListDel
+|;
+
+
+# Simpler and more efficient version of dbVNListList below
+# %options->{ uid rid }
+sub dbVNListGet {
+ my($self, %o) = @_;
+
+ my %where = (
+ 'uid = ?' => $o{uid},
+ $o{rid} ? (
+ 'rid = ?' => $o{rid} ) : (),
+ );
+
+ return $self->dbAll(q|
+ SELECT uid, rid, rstat, vstat
+ FROM rlists
+ !W|,
+ \%where
+ );
+}
+
+
+# %options->{ uid order char voted page results }
+# NOTE: this function is mostly copied from 1.x, may need some rewriting...
+sub dbVNListList {
+ my($self, %o) = @_;
+
+ $o{results} ||= 50;
+ $o{page} ||= 1;
+ $o{order} ||= 'vr.title ASC';
+ $o{voted} ||= 0; # -1: only non-voted, 0: all, 1: only voted
+
+ # construct the global WHERE clause
+ my $where = $o{voted} != -1 ? 'vo.vote IS NOT NULL' : '';
+ $where .= ($where?' OR ':'').q|v.id IN(
+ SELECT irv.vid
+ FROM rlists irl
+ JOIN releases ir ON ir.id = irl.rid
+ JOIN releases_vn irv ON irv.rid = ir.latest
+ WHERE uid = ?
+ )| if $o{voted} != 1;
+ $where = '('.$where.') AND LOWER(SUBSTR(vr.title, 1, 1)) = \''.$o{char}.'\'' if $o{char};
+ $where = '('.$where.') AND (ASCII(vr.title) < 97 OR ASCII(vr.title) > 122) AND (ASCII(vr.title) < 65 OR ASCII(vr.title) > 90)' if defined $o{char} && !$o{char};
+ $where = '('.$where.') AND vo.vote IS NULL' if $o{voted} == -1;
+
+ # execute query
+ my($r, $np) = $self->dbPage(\%o, qq|
+ SELECT vr.vid, vr.title, vr.original, v.c_released, v.c_languages, v.c_platforms, COALESCE(vo.vote, 0) AS vote
+ FROM vn v
+ JOIN vn_rev vr ON vr.id = v.latest
+ !s JOIN votes vo ON vo.vid = v.id AND vo.uid = ?
+ WHERE $where
+ ORDER BY !s|,
+ $o{voted} == 1 ? '' : 'LEFT', $o{uid}, # JOIN if we only want votes, LEFT JOIN if we also want rlist items
+ $o{voted} != 1 ? $o{uid} : (), $o{order},
+ );
+
+ # fetch releases and link to VNs
+ if(@$r) {
+ my %vns = map {
+ $_->{rels}=[];
+ $_->{vid}, $_->{rels}
+ } @$r;
+
+ push @{$vns{$_->{vid}}}, $_ for (@{$self->dbAll(q|
+ SELECT rv.vid, rr.rid, rr.title, rr.original, rr.released, rr.type, rr.language, rr.minage, rl.rstat, rl.vstat
+ FROM rlists rl
+ JOIN releases r ON rl.rid = r.id
+ JOIN releases_rev rr ON rr.id = r.latest
+ JOIN releases_vn rv ON rv.rid = r.latest
+ WHERE rl.uid = ?
+ AND rv.vid IN(!l)
+ ORDER BY rr.released ASC|,
+ $o{uid}, [ keys %vns ]
+ )});
+ }
+
+ return wantarray ? ($r, $np) : $r;
+}
+
+
+# %options->{ uid rid rstat vstat }
+sub dbVNListAdd {
+ my($self, %o) = @_;
+
+ my %s = (
+ defined $o{rstat} ? ( 'rstat = ?', $o{rstat} ) : (),
+ defined $o{vstat} ? ( 'vstat = ?', $o{vstat} ) : (),
+ );
+ $o{rstat}||=0;
+ $o{vstat}||=0;
+
+ $self->dbExec(
+ 'UPDATE rlists !H WHERE uid = ? AND rid IN(!l)',
+ \%s, $o{uid}, ref($o{rid}) eq 'ARRAY' ? $o{rid} : [ $o{rid} ]
+ )
+ ||
+ $self->dbExec(
+ 'INSERT INTO rlists (uid, rid, rstat, vstat) VALUES(!l)',
+ [@o{qw| uid rid rstat vstat |}]
+ );
+}
+
+
+# Arguments: uid, rid
+sub dbVNListDel {
+ my($self, $uid, $rid) = @_;
+ $self->dbExec(
+ 'DELETE FROM rlists WHERE uid = ? AND rid IN(!l)',
+ $uid, ref($rid) eq 'ARRAY' ? $rid : [ $rid ]
+ );
+}
+
+
+# %options->{ uid vid hide order results page }
+sub dbVoteGet {
+ my($self, %o) = @_;
+ $o{order} ||= 'n.date DESC';
+ $o{results} ||= 50;
+ $o{page} ||= 1;
+
+ my %where = (
+ $o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (),
+ $o{vid} ? ( 'n.vid = ?' => $o{vid} ) : (),
+ $o{hide} ? ( 'u.show_list = FALSE' => 1 ) : (),
+ );
+
+ my($r, $np) = $self->dbPage(\%o, q|
+ SELECT n.vid, vr.title, vr.original, n.vote, n.date, n.uid, u.username
+ FROM votes n
+ JOIN vn v ON v.id = n.vid
+ JOIN vn_rev vr ON vr.id = v.latest
+ JOIN users u ON u.id = n.uid
+ !W
+ ORDER BY !s|,
+ \%where, $o{order}
+ );
+
+ return wantarray ? ($r, $np) : $r;
+}
+
+
+# Arguments: (uid|vid), id
+# Returns an arrayref with 10 elements containing the number of votes for index+1
+sub dbVoteStats {
+ my($self, $col, $id) = @_;
+ my $r = [ qw| 0 0 0 0 0 0 0 0 0 0 | ];
+ $r->[$_->{vote}-1] = $_->{votes} for (@{$self->dbAll(q|
+ SELECT vote, COUNT(vote) as votes
+ FROM votes
+ !W
+ GROUP BY vote|,
+ $col ? { '!s = ?' => [ $col, $id ] } : {},
+ )});
+ return $r;
+}
+
+
+# Adds a new vote or updates an existing one
+# Arguments: vid, uid, vote
+sub dbVoteAdd {
+ my($self, $vid, $uid, $vote) = @_;
+ $self->dbExec(q|
+ UPDATE votes
+ SET vote = ?
+ WHERE vid = ?
+ AND uid = ?|,
+ $vote, $vid, $uid
+ ) || $self->dbExec(q|
+ INSERT INTO votes
+ (vid, uid, vote, date)
+ VALUES (!l)|,
+ [ $vid, $uid, $vote, time ]
+ );
+}
+
+
+# Arguments: uid, vid
+sub dbVoteDel {
+ my($self, $uid, $vid) = @_;
+ $self->dbExec('DELETE FROM votes !W',
+ { 'vid = ?' => $vid, 'uid = ?' => $uid }
+ );
+}
+
+
+# %options->{ uid vid wstat what order page results }
+# what: vn
+sub dbWishListGet {
+ my($self, %o) = @_;
+
+ $o{order} ||= 'wl.wstat ASC';
+ $o{page} ||= 1;
+ $o{results} ||= 50;
+ $o{what} ||= '';
+
+ my %where = (
+ 'wl.uid = ?' => $o{uid},
+ $o{vid} ? ( 'wl.vid = ?' => $o{vid} ) : (),
+ defined $o{wstat} ? ( 'wl.wstat = ?' => $o{wstat} ) : (),
+ );
+
+ my $select = 'wl.vid, wl.wstat, wl.added';
+ my @join;
+ if($o{what} =~ /vn/) {
+ $select .= ', vr.title, vr.original';
+ push @join, 'JOIN vn v ON v.id = wl.vid',
+ 'JOIN vn_rev vr ON vr.id = v.latest';
+ }
+
+ my($r, $np) = $self->dbPage(\%o, q|
+ SELECT !s
+ FROM wlists wl
+ !s
+ !W
+ ORDER BY !s|,
+ $select, join(' ', @join), \%where, $o{order},
+ );
+
+ return wantarray ? ($r, $np) : $r;
+}
+
+
+# Updates or adds a whishlist item
+# Arguments: vid, uid, wstat
+sub dbWishListAdd {
+ my($self, $vid, $uid, $wstat) = @_;
+ $self->dbExec(
+ 'UPDATE wlists SET wstat = ? WHERE uid = ? AND vid IN(!l)',
+ $wstat, $uid, ref($vid) eq 'ARRAY' ? $vid : [ $vid ]
+ )
+ ||
+ $self->dbExec(
+ 'INSERT INTO wlists (uid, vid, wstat) VALUES(!l)',
+ [ $uid, $vid, $wstat ]
+ );
+}
+
+
+# Arguments: uid, vids
+sub dbWishListDel {
+ my($self, $uid, $vid) = @_;
+ $self->dbExec(
+ 'DELETE FROM wlists WHERE uid = ? AND vid IN(!l)',
+ $uid, ref($vid) eq 'ARRAY' ? $vid : [ $vid ]
+ );
+}
+
+
+1;
+
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index b17ad62f..c196e4f4 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -9,7 +9,7 @@ our @EXPORT = qw|dbUserGet dbUserEdit dbUserAdd dbUserDel|;
# %options->{ username passwd mail order uid results page }
-sub dbUserGet {
+sub dbUserGet {
my $s = shift;
my %o = (
order => 'username ASC',
@@ -48,7 +48,7 @@ sub dbUserGet {
# uid, %options->{ columns in users table }
-sub dbUserEdit {
+sub dbUserEdit {
my($s, $uid, %o) = @_;
my %h;
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index d70db9ee..f12bf513 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -28,7 +28,7 @@ sub dbVNGet {
defined $o{char} && !$o{char} ? (
'(ASCII(vr.title) < 97 OR ASCII(vr.title) > 122) AND (ASCII(vr.title) < 65 OR ASCII(vr.title) > 90)' => 1 ) : (),
$o{cati} && @{$o{cati}} ? ( q|
- v.id IN(SELECT iv.id
+ v.id IN(SELECT iv.id
FROM vn_categories ivc
JOIN vn iv ON iv.latest = ivc.vid
WHERE cat IN(!l)
@@ -37,8 +37,8 @@ sub dbVNGet {
$o{cate} && @{$o{cate}} ? ( q|
v.id NOT IN(SELECT iv.id
FROM vn_categories ivc
- JOIN vn iv ON iv.latest = ivc.vid
- WHERE cat IN(!l)
+ JOIN vn iv ON iv.latest = ivc.vid
+ WHERE cat IN(!l)
GROUP BY iv.id)| => [ $o{cate} ] ) : (),
$o{lang} && @{$o{lang}} ? (
'('.join(' OR ', map "v.c_languages ILIKE '%%$_%%'", @{$o{lang}}).')' => 1 ) : (),
@@ -78,11 +78,11 @@ sub dbVNGet {
$o{rev} ?
'JOIN vn v ON v.id = vr.vid' :
'JOIN vn v ON vr.id = v.latest',
- $o{rev} || $o{what} =~ /changes/ ?
+ $o{rev} || $o{what} =~ /changes/ ?
'JOIN changes c ON c.id = vr.id' : (),
$o{what} =~ /changes/ ?
'JOIN users u ON u.id = c.requester' : (),
- $o{what} =~ /relgraph/ ?
+ $o{what} =~ /relgraph/ ?
'JOIN relgraph rg ON rg.id = v.rgraph' : (),
);
@@ -261,7 +261,7 @@ sub dbScreenshotAdd {
# arrayref of screenshot IDs as argument
sub dbScreenshotGet {
return shift->dbAll(q|SELECT * FROM screenshots WHERE id IN(!l)|, shift);
-}
+}
1;
diff --git a/lib/VNDB/DB/VNList.pm b/lib/VNDB/DB/VNList.pm
deleted file mode 100644
index 9e430f43..00000000
--- a/lib/VNDB/DB/VNList.pm
+++ /dev/null
@@ -1,126 +0,0 @@
-
-package VNDB::DB::VNList;
-
-use strict;
-use warnings;
-use Exporter 'import';
-
-
-our @EXPORT = qw|dbVNListGet dbVNListList dbVNListAdd dbVNListDel|;
-
-
-# Simpler and more efficient version of dbVNListList below
-# %options->{ uid rid }
-sub dbVNListGet {
- my($self, %o) = @_;
-
- my %where = (
- 'uid = ?' => $o{uid},
- $o{rid} ? (
- 'rid = ?' => $o{rid} ) : (),
- );
-
- return $self->dbAll(q|
- SELECT uid, rid, rstat, vstat
- FROM rlists
- !W|,
- \%where
- );
-}
-
-
-# %options->{ uid order char voted page results }
-# NOTE: this function is mostly copied from 1.x, may need some rewriting...
-sub dbVNListList {
- my($self, %o) = @_;
-
- $o{results} ||= 50;
- $o{page} ||= 1;
- $o{order} ||= 'vr.title ASC';
- $o{voted} ||= 0; # -1: only non-voted, 0: all, 1: only voted
-
- # construct the global WHERE clause
- my $where = $o{voted} != -1 ? 'vo.vote IS NOT NULL' : '';
- $where .= ($where?' OR ':'').q|v.id IN(
- SELECT irv.vid
- FROM rlists irl
- JOIN releases ir ON ir.id = irl.rid
- JOIN releases_vn irv ON irv.rid = ir.latest
- WHERE uid = ?
- )| if $o{voted} != 1;
- $where = '('.$where.') AND LOWER(SUBSTR(vr.title, 1, 1)) = \''.$o{char}.'\'' if $o{char};
- $where = '('.$where.') AND (ASCII(vr.title) < 97 OR ASCII(vr.title) > 122) AND (ASCII(vr.title) < 65 OR ASCII(vr.title) > 90)' if defined $o{char} && !$o{char};
- $where = '('.$where.') AND vo.vote IS NULL' if $o{voted} == -1;
-
- # execute query
- my($r, $np) = $self->dbPage(\%o, qq|
- SELECT vr.vid, vr.title, vr.original, v.c_released, v.c_languages, v.c_platforms, COALESCE(vo.vote, 0) AS vote
- FROM vn v
- JOIN vn_rev vr ON vr.id = v.latest
- !s JOIN votes vo ON vo.vid = v.id AND vo.uid = ?
- WHERE $where
- ORDER BY !s|,
- $o{voted} == 1 ? '' : 'LEFT', $o{uid}, # JOIN if we only want votes, LEFT JOIN if we also want rlist items
- $o{voted} != 1 ? $o{uid} : (), $o{order},
- );
-
- # fetch releases and link to VNs
- if(@$r) {
- my %vns = map {
- $_->{rels}=[];
- $_->{vid}, $_->{rels}
- } @$r;
-
- push @{$vns{$_->{vid}}}, $_ for (@{$self->dbAll(q|
- SELECT rv.vid, rr.rid, rr.title, rr.original, rr.released, rr.type, rr.language, rr.minage, rl.rstat, rl.vstat
- FROM rlists rl
- JOIN releases r ON rl.rid = r.id
- JOIN releases_rev rr ON rr.id = r.latest
- JOIN releases_vn rv ON rv.rid = r.latest
- WHERE rl.uid = ?
- AND rv.vid IN(!l)
- ORDER BY rr.released ASC|,
- $o{uid}, [ keys %vns ]
- )});
- }
-
- return wantarray ? ($r, $np) : $r;
-}
-
-
-# %options->{ uid rid rstat vstat }
-sub dbVNListAdd {
- my($self, %o) = @_;
-
- my %s = (
- defined $o{rstat} ? ( 'rstat = ?', $o{rstat} ) : (),
- defined $o{vstat} ? ( 'vstat = ?', $o{vstat} ) : (),
- );
- $o{rstat}||=0;
- $o{vstat}||=0;
-
- $self->dbExec(
- 'UPDATE rlists !H WHERE uid = ? AND rid IN(!l)',
- \%s, $o{uid}, ref($o{rid}) eq 'ARRAY' ? $o{rid} : [ $o{rid} ]
- )
- ||
- $self->dbExec(
- 'INSERT INTO rlists (uid, rid, rstat, vstat) VALUES(!l)',
- [@o{qw| uid rid rstat vstat |}]
- );
-}
-
-
-# Arguments: uid, rid
-sub dbVNListDel {
- my($self, $uid, $rid) = @_;
- $self->dbExec(
- 'DELETE FROM rlists WHERE uid = ? AND rid IN(!l)',
- $uid, ref($rid) eq 'ARRAY' ? $rid : [ $rid ]
- );
-}
-
-
-
-1;
-
diff --git a/lib/VNDB/DB/Votes.pm b/lib/VNDB/DB/Votes.pm
deleted file mode 100644
index 42779885..00000000
--- a/lib/VNDB/DB/Votes.pm
+++ /dev/null
@@ -1,85 +0,0 @@
-
-package VNDB::DB::Votes;
-
-use strict;
-use warnings;
-use Exporter 'import';
-
-
-our @EXPORT = qw|dbVoteGet dbVoteStats dbVoteAdd dbVoteDel|;
-
-
-# %options->{ uid vid hide order results page }
-sub dbVoteGet {
- my($self, %o) = @_;
- $o{order} ||= 'n.date DESC';
- $o{results} ||= 50;
- $o{page} ||= 1;
-
- my %where = (
- $o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (),
- $o{vid} ? ( 'n.vid = ?' => $o{vid} ) : (),
- $o{hide} ? ( 'u.show_list = FALSE' => 1 ) : (),
- );
-
- my($r, $np) = $self->dbPage(\%o, q|
- SELECT n.vid, vr.title, vr.original, n.vote, n.date, n.uid, u.username
- FROM votes n
- JOIN vn v ON v.id = n.vid
- JOIN vn_rev vr ON vr.id = v.latest
- JOIN users u ON u.id = n.uid
- !W
- ORDER BY !s|,
- \%where, $o{order}
- );
-
- return wantarray ? ($r, $np) : $r;
-}
-
-
-# Arguments: (uid|vid), id
-# Returns an arrayref with 10 elements containing the number of votes for index+1
-sub dbVoteStats {
- my($self, $col, $id) = @_;
- my $r = [ qw| 0 0 0 0 0 0 0 0 0 0 | ];
- $r->[$_->{vote}-1] = $_->{votes} for (@{$self->dbAll(q|
- SELECT vote, COUNT(vote) as votes
- FROM votes
- !W
- GROUP BY vote|,
- $col ? { '!s = ?' => [ $col, $id ] } : {},
- )});
- return $r;
-}
-
-
-# Adds a new vote or updates an existing one
-# Arguments: vid, uid, vote
-sub dbVoteAdd {
- my($self, $vid, $uid, $vote) = @_;
- $self->dbExec(q|
- UPDATE votes
- SET vote = ?
- WHERE vid = ?
- AND uid = ?|,
- $vote, $vid, $uid
- ) || $self->dbExec(q|
- INSERT INTO votes
- (vid, uid, vote, date)
- VALUES (!l)|,
- [ $vid, $uid, $vote, time ]
- );
-}
-
-
-# Arguments: uid, vid
-sub dbVoteDel {
- my($self, $uid, $vid) = @_;
- $self->dbExec('DELETE FROM votes !W',
- { 'vid = ?' => $vid, 'uid = ?' => $uid }
- );
-}
-
-
-1;
-
diff --git a/lib/VNDB/DB/WishList.pm b/lib/VNDB/DB/WishList.pm
deleted file mode 100644
index a75ce41f..00000000
--- a/lib/VNDB/DB/WishList.pm
+++ /dev/null
@@ -1,76 +0,0 @@
-
-package VNDB::DB::WishList;
-
-use strict;
-use warnings;
-use Exporter 'import';
-
-
-our @EXPORT = qw|dbWishListGet dbWishListAdd dbWishListDel|;
-
-
-# %options->{ uid vid wstat what order page results }
-# what: vn
-sub dbWishListGet {
- my($self, %o) = @_;
-
- $o{order} ||= 'wl.wstat ASC';
- $o{page} ||= 1;
- $o{results} ||= 50;
- $o{what} ||= '';
-
- my %where = (
- 'wl.uid = ?' => $o{uid},
- $o{vid} ? ( 'wl.vid = ?' => $o{vid} ) : (),
- defined $o{wstat} ? ( 'wl.wstat = ?' => $o{wstat} ) : (),
- );
-
- my $select = 'wl.vid, wl.wstat, wl.added';
- my @join;
- if($o{what} =~ /vn/) {
- $select .= ', vr.title, vr.original';
- push @join, 'JOIN vn v ON v.id = wl.vid',
- 'JOIN vn_rev vr ON vr.id = v.latest';
- }
-
- my($r, $np) = $self->dbPage(\%o, q|
- SELECT !s
- FROM wlists wl
- !s
- !W
- ORDER BY !s|,
- $select, join(' ', @join), \%where, $o{order},
- );
-
- return wantarray ? ($r, $np) : $r;
-}
-
-
-# Updates or adds a whishlist item
-# Arguments: vid, uid, wstat
-sub dbWishListAdd {
- my($self, $vid, $uid, $wstat) = @_;
- $self->dbExec(
- 'UPDATE wlists SET wstat = ? WHERE uid = ? AND vid IN(!l)',
- $wstat, $uid, ref($vid) eq 'ARRAY' ? $vid : [ $vid ]
- )
- ||
- $self->dbExec(
- 'INSERT INTO wlists (uid, vid, wstat) VALUES(!l)',
- [ $uid, $vid, $wstat ]
- );
-}
-
-
-# Arguments: uid, vids
-sub dbWishListDel {
- my($self, $uid, $vid) = @_;
- $self->dbExec(
- 'DELETE FROM wlists WHERE uid = ? AND vid IN(!l)',
- $uid, ref($vid) eq 'ARRAY' ? $vid : [ $vid ]
- );
-}
-
-
-1;
-
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 8971c6a8..bf0a871f 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -31,7 +31,7 @@ sub date {
# m = 99 -> month+day unkown
# d = 99 -> day unknown
# return value: (unknown|TBA|yyyy|yyyy-mm|yyyy-mm-dd)
-# if date > now: <b class="future">str</b>
+# if date > now: <b class="future">str</b>
sub datestr {
my $date = sprintf '%08d', shift||0;
my $future = $date > strftime '%Y%m%d', gmtime;
@@ -72,7 +72,7 @@ sub userstr {
# [spoiler] .. [/spoiler]
# v+, v+.+
# http://../
-sub bb2html {
+sub bb2html {
my $raw = shift;
my $maxlength = shift;
$raw =~ s/\r//g;
@@ -127,15 +127,15 @@ sub bb2html {
} elsif($_ eq '[/raw]') {
pop @open if $open[$#open] eq 'raw';
next;
- }
-
+ }
+
# normal text processing
$length += length $_;
last if $maxlength && $length > $maxlength;
$result .= $e->($_);
}
- $result .= '</a>'
+ $result .= '</a>'
while((local $_ = pop @open) ne 'first');
$result .= '...' if $maxlength && $length > $maxlength;
@@ -146,7 +146,7 @@ sub bb2html {
# GTIN code as argument,
# Returns 'JAN', 'EAN', 'UPC' or undef,
# Also 'normalizes' the first argument in place
-sub gtintype {
+sub gtintype {
$_[0] =~ s/[^\d]+//g;
$_[0] =~ s/^0+//;
my $c = shift;
diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm
index c7dd17d6..5c7ef238 100644
--- a/lib/VNDB/Handler/Discussions.pm
+++ b/lib/VNDB/Handler/Discussions.pm
@@ -101,7 +101,7 @@ sub thread {
br;
input type => 'submit', value => 'Reply', class => 'submit';
end;
- end;
+ end;
end;
} elsif(!$self->authCan('board')) {
div class => 'mainbox';
@@ -302,7 +302,7 @@ sub tagbrowse {
p class => 'center';
if(!@$list) {
b 'No related threads found';
- br; br;
+ br; br;
a href => "/t/$type$iid/new", 'Why not create one yourself?';
} else {
a href => '/t/'.($iid ? $type.$iid : 'db').'/new', 'Start a new thread';
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 85aacdf2..60af53e7 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -14,7 +14,7 @@ YAWF::register(
qr{d([1-9]\d*)}, \&docpage,
qr{nospam}, \&nospam,
qr{([vrp])([1-9]\d*)/(lock|hide)}, \&itemmod,
-
+
# redirects for old URLs
qr{(.*[^/]+)/+}, sub { $_[0]->resRedirect("/$_[1]", 'perm') },
qr{p}, sub { $_[0]->resRedirect('/p/all', 'perm') },
@@ -139,11 +139,11 @@ sub history {
my $revurl = "/$tc$i->{iid}.$i->{rev}";
Tr $n % 2 ? ( class => 'odd' ) : ();
- td class => 'tc1_1';
- a href => $revurl, "$tc$i->{iid}";
+ td class => 'tc1_1';
+ a href => $revurl, "$tc$i->{iid}";
end;
- td class => 'tc1_2';
- a href => $revurl, ".$i->{rev}";
+ td class => 'tc1_2';
+ a href => $revurl, ".$i->{rev}";
end;
td date $i->{added};
td;
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 8c6775d5..c857aa74 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -178,7 +178,7 @@ sub list {
}
end;
end;
-
+
my $pageurl = "/p/$char" . ($f->{q} ? "?q=$f->{q}" : '');
$self->htmlBrowseNavigate($pageurl, $f->{p}, $np, 't');
div class => 'mainbox producerbrowse';
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 2338f5aa..14749169 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -313,7 +313,7 @@ sub _form {
[ input => short => 'title', name => 'Title (romaji)', width => 300 ],
[ input => short => 'original', name => 'Original title', width => 300 ],
[ static => content => 'The original title of this release, leave blank if it already is in the Latin alphabet.' ],
- [ select => short => 'language', name => 'Language',
+ [ select => short => 'language', name => 'Language',
options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
[ input => short => 'gtin', name => 'JAN/UPC/EAN' ],
[ input => short => 'website', name => 'Official website' ],
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index ac0e7397..b2ecc841 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -73,7 +73,7 @@ sub newpass {
my $self = shift;
return $self->resRedirect('/') if $self->authInfo->{id};
-
+
my($frm, $u);
if($self->reqMethod eq 'POST') {
$frm = $self->formValidate(
@@ -86,7 +86,7 @@ sub newpass {
if(!$frm->{_err}) {
my @chars = ( 'A'..'Z', 'a'..'z', 0..9 );
my $pass = join '', map $chars[int rand $#chars+1], 0..8;
- $self->dbUserEdit($u->{id}, passwd => md5_hex($pass));
+ $self->dbUserEdit($u->{id}, passwd => md5_hex($pass));
$self->mail(
sprintf(join('', <DATA>), $u->{username}, $pass),
To => $u->{mail},
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index f65132d2..c0c3754e 100644
--- a/lib/VNDB/Handler/VNBrowse.pm
+++ b/lib/VNDB/Handler/VNBrowse.pm
@@ -35,7 +35,7 @@ sub list {
# VNDBID
return $self->resRedirect('/'.$1.$2.(!$3 ? '' : $1 eq 'd' ? '#'.$3 : '.'.$3), 'temp')
if $q =~ /^([vrptud])([0-9]+)(?:\.([0-9]+))?$/;
-
+
if(!($q =~ s/^title://)) {
# categories
my %catl = map {
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index cada9875..14859e3a 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -132,7 +132,7 @@ sub _uploadimage {
if($frm->{_err}) {
unlink $tmp;
return undef;
- }
+ }
# store the file and let multi handle it
my $imgid = $self->dbVNImageId;
@@ -171,7 +171,7 @@ sub _form {
[ input => short => 'l_encubed', pre => 'http://novelnews.net/tag/', post => '/' ],
[ input => short => 'l_renai', pre => 'http://renai.us/game/', post => '.shtml' ],
[ input => short => 'l_vnn', pre => 'http://visual-novels.net/vn/index.php?option=com_content&amp;task=view&amp;id=', width => 40 ],
-
+
[ input => short => 'anime', name => 'Anime' ],
[ static => content => q|
Whitespace seperated list of <a href="http://anidb.net/">AniDB</a> anime IDs.
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index aa7e072b..bc56dd8c 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -57,7 +57,7 @@ sub page {
div class => 'vndetails';
- # image
+ # image
div class => 'vnimg';
if(!$v->{image}) {
p 'No image uploaded yet';
@@ -222,7 +222,7 @@ sub _revision {
sub _producers {
my($self, $i, $r) = @_;
return if !grep @{$_->{producers}}, @$r;
-
+
my @lang;
for my $l (@$r) {
push @lang, $l->{language} if !grep $l->{language} eq $_, @lang;
@@ -291,7 +291,7 @@ sub _relations {
push @{$rel{$_->{relation}}}, $_
for (sort { $a->{title} cmp $b->{title} } @{$v->{relations}});
-
+
Tr ++$$i % 2 ? (class => 'odd') : ();
td 'Relations';
td class => 'relations';
diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm
index 0614945a..b520eeba 100644
--- a/lib/VNDB/Util/Auth.pm
+++ b/lib/VNDB/Util/Auth.pm
@@ -15,7 +15,7 @@ use Crypt::Lite;
our @EXPORT = qw| authInit authLogin authLogout authInfo authCan |;
-
+
# initializes authentication information and checks the vndb_auth cookie
sub authInit {
my $self = shift;
@@ -30,7 +30,7 @@ sub authInit {
_authCheck($self, $user, $pass);
}
-
+
# login, arguments: user, password, url-to-redirect-to-on-success
# returns 1 on success (redirected), 0 otherwise (no reply sent)
sub authLogin {
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 77897a78..5cf3d729 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -31,7 +31,7 @@ sub htmlMainTabs {
a href => "/t/$id", "discussions ($cnt)";
end;
}
-
+
if($type eq 'u' && $obj->{show_list}) {
li $sel eq 'wish' ? (class => 'tabselected') : ();
a href => "/$id/wish", 'wishlist';
@@ -306,7 +306,7 @@ sub revdiff {
my @ser1 = map encode_utf8($_), $o{split} ? $o{split}->($ser1) : map xml_escape($_), split //, $ser1;
my @ser2 = map encode_utf8($_), $o{split} ? $o{split}->($ser2) : map xml_escape($_), split //, $ser2;
return if $o{split} && $#ser1 == $#ser2 && !grep $ser1[$_] ne $ser2[$_], 0..$#ser1;
-
+
$ser1 = $ser2 = '';
my @d = compact_diff(\@ser1, \@ser2);
for my $i (0..($#d-2)/2) {
@@ -372,7 +372,7 @@ sub htmlItemMessage {
my($self, $type, $obj) = @_;
if($obj->{locked}) {
- p class => 'locked', 'Locked for editing'
+ p class => 'locked', 'Locked for editing'
} elsif(!$self->authInfo->{id}) {
p class => 'locked';
lit 'You need to be <a href="/u/login">logged in</a> to edit this page</a>';
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 4431fcb6..b6b7f57b 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -249,7 +249,7 @@ sub htmlForm {
}
input type => 'submit', value => 'Submit', class => 'submit';
end;
- end;
+ end;
end;
}