]> ruin.nu Git - ndwebbie.git/blob - lib/NDWeb/Controller/TextExport.pm
Change database structure for planets and alliances + PG 8.4 changes
[ndwebbie.git] / lib / NDWeb / Controller / TextExport.pm
1 package NDWeb::Controller::TextExport;
2
3 use strict;
4 use warnings;
5 use parent 'Catalyst::Controller';
6
7 =head1 NAME
8
9 NDWeb::Controller::TextExport - Catalyst Controller
10
11 =head1 DESCRIPTION
12
13 Catalyst Controller.
14
15 =head1 METHODS
16
17 =cut
18
19
20 =head2 index
21
22 =cut
23
24 sub auto : Private {
25         my ( $self, $c ) = @_;
26         $c->stash(template => 'textexport/index.tt2');
27 }
28
29 sub alliance : Local {
30         my ( $self, $c, $ally ) = @_;
31         my $dbh = $c->model;
32
33         my $query = $dbh->prepare(q{SELECT coords(x,y,z), size, score, value,race, COALESCE(nick,'') AS nick
34                 FROM current_planet_stats
35                 WHERE aid = $1
36                 ORDER BY x,y,z});
37         $query->execute($ally);
38
39         $c->stash(titles => $query->{NAME});
40         $c->stash(values => $query->fetchall_arrayref);
41 }
42
43 sub end : ActionClass('RenderView') {
44         my ( $self, $c ) = @_;
45         $c->res->content_type('text/plain') if $c->stash->{template} =~ m{^textexport/};
46 }
47
48 =head1 AUTHOR
49
50 Michael Andreen (harv@ruin.nu)
51
52 =head1 LICENSE
53
54 GPL 2.0, or later.
55
56 =cut
57
58 1;