summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-04-03 18:12:24 +0200
committerYorhel <git@yorhel.nl>2011-04-03 18:12:24 +0200
commit0009e62b8b0b3066f10c4269718c9ccc9b312a63 (patch)
tree8dda1e0ea577da858841a7e28554f1502b715755 /lib/VNDB
parented7cad3d6e6c9ac879eb6392bfd4e9368537ab39 (diff)
Order the traits groups on /i by their 'order' column
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/DB/Tags.pm8
-rw-r--r--lib/VNDB/Func.pm4
-rw-r--r--lib/VNDB/Handler/Traits.pm2
3 files changed, 8 insertions, 6 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm
index eee73f10..37411a62 100644
--- a/lib/VNDB/DB/Tags.pm
+++ b/lib/VNDB/DB/Tags.pm
@@ -93,19 +93,21 @@ sub dbTagGet {
sub dbTTTree {
my($self, $type, $id, $lvl, $back) = @_;
$lvl ||= 15;
+ my $xtra = $type eq 'trait' ? ', "order"' : '';
+ my $xtra2 = $type eq 'trait' ? ', t."order"' : '';
my $r = $self->dbAll(qq|
WITH RECURSIVE thetree(lvl, id, parent, name, c_items) AS (
- SELECT ?::integer, id, 0, name, c_items
+ SELECT ?::integer, id, 0, name, c_items$xtra
FROM ${type}s
!W
UNION ALL
- SELECT tt.lvl-1, t.id, tt.id, t.name, t.c_items
+ SELECT tt.lvl-1, t.id, tt.id, t.name, t.c_items$xtra2
FROM thetree tt
JOIN ${type}s_parents tp ON !s
JOIN ${type}s t ON !s
WHERE tt.lvl > 0
AND t.state = 2
- ) SELECT DISTINCT id, parent, name, c_items FROM thetree ORDER BY name|, $lvl,
+ ) SELECT DISTINCT id, parent, name, c_items$xtra FROM thetree ORDER BY name|, $lvl,
$id ? {'id = ?' => $id} : {"NOT EXISTS(SELECT 1 FROM ${type}s_parents WHERE $type = id)" => 1, 'state = 2' => 1},
!$back ? ('tp.parent = tt.id', "t.id = tp.$type") : ("tp.$type = tt.id", 't.id = tp.parent')
);
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 64b56625..67cd3f7e 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -139,12 +139,12 @@ sub _parenttags {
# a child tags/traits box
sub childtags {
- my($self, $title, $type, $t) = @_;
+ my($self, $title, $type, $t, $order) = @_;
div class => 'mainbox';
h1 $title;
ul class => 'tagtree';
- for my $p (sort { @{$b->{'sub'}} <=> @{$a->{'sub'}} } @{$t->{childs}}) {
+ for my $p (sort { !$order ? @{$b->{'sub'}} <=> @{$a->{'sub'}} : $a->{$order} <=> $b->{$order} } @{$t->{childs}}) {
li;
a href => "/$type$p->{id}", $p->{name};
b class => 'grayedout', " ($p->{c_items})" if $p->{c_items};
diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm
index 887890b6..3e08f6bf 100644
--- a/lib/VNDB/Handler/Traits.pm
+++ b/lib/VNDB/Handler/Traits.pm
@@ -337,7 +337,7 @@ sub traitindex {
end;
my $t = $self->dbTTTree(trait => 0, 2);
- childtags($self, mt('_traiti_tree'), 'i', {childs => $t});
+ childtags($self, mt('_traiti_tree'), 'i', {childs => $t}, 'order');
table class => 'mainbox threelayout';
Tr;