diff options
author | Arne Georg Gleditsch <argggh@taniquetil.(none)> | 2009-08-11 22:25:27 +0200 |
---|---|---|
committer | Arne Georg Gleditsch <argggh@taniquetil.(none)> | 2009-08-11 22:25:27 +0200 |
commit | 8c0cc60f48005db0a2f5496d265deb85dd918fae (patch) | |
tree | 2c23cd7fd7f0e2b525f258a9e18dee2c0b47ac7b /lib/LXRng/Index/DBI.pm | |
parent | 18c9a9da17ebea409c56ef9118a0adcc536f05c4 (diff) |
Honour body_charset when displaying files.
Diffstat (limited to 'lib/LXRng/Index/DBI.pm')
-rw-r--r-- | lib/LXRng/Index/DBI.pm | 21 |
1 files changed, 21 insertions, 0 deletions
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) = @_; |