summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2016-01-17 13:09:07 +0100
committerYorhel <git@yorhel.nl>2016-01-17 13:09:07 +0100
commit110db705ecdfb5c89500ff8f24652bcd1e25fc45 (patch)
tree025bda64df44f2f281148d019d43f1f747050753 /lib/VNDB/Handler
parent38a4c36b21b1979a64cb915a80167fb7f8cadb9e (diff)
Use Tie::IxHash for some global.pl lists
This removes the reliance on sort() to provide meaningful ordering (the keys aren't always good for ordering) and removes the 'order' hack used for (vn|prod)_relations.
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/Producers.pm17
-rw-r--r--lib/VNDB/Handler/Releases.pm2
-rw-r--r--lib/VNDB/Handler/Staff.pm2
-rw-r--r--lib/VNDB/Handler/Tags.pm4
-rw-r--r--lib/VNDB/Handler/Users.pm2
-rw-r--r--lib/VNDB/Handler/VNEdit.pm6
-rw-r--r--lib/VNDB/Handler/VNPage.pm6
7 files changed, 20 insertions, 19 deletions
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 29c68d2d..13dd40b0 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -68,7 +68,7 @@ sub page {
[ desc => diff => qr/[ ,\n\.]/ ],
[ relations => join => '<br />', split => sub {
my @r = map sprintf('%s: <a href="/p%d" title="%s">%s</a>',
- $self->{prod_relations}{$_->{relation}}[2], $_->{id}, xml_escape($_->{original}||$_->{name}), xml_escape shorten $_->{name}, 40
+ $self->{prod_relations}{$_->{relation}}[1], $_->{id}, xml_escape($_->{original}||$_->{name}), xml_escape shorten $_->{name}, 40
), sort { $a->{id} <=> $b->{id} } @{$_[0]};
return @r ? @r : (mt '_revision_empty');
}],
@@ -100,8 +100,9 @@ sub page {
for (sort { $a->{name} cmp $b->{name} } @{$p->{relations}});
p class => 'center';
br;
- for my $r (sort { $self->{prod_relations}{$a}[0] <=> $self->{prod_relations}{$b}[0] } keys %rel) {
- txt $self->{prod_relations}{$r}[2].': ';
+ for my $r (keys %{$self->{prod_relations}}) {
+ next if !$rel{$r};
+ txt $self->{prod_relations}{$r}[1].': ';
for (@{$rel{$r}}) {
a href => "/p$_->{id}", title => $_->{original}||$_->{name}, shorten $_->{name}, 40;
txt ', ' if $_ ne $rel{$r}[$#{$rel{$r}}];
@@ -268,14 +269,14 @@ sub edit {
$self->htmlForm({ frm => $frm, action => $pid ? "/p$pid/edit" : '/p/new', editsum => 1 },
'pedit_geninfo' => [ mt('_pedit_form_generalinfo'),
[ select => name => mt('_pedit_form_type'), short => 'type',
- options => [ map [ $_, $self->{producer_types}{$_} ], sort keys %{$self->{producer_types}} ] ],
+ options => [ map [ $_, $self->{producer_types}{$_} ], keys %{$self->{producer_types}} ] ],
[ input => name => mt('_pedit_form_name'), short => 'name' ],
[ input => name => mt('_pedit_form_original'), short => 'original' ],
[ static => content => mt('_pedit_form_original_note') ],
[ input => name => mt('_pedit_form_alias'), short => 'alias', width => 400 ],
[ static => content => mt('_pedit_form_alias_note') ],
[ select => name => mt('_pedit_form_lang'), short => 'lang',
- options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($self->{languages}{$_})" ], keys %{$self->{languages}} ] ],
[ input => name => mt('_pedit_form_website'), short => 'website' ],
[ input => name => mt('_pedit_form_wikipedia'), short => 'l_wp', pre => 'http://en.wikipedia.org/wiki/' ],
[ text => name => mt('_pedit_form_desc').'<br /><b class="standout">'.mt('_inenglish').'</b>', short => 'desc', rows => 6 ],
@@ -297,8 +298,8 @@ sub edit {
end;
td class => 'tc_rel';
Select;
- option value => $_, $self->{prod_relations}{$_}[2]
- for (sort { $self->{prod_relations}{$a}[0] <=> $self->{prod_relations}{$b}[0] } keys %{$self->{prod_relations}});
+ option value => $_, $self->{prod_relations}{$_}[1]
+ for (keys %{$self->{prod_relations}});
end;
end;
td class => 'tc_add';
@@ -320,7 +321,7 @@ sub _updreverse {
if(exists $$old{$_} and !exists $$new{$_}) {
$upd{$_} = undef;
} elsif((!exists $$old{$_} and exists $$new{$_}) || ($$old{$_} ne $$new{$_})) {
- $upd{$_} = $self->{prod_relations}{$$new{$_}}[1];
+ $upd{$_} = $self->{prod_relations}{$$new{$_}}[0];
}
}
return if !keys %upd;
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index ef639ca1..fd05c069 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -388,7 +388,7 @@ sub _form {
[ input => short => 'original', name => mt('_redit_form_original'), width => 450 ],
[ static => content => mt '_redit_form_original_note' ],
[ select => short => 'languages', name => mt('_redit_form_languages'), multi => 1,
- options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($self->{languages}{$_})" ], keys %{$self->{languages}} ] ],
[ input => short => 'gtin', name => mt('_redit_form_gtin') ],
[ input => short => 'catalog', name => mt('_redit_form_catalog') ],
[ input => short => 'website', name => mt('_redit_form_website') ],
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 5eab1192..178d80cb 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -277,7 +277,7 @@ sub edit {
[ select => name => mt('_staffe_form_gender'),short => 'gender', options => [
map [ $_, mt("_gender_$_") ], qw(unknown m f) ] ],
[ select => name => mt('_staffe_form_lang'), short => 'lang',
- options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($self->{languages}{$_})" ], keys %{$self->{languages}} ] ],
[ input => name => mt('_staffe_form_site'), short => 'l_site' ],
[ input => name => mt('_staffe_form_wikipedia'), short => 'l_wp', pre => 'http://en.wikipedia.org/wiki/' ],
[ input => name => mt('_staffe_form_twitter'), short => 'l_twitter' ],
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index 62a72555..3e6a37d1 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -235,7 +235,7 @@ sub tagedit {
[ static => content => mt '_tagedit_frm_meta_warn' ] : (),
) : (),
[ select => short => 'cat', name => mt('_tagedit_frm_cat'), options => [
- map [$_, $self->{tag_categories}{$_}], sort keys %{$self->{tag_categories}} ] ],
+ map [$_, $self->{tag_categories}{$_}], keys %{$self->{tag_categories}} ] ],
$self->authCan('tagmod') && $tag ? (
[ checkbox => short => 'catrec', name => mt '_tagedit_frm_catrec' ],
[ static => content => mt '_tagedit_frm_catrec_warn' ],
@@ -582,7 +582,7 @@ sub _tagmod_list {
my %my = map +($_->{tag} => $_), @$my;
- for my $cat (sort keys %{$self->{tag_categories}}) {
+ for my $cat (keys %{$self->{tag_categories}}) {
my @tags = grep $_->{cat} eq $cat, @$tags;
next if !@tags;
Tr class => 'tagmod_cat';
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index d3e6b9b3..e7fd9a4f 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -453,7 +453,7 @@ sub edit {
[ check => short => 'traits_sexual', name => mt '_usere_fsextraits' ],
[ check => short => 'tags_all', name => mt '_usere_ftags' ],
[ select => short => 'tags_cat', name => mt('_usere_tagcats'), multi => 1, size => 3,
- options => [ map [ $_, $self->{tag_categories}{$_} ], sort keys %{$self->{tag_categories}} ] ],
+ options => [ map [ $_, $self->{tag_categories}{$_} ], keys %{$self->{tag_categories}} ] ],
[ select => short => 'spoilers', name => mt('_usere_spoilers'), options => [ map [ $_, mt '_spoilset_'.$_ ], 0..2 ] ],
[ select => short => 'skin', name => mt('_usere_skin'), width => 300, options => [
map [ $_, $self->{skins}{$_}[0].($self->debug?" [$_]":'') ], sort { $self->{skins}{$a}[0] cmp $self->{skins}{$b}[0] } keys %{$self->{skins}} ] ],
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index 854bbf46..b906eafa 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -379,8 +379,8 @@ sub _form {
input type => 'checkbox', id => 'official', checked => 'checked';
label for => 'official', mt '_vnedit_rel_official';
Select;
- option value => $_, $self->{vn_relations}{$_}[2]
- for (sort { $self->{vn_relations}{$a}[0] <=> $self->{vn_relations}{$b}[0] } keys %{$self->{vn_relations}});
+ option value => $_, $self->{vn_relations}{$_}[1]
+ for (keys %{$self->{vn_relations}});
end;
txt ' '.mt '_vnedit_rel_of';
end;
@@ -434,7 +434,7 @@ sub _updreverse {
if(exists $$old{$_} and !exists $$new{$_}) {
$upd{$_} = undef;
} elsif((!exists $$old{$_} and exists $$new{$_}) || ($$old{$_}[0] ne $$new{$_}[0] || !$$old{$_}[1] != !$$new{$_}[1])) {
- $upd{$_} = [ $self->{vn_relations}{ $$new{$_}[0] }[1], $$new{$_}[1] ];
+ $upd{$_} = [ $self->{vn_relations}{ $$new{$_}[0] }[0], $$new{$_}[1] ];
}
}
return if !keys %upd;
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 50f21071..82a0599e 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -442,7 +442,7 @@ sub page {
div id => 'tagops';
# NOTE: order of these links is hardcoded in JS
my $tags_cat = $self->authPref('tags_cat') || $self->{default_tags_cat};
- a href => "#$_", $tags_cat =~ /\Q$_/ ? (class => 'tsel') : (), lc $self->{tag_categories}{$_} for sort keys %{$self->{tag_categories}};
+ a href => "#$_", $tags_cat =~ /\Q$_/ ? (class => 'tsel') : (), lc $self->{tag_categories}{$_} for keys %{$self->{tag_categories}};
my $spoiler = $self->authPref('spoilers') || 0;
a href => '#', class => 'sec'.($spoiler == 0 ? ' tsel' : ''), lc mt '_spoilset_0';
a href => '#', $spoiler == 1 ? (class => 'tsel') : (), lc mt '_spoilset_1';
@@ -532,7 +532,7 @@ sub _revision {
[ relations => join => '<br />', split => sub {
my @r = map sprintf('[%s] %s: <a href="/v%d" title="%s">%s</a>',
mt($_->{official} ? '_vndiff_rel_official' : '_vndiff_rel_unofficial'),
- $self->{vn_relations}{$_->{relation}}[2], $_->{id}, xml_escape($_->{original}||$_->{title}), xml_escape shorten $_->{title}, 40
+ $self->{vn_relations}{$_->{relation}}[1], $_->{id}, xml_escape($_->{original}||$_->{title}), xml_escape shorten $_->{title}, 40
), sort { $a->{id} <=> $b->{id} } @{$_[0]};
return @r ? @r : (mt '_revision_empty');
}],
@@ -615,7 +615,7 @@ sub _relations {
td class => 'relations';
dl;
for(sort keys %rel) {
- dt $self->{vn_relations}{$_}[2];
+ dt $self->{vn_relations}{$_}[1];
dd;
for (@{$rel{$_}}) {
b class => 'grayedout', mt('_vnpage_relations_unofficial').' ' if !$_->{official};