From c8563070feee1d24bcdab637f37048b68e8b0b4d Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 25 Jul 2009 15:58:07 +0200 Subject: [PATCH] Added page to list def channels and alliance for planets --- lib/NDWeb/Controller/Intel.pm | 22 ++++++++++++++++++++++ root/lib/site/leftbar.tt2 | 1 + root/src/intel/channels.tt2 | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 root/src/intel/channels.tt2 diff --git a/lib/NDWeb/Controller/Intel.pm b/lib/NDWeb/Controller/Intel.pm index 535ca28..bbdf0f7 100644 --- a/lib/NDWeb/Controller/Intel.pm +++ b/lib/NDWeb/Controller/Intel.pm @@ -2,6 +2,7 @@ package NDWeb::Controller::Intel; use strict; use warnings; +use feature ':5.10'; use parent 'Catalyst::Controller'; use NDWeb::Include; @@ -97,6 +98,27 @@ sub planet : Local { } +sub channels : Local { + my ( $self, $c, $order ) = @_; + my $dbh = $c->model; + + if ($order ~~ /(alliance|channel)/){ + $order = "lower($1) ASC"; + }elsif ($order ~~ /(coords)/){ + $order = "x,y,z"; + }else{ + $order = 'lower(channel)'; + } + + my $query = $dbh->prepare(q{ +SELECT id,coords(x,y,z),nick,channel,alliance FROM current_planet_stats +WHERE channel <> '' and channel IS NOT NULL +ORDER BY } . $order + ); + $query->execute; + $c->stash(planets => $query->fetchall_arrayref({}) ); +} + sub postplanetcomment : Local { my ($self, $c, $p) = @_; diff --git a/root/lib/site/leftbar.tt2 b/root/lib/site/leftbar.tt2 index 7fdbbd4..6a27119 100644 --- a/root/lib/site/leftbar.tt2 +++ b/root/lib/site/leftbar.tt2 @@ -116,6 +116,7 @@

Intel menu