From 8c0cc60f48005db0a2f5496d265deb85dd918fae Mon Sep 17 00:00:00 2001 From: Arne Georg Gleditsch Date: Tue, 11 Aug 2009 22:25:27 +0200 Subject: Honour body_charset when displaying files. --- lib/LXRng/Index/DBI.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/LXRng/Index/DBI.pm') diff --git a/lib/LXRng/Index/DBI.pm b/lib/LXRng/Index/DBI.pm index 55e215d..8fcb391 100644 --- a/lib/LXRng/Index/DBI.pm +++ b/lib/LXRng/Index/DBI.pm @@ -535,6 +535,27 @@ sub set_rfile_charset { return $sth->execute($charset, $rfile_id); } +sub get_file_charset { + my ($self, $tree, $path, $rel) = @_; + + my $dbh = $self->dbh; + my $pre = $self->prefix; + my $rel_id = $self->release_id($tree, $rel); + return undef unless $rel_id; + my $rfile_id = $self->_get_rfile_by_release($rel_id, $path); + return undef unless $rfile_id; + + my $sth = $$self{'sth'}{'get_file_charset'} ||= + $dbh->prepare(qq{select c.name + from ${pre}revisions r, ${pre}charsets c + where r.id = ? and r.body_charset = c.id}); + my $charset; + if ($sth->execute($rfile_id) > 0) { + ($charset) = $sth->fetchrow_array(); + } + $sth->finish(); + return $charset; +} sub get_rfile_timestamp { my ($self, $rfile_id) = @_; -- cgit v1.2.3